src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
|---|---|
DelegateNativeContext2D implements INativeContext2D { public void transform(Transform.TransformJSO jso) { this.transform(jso.get(0), jso.get(1), jso.get(2), jso.get(3), jso.get(4), jso.get(5)); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void transform() { delegateNativeContext2D.transform(1, 1, 1, 1, 1, 1); verify(context, times(1)).transform(1, 1, 1, 1, 1, 1); }
@Test public void transform1() { delegateNativeContext2D.transform(Transform.TransformJSO.make(1, 1, 1, 1, 1, 1)); verify(context, times(1)).transform(1, 1, 1, 1, 1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public void setTransform(Transform.TransformJSO jso) { this.setTransform(jso.get(0), jso.get(1), jso.get(2), jso.get(3), jso.get(4), jso.get(5)); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setTransform() { delegateNativeContext2D.setTransform(Transform.TransformJSO.make(1, 1, 1, 1, 1, 1)); verify(context, times(1)).setTransform(1, 1, 1, 1, 1, 1); }
@Test public void setTransform1() { delegateNativeContext2D.setTransform(1, 1, 1, 1, 1, 1); verify(context, times(1)).setTransform(1, 1, 1, 1, 1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public void setToIdentityTransform() { this.setTransform(1, 0, 0, 1, 0, 0); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setToIdentityTransform() { delegateNativeContext2D.setToIdentityTransform(); verify(context, times(1)).setTransform(1, 0, 0, 1, 0, 0); }
|
DelegateNativeContext2D implements INativeContext2D { public void setTextFont(String font) { context.setFont(font); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setTextFont() { delegateNativeContext2D.setTextFont("arial"); verify(context, times(1)).setFont("arial"); }
|
DelegateNativeContext2D implements INativeContext2D { public void setTextBaseline(String baseline) { context.setTextBaseline(baseline); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setTextBaseline() { delegateNativeContext2D.setTextBaseline("base"); verify(context, times(1)).setTextBaseline("base"); }
|
DelegateNativeContext2D implements INativeContext2D { public void setTextAlign(String align) { context.setTextAlign(align); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setTextAlign() { delegateNativeContext2D.setTextAlign("left"); verify(context, times(1)).setTextAlign("left"); }
|
DelegateNativeContext2D implements INativeContext2D { public void strokeText(String text, double x, double y) { context.strokeText(text, x, y); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void strokeText() { delegateNativeContext2D.strokeText("text", 1, 1); verify(context, times(1)).strokeText("text", 1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public void setGlobalAlpha(double alpha) { context.setGlobalAlpha(alpha); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setGlobalAlpha() { delegateNativeContext2D.setGlobalAlpha(1); verify(context, times(1)).setGlobalAlpha(1); }
|
DelegateNativeContext2D implements INativeContext2D { public void translate(double x, double y) { context.translate(x, y); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void translate() { delegateNativeContext2D.translate(1, 1); verify(context, times(1)).translate(1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public void setShadow(Shadow.ShadowJSO shadow) { if (Objects.nonNull(shadow)) { context.setShadowColor(shadow.getColor()); context.setShadowOffsetX(shadow.getOffset().getX()); context.setShadowOffsetY(shadow.getOffset().getY()); context.setShadowBlur(shadow.getBlur()); } else { context.setShadowColor("transparent"); context.setShadowOffsetX(0); context.setShadowOffsetY(0); context.setShadowBlur(0); } } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setShadow() { delegateNativeContext2D.setShadow(null); verify(context).setShadowColor(Mockito.anyString()); verify(context).setShadowOffsetX(Mockito.anyInt()); verify(context).setShadowOffsetY(Mockito.anyInt()); verify(context).setShadowBlur(Mockito.anyInt()); delegateNativeContext2D.setShadow(null); }
|
DelegateNativeContext2D implements INativeContext2D { public boolean isSupported(String feature) { throwException(); return false; } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test(expected = UnsupportedOperationException.class) public void isSupported() { delegateNativeContext2D.isSupported("feature"); }
|
DelegateNativeContext2D implements INativeContext2D { public boolean isPointInPath(double x, double y) { return context.isPointInPath(x, y); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void isPointInPath() { delegateNativeContext2D.isPointInPath(1, 1); verify(context, times(1)).isPointInPath(1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public ImageData getImageData(double x, double y, double width, double height) { elemental2.dom.ImageData nativeImageData = context.getImageData(x, y, width, height); return nativeClassConverter.convert(nativeImageData, ImageData.class); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void getImageData() { delegateNativeContext2D.getImageData(1, 1, 1, 1); verify(context, times(1)).getImageData(1, 1, 1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public ImageData createImageData(double width, double height) { return nativeClassConverter.convert(context.createImageData(width, height), ImageData.class); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void createImageData() { delegateNativeContext2D.createImageData(null); verify(context, times(1)).createImageData(null); }
@Test public void createImageData1() { delegateNativeContext2D.createImageData(1, 1); verify(context, times(1)).createImageData(1, 1); }
|
DelegateNativeContext2D implements INativeContext2D { public void putImageData(ImageData image, double x, double y) { context.putImageData(nativeClassConverter.convert(image, elemental2.dom.ImageData.class), x, y); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void putImageData() { delegateNativeContext2D.putImageData(null, 1, 1); verify(context, times(1)).putImageData(null, 1, 1); }
@Test public void putImageData1() { delegateNativeContext2D.putImageData(null, 1, 1, 1, 1, 1, 1); verify(context, times(1)).putImageData(null, 1, 1, 1, 1, 1, 1); }
|
OutputClauseLiteralExpressionPropertyConverter { public static JSITLiteralExpression dmnFromWB(final OutputClauseLiteralExpression wb) { if (Objects.isNull(wb)) { return null; } else if (Objects.isNull(wb.getText())) { return null; } else if (StringUtils.isEmpty(wb.getText().getValue())) { return null; } return LiteralExpressionPropertyConverter.dmnFromWB(wb); } static OutputClauseLiteralExpression wbFromDMN(final JSITLiteralExpression dmn); static JSITLiteralExpression dmnFromWB(final OutputClauseLiteralExpression wb); }
|
@Test public void testDMNFromWBWhenNull() { final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(null); assertThat(dmn).isNull(); }
@Test public void testDMNFromWBWhenTextIsNull() { final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression(); wb.setText(null); final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb); assertThat(dmn).isNull(); }
@Test public void testDMNFromWBWhenNonNullWithEmptyString() { final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression(); wb.getText().setValue(""); final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb); assertThat(dmn).isNull(); }
@Test public void testDMNFromWBWhenNonNullWithNonEmptyString() { final OutputClauseLiteralExpression wb = new OutputClauseLiteralExpression(); wb.getText().setValue(TEXT); final JSITLiteralExpression dmn = OutputClauseLiteralExpressionPropertyConverter.dmnFromWB(wb); assertThat(dmn).isNotNull(); verify(jsitLiteralExpression).setText(TEXT); }
|
DelegateNativeContext2D implements INativeContext2D { public TextMetrics measureText(String text) { return nativeClassConverter.convert(context.measureText(text), TextMetrics.class); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void measureText() { delegateNativeContext2D.measureText("text"); verify(context, times(1)).measureText("text"); }
|
DelegateNativeContext2D implements INativeContext2D { public void resetClip() { context.resetClip(); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void resetClip() { delegateNativeContext2D.resetClip(); verify(context, times(1)).resetClip(); }
|
DelegateNativeContext2D implements INativeContext2D { public void setMiterLimit(double limit) { context.setMiterLimit(limit); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setMiterLimit() { delegateNativeContext2D.setMiterLimit(1); verify(context, times(1)).setMiterLimit(1); }
|
DelegateNativeContext2D implements INativeContext2D { public void setLineDash(NFastDoubleArrayJSO dashes) { context.setLineDash(dashes.toArray()); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setLineDash() { delegateNativeContext2D.setLineDash(NFastDoubleArrayJSO.make(1, 1)); verify(context, times(1)).setLineDash(new double[]{1, 1}); }
|
DelegateNativeContext2D implements INativeContext2D { public void setLineDashOffset(double offset) { context.setLineDashOffset(offset); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void setLineDashOffset() { delegateNativeContext2D.setLineDashOffset(1); verify(context, times(1)).setLineDashOffset(1); }
|
DelegateNativeContext2D implements INativeContext2D { public double getBackingStorePixelRatio() { return 1; } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void getBackingStorePixelRatio() { assertEquals(delegateNativeContext2D.getBackingStorePixelRatio(), 1, 0); }
|
DelegateNativeContext2D implements INativeContext2D { public boolean path(PathPartList.PathPartListJSO list) { if (list == null) { return false; } int leng = list.length(); if (leng < 1) { return false; } int indx = 0; this.beginPath(); while (indx < leng) { PathPartEntryJSO e = list.get(indx); indx++; NFastDoubleArrayJSO p = e.getPoints(); switch (e.getCommand()) { case 1: lineTo(p.get(0), p.get(1)); break; case 2: moveTo(p.get(0), p.get(1)); break; case 3: bezierCurveTo(p.get(0), p.get(1), p.get(2), p.get(3), p.get(4), p.get(5)); break; case 4: quadraticCurveTo(p.get(0), p.get(1), p.get(2), p.get(3)); break; case 5: ellipse(p.get(0), p.get(1), p.get(2), p.get(3), p.get(6), p.get(4), p.get(4) + p.get(5), (1 - p.get(7)) > 0); break; case 6: closePath(); break; case 7: this.arcTo(p.get(0), p.get(1), p.get(2), p.get(3), p.get(4)); break; } } return true; } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void path() { assertTrue(delegateNativeContext2D.path(buildPathPartList())); verify(context, times(1)).lineTo(1, 1); verify(context, times(1)).moveTo(2, 2); verify(context, times(1)).bezierCurveTo(1, 2, 3, 4, 5, 6); verify(context, times(1)).quadraticCurveTo(1, 2, 3, 4); verify(context, times(1)).ellipse(1, 2, 3, 4, 7, 5, 5 + 6, false); verify(context, times(1)).closePath(); verify(context, times(1)).arcTo(1, 2, 3, 4, 5); }
|
DelegateNativeContext2D implements INativeContext2D { public IContext2D getDelegate() { return context; } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void getDelegate() { assertEquals(context, delegateNativeContext2D.getDelegate()); }
|
DelegateNativeContext2D implements INativeContext2D { public void drawImage(Element image, double x, double y) { context.drawImage(nativeClassConverter.convert(image, HTMLCanvasElement.class), x, y); } DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler); DelegateNativeContext2D(IContext2D context, AbstractCanvasHandler canvasHandler, Converter converter); void initDeviceRatio(); @Override void saveContainer(String id); @Override void restoreContainer(); void save(); void save(String id); void restore(); void beginPath(); void closePath(); void moveTo(double x, double y); void lineTo(double x, double y); void setGlobalCompositeOperation(String operation); void setLineCap(String lineCap); void setLineJoin(String lineJoin); void quadraticCurveTo(double cpx, double cpy, double x, double y); void arc(double x, double y, double radius, double startAngle, double endAngle); void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea, boolean ac); void ellipse(double x, double y, double rx, double ry, double ro, double sa, double ea); void arcTo(double x1, double y1, double x2, double y2, double radius); void bezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y); void clearRect(double x, double y, double w, double h); void clip(); void fill(); void stroke(); void fillRect(double x, double y, double w, double h); void fillText(String text, double x, double y); void fillTextWithGradient(String text, double x, double y, double sx, double sy, double ex, double ey, String color); void fillText(String text, double x, double y, double maxWidth); void setFillColor(String fill); void rect(double x, double y, double w, double h); void rotate(double angle); void scale(double sx, double sy); void setStrokeColor(String color); void setStrokeWidth(double width); void setImageSmoothingEnabled(boolean enabled); void setFillGradient(LinearGradient.LinearGradientJSO grad); void setFillGradient(PatternGradient.PatternGradientJSO grad); void setFillGradient(RadialGradient.RadialGradientJSO grad); void transform(Transform.TransformJSO jso); void transform(double d0, double d1, double d2, double d3, double d4, double d5); void setTransform(Transform.TransformJSO jso); void setTransform(double d0, double d1, double d2, double d3, double d4, double d5); void setToIdentityTransform(); void setTextFont(String font); void setTextBaseline(String baseline); void setTextAlign(String align); void strokeText(String text, double x, double y); void setGlobalAlpha(double alpha); void translate(double x, double y); void setShadow(Shadow.ShadowJSO shadow); boolean isSupported(String feature); boolean isPointInPath(double x, double y); ImageData getImageData(double x, double y, double width, double height); ImageData createImageData(double width, double height); ImageData createImageData(ImageData data); void putImageData(ImageData image, double x, double y); void putImageData(ImageData image, double x, double y, double dx, double dy, double dw, double dh); TextMetrics measureText(String text); void drawImage(Element image, double x, double y); void drawImage(Element image, double x, double y, double w, double h); void drawImage(Element image, double sx, double sy, double sw, double sh, double x, double y, double w, double h); void resetClip(); void setMiterLimit(double limit); void setLineDash(NFastDoubleArrayJSO dashes); void setLineDashOffset(double offset); double getBackingStorePixelRatio(); boolean path(PathPartList.PathPartListJSO list); boolean clip(PathPartList.PathPartListJSO list); void fill(Path2D.NativePath2D path); void stroke(Path2D.NativePath2D path); void clip(Path2D.NativePath2D path); Path2D.NativePath2D getCurrentPath(); void setCurrentPath(Path2D.NativePath2D path); IContext2D getDelegate(); }
|
@Test public void drawImage() { delegateNativeContext2D.drawImage(element, 1, 1); verify(context, times(1)).drawImage(htmlElement, 1, 1); }
@Test public void drawImage2() { delegateNativeContext2D.drawImage(element, 1, 1, 1, 1); verify(context, times(1)).drawImage(htmlElement, 1, 1, 1, 1); }
@Test public void drawImage3() { delegateNativeContext2D.drawImage(element, 1, 1, 1, 1, 1, 1, 1, 1); verify(context, times(1)).drawImage(htmlElement, 1, 1, 1, 1, 1, 1, 1, 1); }
|
LienzoCanvasExport implements CanvasExport<AbstractCanvasHandler> { @Override public String toImageData(final AbstractCanvasHandler canvasHandler, final CanvasURLExportSettings settings) { final LienzoLayer layer = getLayer(canvasHandler); final int[] bounds = boundsProvider.compute(layer, settings); return LienzoLayerUtils.layerToDataURL(layer, getDataType(settings.getUrlDataType()), bounds[0], bounds[1], bounds[2], bounds[3], BG_COLOR); } LienzoCanvasExport(); LienzoCanvasExport(final BoundsProvider boundsProvider); @Override IContext2D toContext2D(final AbstractCanvasHandler canvasHandler,
final CanvasExportSettings settings); @Override String toImageData(final AbstractCanvasHandler canvasHandler,
final CanvasURLExportSettings settings); static final String BG_COLOR; static final int PADDING; }
|
@Test public void testToJpgImageData() { tested.toImageData(canvasHandler, CanvasURLExportSettings.build(JPG)); verify(context2D, times(1)).setFillColor(eq(LienzoCanvasExport.BG_COLOR)); verify(context2D, times(1)).fillRect(eq(0d), eq(0d), eq(100d), eq(200d)); verify(layer, times(1)).drawWithTransforms(eq(context2D), eq(1d), any(BoundingBox.class)); verify(scratchPad, times(1)).toDataURL(eq(DataURLType.JPG), eq(1d)); verify(scratchPad, times(1)).clear(); }
@Test public void testToPngImageData() { tested.toImageData(canvasHandler, CanvasURLExportSettings.build(PNG)); verify(context2D, times(1)).setFillColor(eq(LienzoCanvasExport.BG_COLOR)); verify(context2D, times(1)).fillRect(eq(0d), eq(0d), eq(100d), eq(200d)); verify(layer, times(1)).drawWithTransforms(eq(context2D), eq(1d), any(BoundingBox.class)); verify(scratchPad, times(1)).toDataURL(eq(DataURLType.PNG), eq(1d)); verify(scratchPad, times(1)).clear(); }
|
LienzoCanvasExport implements CanvasExport<AbstractCanvasHandler> { private static LienzoLayer getLayer(final AbstractCanvasHandler canvasHandler) { return ((WiresCanvas) canvasHandler.getCanvas()).getView().getLayer(); } LienzoCanvasExport(); LienzoCanvasExport(final BoundsProvider boundsProvider); @Override IContext2D toContext2D(final AbstractCanvasHandler canvasHandler,
final CanvasExportSettings settings); @Override String toImageData(final AbstractCanvasHandler canvasHandler,
final CanvasURLExportSettings settings); static final String BG_COLOR; static final int PADDING; }
|
@Test public void testWiresLayerBoundsProvider() { layer = new Layer(); when(lienzoLayer.getLienzoLayer()).thenReturn(layer); WiresManager wiresManager = WiresManager.get(layer); com.ait.lienzo.client.core.shape.wires.WiresLayer wiresLayer = wiresManager.getLayer(); wiresLayer.add(new WiresShape(new MultiPath().rect(0, 0, 50, 50)).setLocation(new Point2D(12, 44))); wiresLayer.add(new WiresShape(new MultiPath().rect(0, 0, 100, 150)).setLocation(new Point2D(1, 3))); LienzoCanvasExport.WiresLayerBoundsProvider provider = new LienzoCanvasExport.WiresLayerBoundsProvider(); int[] size0 = provider.compute(lienzoLayer, CanvasExportSettings.build()); assertEquals(0, size0[0]); assertEquals(0, size0[1]); assertEquals(151, size0[2]); assertEquals(203, size0[3]); }
|
LienzoCanvasExport implements CanvasExport<AbstractCanvasHandler> { @Override public IContext2D toContext2D(final AbstractCanvasHandler canvasHandler, final CanvasExportSettings settings) { final LienzoLayer layer = getLayer(canvasHandler); final com.ait.lienzo.client.core.shape.Layer lienzoLayer = layer.getLienzoLayer(); final Viewport viewport = lienzoLayer.getViewport(); final int[] bounds = boundsProvider.compute(layer, settings); final IContext2D svgContext2D = Context2DFactory.create(new SvgExportSettings(bounds[2], bounds[3], lienzoLayer.getContext())); final Transform transform = viewport.getTransform(); viewport.setTransform(new Transform()); lienzoLayer.draw(new Context2D(new DelegateNativeContext2D(svgContext2D, canvasHandler))); viewport.setTransform(transform); lienzoLayer.draw(); return svgContext2D; } LienzoCanvasExport(); LienzoCanvasExport(final BoundsProvider boundsProvider); @Override IContext2D toContext2D(final AbstractCanvasHandler canvasHandler,
final CanvasExportSettings settings); @Override String toImageData(final AbstractCanvasHandler canvasHandler,
final CanvasURLExportSettings settings); static final String BG_COLOR; static final int PADDING; }
|
@Test public void testToContext2D() { Transform transform = new Transform().translate(11, 33).scale(0.1, 0.3); when(viewport.getTransform()).thenReturn(transform); IContext2D iContext2D = tested.toContext2D(canvasHandler, CanvasExportSettings.build()); assertNotNull(iContext2D); verify(layer, times(1)).draw(any(Context2D.class)); ArgumentCaptor<Transform> transformArgumentCaptor = ArgumentCaptor.forClass(Transform.class); verify(viewport, times(2)).setTransform(transformArgumentCaptor.capture()); verify(layer).draw(); List<Transform> transforms = transformArgumentCaptor.getAllValues(); Transform t0 = transforms.get(0); Transform t1 = transforms.get(1); assertEquals(0d, t0.getTranslateX(), 0d); assertEquals(0d, t0.getTranslateY(), 0d); assertEquals(1d, t0.getScaleX(), 0d); assertEquals(1d, t0.getScaleY(), 0d); assertEquals(11d, t1.getTranslateX(), 0d); assertEquals(33d, t1.getTranslateY(), 0d); assertEquals(0.1d, t1.getScaleX(), 0d); assertEquals(0.3d, t1.getScaleY(), 0d); }
|
CanvasBoundsIndexerImpl implements CanvasBoundsIndexer<AbstractCanvasHandler> { @Override @SuppressWarnings("unchecked") public Node<View<?>, Edge> getAt(final double x, final double y) { final WiresCanvas canvas = (WiresCanvas) canvasHandler.getAbstractCanvas(); final LienzoLayer lienzoLayer = canvas.getView().getLayer(); final String viewUUID = LienzoLayerUtils.getUUID_At(lienzoLayer, x, y); if (null != viewUUID && viewUUID.trim().length() > 0) { final Shape<?> shape = canvas.getShape(viewUUID); if (null != shape) { return canvasHandler.getGraphIndex().getNode(shape.getUUID()); } } return null; } BoundsIndexer<AbstractCanvasHandler, Node<View<?>, Edge>> build(final AbstractCanvasHandler context); @Override @SuppressWarnings("unchecked") Node<View<?>, Edge> getAt(final double x,
final double y); @Override @SuppressWarnings("unchecked") Node<View<?>, Edge> getAt(final double x,
final double y,
final double width,
final double height,
final Element parentNode); @Override double[] getTrimmedBounds(); @Override void destroy(); }
|
@Test public void testGetAt() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(20), eq(20))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20); assertNotNull(node); Node<View<?>, Edge> nodeAtFreePosition = canvasBoundsIndexerImpl.getAt(400, 400); assertNull(nodeAtFreePosition); }
@Test public void testGetAreaAtUL() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(20), eq(20))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20, 100, 100, parentNode); assertNotNull(node); }
@Test public void testGetAreaAtUR() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(120), eq(20))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20, 100, 100, parentNode); assertNotNull(node); }
@Test public void testGetAreaAtCC() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(70), eq(70))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20, 100, 100, parentNode); assertNotNull(node); }
@Test public void testGetAreaAtWhitParentLL() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(20), eq(120))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20, 100, 100, parentNode); assertNotNull(node); }
@Test public void testGetAreaAtWhitParentLR() { when(lienzoLayer.getLienzoLayer().getLayer().findShapeAtPoint(eq(120), eq(120))).thenReturn(shape); Node<View<?>, Edge> node = canvasBoundsIndexerImpl.getAt(20, 20, 100, 100, parentNode); assertNotNull(node); }
@Test public void testGetAreaAtFreePosition() { Node<View<?>, Edge> nodeFreePosition = canvasBoundsIndexerImpl.getAt(0, 600, 100, 10, parentNode); assertNull(nodeFreePosition); }
|
CanvasBoundsIndexerImpl implements CanvasBoundsIndexer<AbstractCanvasHandler> { @Override public void destroy() { this.canvasHandler = null; } BoundsIndexer<AbstractCanvasHandler, Node<View<?>, Edge>> build(final AbstractCanvasHandler context); @Override @SuppressWarnings("unchecked") Node<View<?>, Edge> getAt(final double x,
final double y); @Override @SuppressWarnings("unchecked") Node<View<?>, Edge> getAt(final double x,
final double y,
final double width,
final double height,
final Element parentNode); @Override double[] getTrimmedBounds(); @Override void destroy(); }
|
@Test public void testDestroy() { canvasBoundsIndexerImpl.destroy(); assertNull(canvasBoundsIndexerImpl.canvasHandler); }
|
LienzoCanvasView extends AbstractCanvasView<LienzoCanvasView> { @Override public LienzoCanvasView<L> add(final ShapeView<?> shape) { getLayer().add((IPrimitive<?>) shape); return this; } LienzoCanvasView(); LienzoCanvasView(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFactory); abstract L getLayer(); @Override LienzoCanvasView<L> add(final ShapeView<?> shape); @Override LienzoCanvasView<L> delete(final ShapeView<?> shape); @Override LienzoCanvasView<L> setGrid(final CanvasGrid grid); LienzoCanvasView<L> setDecoratorFactory(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFatory); @Override LienzoCanvasView<L> clear(); @Override Transform getTransform(); LienzoPanel getLienzoPanel(); }
|
@Test public void testInitialize() { assertEquals(tested, tested.initialize(panel, settings)); verify(panel, times(1)).show(eq(lienzoLayer)); verify(panelStyle, times(1)).setBackgroundColor(eq(LienzoCanvasView.BG_COLOR)); verify(topLayer, times(1)).add(eq(decorator)); }
|
LienzoCanvasView extends AbstractCanvasView<LienzoCanvasView> { @Override public LienzoCanvasView<L> setGrid(final CanvasGrid grid) { if (null != grid) { GridLayer gridLayer = LienzoGridLayerBuilder.getLienzoGridFor(grid); getLienzoPanel().setBackgroundLayer(gridLayer); } else { getLienzoPanel().setBackgroundLayer(null); } return this; } LienzoCanvasView(); LienzoCanvasView(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFactory); abstract L getLayer(); @Override LienzoCanvasView<L> add(final ShapeView<?> shape); @Override LienzoCanvasView<L> delete(final ShapeView<?> shape); @Override LienzoCanvasView<L> setGrid(final CanvasGrid grid); LienzoCanvasView<L> setDecoratorFactory(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFatory); @Override LienzoCanvasView<L> clear(); @Override Transform getTransform(); LienzoPanel getLienzoPanel(); }
|
@Test public void testSetGrid() { tested.initialize(panel, settings); tested.setGrid(CanvasGrid.DEFAULT_GRID); verify(panel, times(1)).setBackgroundLayer(any(Layer.class)); }
@Test public void testRemoveGrid() { tested.initialize(panel, settings); tested.setGrid(null); verify(panel, times(1)).setBackgroundLayer(eq(null)); }
|
LienzoCanvasView extends AbstractCanvasView<LienzoCanvasView> { @Override public LienzoCanvasView<L> clear() { getLayer().clear(); return this; } LienzoCanvasView(); LienzoCanvasView(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFactory); abstract L getLayer(); @Override LienzoCanvasView<L> add(final ShapeView<?> shape); @Override LienzoCanvasView<L> delete(final ShapeView<?> shape); @Override LienzoCanvasView<L> setGrid(final CanvasGrid grid); LienzoCanvasView<L> setDecoratorFactory(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFatory); @Override LienzoCanvasView<L> clear(); @Override Transform getTransform(); LienzoPanel getLienzoPanel(); }
|
@Test public void testClear() { tested.clear(); verify(lienzoLayer, times(1)).clear(); }
|
LienzoCanvasView extends AbstractCanvasView<LienzoCanvasView> { @Override public Transform getTransform() { return getLayer().getTransform(); } LienzoCanvasView(); LienzoCanvasView(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFactory); abstract L getLayer(); @Override LienzoCanvasView<L> add(final ShapeView<?> shape); @Override LienzoCanvasView<L> delete(final ShapeView<?> shape); @Override LienzoCanvasView<L> setGrid(final CanvasGrid grid); LienzoCanvasView<L> setDecoratorFactory(final BiFunction<Integer, Integer, IPrimitive<?>> decoratorFatory); @Override LienzoCanvasView<L> clear(); @Override Transform getTransform(); LienzoPanel getLienzoPanel(); }
|
@Test public void testTransform() { Transform transform = mock(Transform.class); when(lienzoLayer.getTransform()).thenReturn(transform); assertEquals(transform, tested.getTransform()); }
|
CommandManagerImpl implements CommandManager<C, V>,
HasCommandListener<CommandListener<C, V>> { @Override public CommandResult<V> allow(final C context, final Command<C, V> command) { Objects.requireNonNull(command, "command"); logCommand("ALLOW", command); final CommandResult<V> result = command.allow(context); if (null != listener) { listener.onAllow(context, command, result); } logResult(result); return result; } CommandManagerImpl(); @Override CommandResult<V> allow(final C context,
final Command<C, V> command); @Override CommandResult<V> execute(final C context,
final Command<C, V> command); @Override CommandResult<V> undo(final C context,
final Command<C, V> command); @Override void setCommandListener(final CommandListener<C, V> listener); }
|
@Test public void allowTest() { commandManager.allow(null, command); verify(commandListener, times(1)).onAllow(any(), any(), any()); }
|
CommandManagerImpl implements CommandManager<C, V>,
HasCommandListener<CommandListener<C, V>> { @Override public CommandResult<V> execute(final C context, final Command<C, V> command) { Objects.requireNonNull(command, "command"); logCommand("EXECUTE", command); final CommandResult<V> result = command.execute(context); if (null != listener) { listener.onExecute(context, command, result); } logResult(result); return result; } CommandManagerImpl(); @Override CommandResult<V> allow(final C context,
final Command<C, V> command); @Override CommandResult<V> execute(final C context,
final Command<C, V> command); @Override CommandResult<V> undo(final C context,
final Command<C, V> command); @Override void setCommandListener(final CommandListener<C, V> listener); }
|
@Test public void executeTest() { commandManager.execute(null, command); verify(commandListener, times(1)).onExecute(any(), any(), any()); }
|
CommandManagerImpl implements CommandManager<C, V>,
HasCommandListener<CommandListener<C, V>> { @Override public CommandResult<V> undo(final C context, final Command<C, V> command) { logCommand("UNDO", command); final CommandResult<V> result = command.undo(context); if (null != listener) { listener.onUndo(context, command, result); } logResult(result); return result; } CommandManagerImpl(); @Override CommandResult<V> allow(final C context,
final Command<C, V> command); @Override CommandResult<V> execute(final C context,
final Command<C, V> command); @Override CommandResult<V> undo(final C context,
final Command<C, V> command); @Override void setCommandListener(final CommandListener<C, V> listener); }
|
@Test public void undoTest() { commandManager.undo(null, command); verify(commandListener, times(1)).onUndo(any(), any(), any()); }
|
PrimitiveUtilities { public static String getClassNameForPrimitiveType(final String type) { if (BYTE.equals(type)) { return Byte.class.getName(); } if (SHORT.equals(type)) { return Short.class.getName(); } if (INT.equals(type)) { return Integer.class.getName(); } if (LONG.equals(type)) { return Long.class.getName(); } if (FLOAT.equals(type)) { return Float.class.getName(); } if (DOUBLE.equals(type)) { return Double.class.getName(); } if (CHAR.equals(type)) { return Character.class.getName(); } if (BOOLEAN.equals(type)) { return Boolean.class.getName(); } return null; } static String getClassNameForPrimitiveType(final String type); static final String BYTE; static final String SHORT; static final String INT; static final String LONG; static final String FLOAT; static final String DOUBLE; static final String CHAR; static final String BOOLEAN; }
|
@Test public void testGetClassNameForPrimitiveType() { assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.BYTE)).isEqualTo(Byte.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.SHORT)).isEqualTo(Short.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.INT)).isEqualTo(Integer.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.LONG)).isEqualTo(Long.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.FLOAT)).isEqualTo(Float.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.DOUBLE)).isEqualTo(Double.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.CHAR)).isEqualTo(Character.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(PrimitiveUtilities.BOOLEAN)).isEqualTo(Boolean.class.getName()); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType("")).isNull(); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType(null)).isNull(); assertThat(PrimitiveUtilities.getClassNameForPrimitiveType("Unknown")).isNull(); }
|
DataEnumLoader { public boolean hasErrors() { return this.errors.size() > 0; } DataEnumLoader(final String mvelSource, final MVELEvaluator mvelEvaluator); DataEnumLoader(final String mvelSource,
final ClassLoader classLoader,
final MVELEvaluator mvelEvaluator); List<String> getErrors(); boolean hasErrors(); Map<String, String[]> getData(); }
|
@Test public void testSimpleEnum() { final String e = "'Fact.field1':[\"A\", \"B\"]"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
@Test public void testValidEnumMultiLine() { final String e = "'Fact.field1':[\"A\", \"B\"]" + System.lineSeparator() + "'Fact.field2':[1, 2]"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
@Test public void testSimpleAndDependentEnum() { final String e = "'Fact.field1':[\"A\", \"B\"]" + System.lineSeparator() + "'Fact.field2[field1=A]':[1, 2]"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
@Test public void testValidDependentEnum() { final String e = "'Fact.field2[field1=A]':'[1, 2, 3]'"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
@Test public void testInvalidDependentEnum_AdvancedEnum1() { final String e = "'Fact.field[dependentField1, dependentField2]' : '(new org.company.DataHelper()).getList(\"@{dependentField1}\", \"@{dependentField2}\")'"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
@Test public void testInvalidDependentEnum_AdvancedEnum2() { final String e = "'Fact.field[dependentField1]' : '(new org.company.DataHelper()).getList(\"@{dependentField1}\")'"; final DataEnumLoader loader = new DataEnumLoader(e, new RawMVELEvaluator()); assertFalse(loader.hasErrors()); }
|
ClassFieldInspector { public Map<String, FieldInfo> getFieldTypesFieldInfo() { return this.fieldTypesFieldInfo; } ClassFieldInspector(final Class<?> clazz); Set<String> getFieldNames(); Map<String, FieldInfo> getFieldTypesFieldInfo(); }
|
@Test public void testGetFieldTypesInfo() { Map<String, FieldInfo> result = bean1Inspector.getFieldTypesFieldInfo(); assertEquals(bean1Fields, result); result = bean2Inspector.getFieldTypesFieldInfo(); assertEquals(bean2Fields, result); }
|
DMNIncludedNodeFactory { DRGElement drgElementWithNamespace(final DRGElement drgElement, final IncludedModel includeModel) { final String modelName = includeModel.getModelName(); drgElement.setName(createName(drgElement, modelName)); drgElement.setAllowOnlyVisualChange(true); if (drgElement instanceof HasVariable) { final HasVariable hasVariable = (HasVariable) drgElement; final IsInformationItem variable = hasVariable.getVariable(); final QName qName = variable.getTypeRef(); if (qName != null && !isBuiltInType(qName.getLocalPart())) { final QName typeRef = createTypeRef(modelName, qName); setVariable(hasVariable, variable, typeRef); } } return drgElement; } DMNIncludedNode makeDMNIncludeNode(final String path,
final IncludedModel includeModel,
final DRGElement drgElement); }
|
@Test public void testDrgElementWithNamespace() { final DRGElement drgElement = mock(DRGElement.class, withSettings().extraInterfaces(HasVariable.class)); final IncludedModel includedModel = mock(IncludedModel.class); final DMNIncludedNodeFactory factory = mock(DMNIncludedNodeFactory.class); final Id elementId = mock(Id.class); final String theId = "theId"; final String theName = "theName"; final String tType = "tType"; final String namespaceUri = "namespaceUri"; final String prefix = "prefix"; final String modelName = "Model Name"; final Name elementName = mock(Name.class); final IsInformationItem informationItem = mock(IsInformationItem.class); final QName qName = mock(QName.class); final Name createdName = mock(Name.class); final QName typeRef = mock(QName.class); when(includedModel.getModelName()).thenReturn(modelName); when(elementId.getValue()).thenReturn(theId); when(elementName.getValue()).thenReturn(theName); when(drgElement.getName()).thenReturn(elementName); when(drgElement.getId()).thenReturn(elementId); when(((HasVariable) drgElement).getVariable()).thenReturn(informationItem); when(qName.getLocalPart()).thenReturn(tType); when(informationItem.getTypeRef()).thenReturn(qName); when(qName.getPrefix()).thenReturn(prefix); when(qName.getNamespaceURI()).thenReturn(namespaceUri); when(factory.createName(drgElement, modelName)).thenReturn(createdName); when(factory.createTypeRef(modelName, qName)).thenReturn(typeRef); doCallRealMethod().when(factory).drgElementWithNamespace(drgElement, includedModel); factory.drgElementWithNamespace(drgElement, includedModel); verify(drgElement).setName(createdName); verify(drgElement).setAllowOnlyVisualChange(true); verify(factory).setVariable((HasVariable) drgElement, informationItem, typeRef); }
|
JavaTypeSystemTranslator implements ClassToGenericClassConverter { @Override public String translateClassToGenericType(final Class<?> type) { String fieldType = null; if (type != null) { if (type.isPrimitive()) { if (type == byte.class) { fieldType = DataType.TYPE_NUMERIC_BYTE; } else if (type == double.class) { fieldType = DataType.TYPE_NUMERIC_DOUBLE; } else if (type == float.class) { fieldType = DataType.TYPE_NUMERIC_FLOAT; } else if (type == int.class) { fieldType = DataType.TYPE_NUMERIC_INTEGER; } else if (type == long.class) { fieldType = DataType.TYPE_NUMERIC_LONG; } else if (type == short.class) { fieldType = DataType.TYPE_NUMERIC_SHORT; } else if (type == boolean.class) { fieldType = DataType.TYPE_BOOLEAN; } else if (type == char.class) { fieldType = DataType.TYPE_STRING; } else if (type == void.class) { fieldType = DataType.TYPE_VOID; } } else if (BigDecimal.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_BIGDECIMAL; } else if (BigInteger.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_BIGINTEGER; } else if (Byte.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_BYTE; } else if (Double.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_DOUBLE; } else if (Float.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_FLOAT; } else if (Integer.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_INTEGER; } else if (Long.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_LONG; } else if (Short.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_NUMERIC_SHORT; } else if (Boolean.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_BOOLEAN; } else if (String.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_STRING; } else if (Collection.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_COLLECTION; } else if (Date.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_DATE; } else if (LocalDate.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_LOCAL_DATE; } else if (Comparable.class.isAssignableFrom(type)) { fieldType = DataType.TYPE_COMPARABLE; } else { fieldType = type.getName(); } } return fieldType; } @Override String translateClassToGenericType(final Class<?> type); }
|
@Test public void testTranslateToGenericType() { Assertions.assertThat(translator.translateClassToGenericType(javaClass)).isEqualTo(translatedType); }
|
ClassFactBuilder extends BaseFactBuilder { @Override public void build(final ModuleDataModelOracleImpl oracle) { super.build(oracle); oracle.addModuleMethodInformation(methodInformation); oracle.addModuleFieldParametersType(fieldParametersType); oracle.addModuleSuperTypes(buildSuperTypes()); oracle.addModuleTypeAnnotations(buildTypeAnnotations()); oracle.addModuleTypeFieldsAnnotations(buildTypeFieldsAnnotations()); } ClassFactBuilder(final ModuleDataModelOracleBuilder builder,
final Class<?> clazz,
final boolean isEvent,
final Function<String, TypeSource> typeSourceResolver); ClassFactBuilder(final ModuleDataModelOracleBuilder builder,
final Map<String, FactBuilder> discoveredFieldFactBuilders,
final Class<?> clazz,
final boolean isEvent,
final Function<String, TypeSource> typeSourceResolver); @Override void build(final ModuleDataModelOracleImpl oracle); @Override void addInternalBuilders(Map<String, FactBuilder> builders); }
|
@Test public void testSuperTypes() throws Exception { final ModuleDataModelOracleBuilder builder = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()); final ModuleDataModelOracleImpl oracle = new ModuleDataModelOracleImpl(); final ClassFactBuilder cb = new ClassFactBuilder(builder, PapaSmurf.class, false, type -> TypeSource.JAVA_PROJECT); cb.build(oracle); assertEquals(2, oracle.getModuleSuperTypes().get(PapaSmurf.class.getName()).size()); }
|
ClassMethodInspector { public List<String> getMethodNames() { List<String> methodList = new ArrayList<String>(); for (MethodInfo info : methods) { methodList.add(info.getName()); } return methodList; } ClassMethodInspector(final Class<?> clazz,
final ClassToGenericClassConverter converter); List<String> getMethodNames(); List<MethodInfo> getMethodInfos(); }
|
@Test public void testMoreThanOneMethodWithTheSameName() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(MoreThanOneMethodWithTheSameName.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testCollection() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(Collection.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testArrayList() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(ArrayList.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testList() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(List.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testSet() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(Set.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testMap() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(Map.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testMyMap() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(MyMap.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testMultiParameterSetter() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(MultiParameterSetter.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } assertEquals(1, ext.getMethodNames().size()); }
@Test public void testGetterWithParameters() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(MyMap.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
@Test public void testBooleanGetterWithParameters() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector(MyMap.class, new JavaTypeSystemTranslator()); for (String s : ext.getMethodNames()) { assertFalse("Method " + s + " is not allowed.", checkBlackList(s)); } }
|
DMNIncludedNodeFactory { QName createTypeRef(final String modelName, final QName qName) { return new QName(qName.getNamespaceURI(), modelName + "." + qName.getLocalPart(), qName.getPrefix()); } DMNIncludedNode makeDMNIncludeNode(final String path,
final IncludedModel includeModel,
final DRGElement drgElement); }
|
@Test public void testCreateTypeRef() { final DMNIncludedNodeFactory factory = new DMNIncludedNodeFactory(); final QName qname = mock(QName.class); final String modelName = "modelName"; final String namespaceUri = "uri"; final String prefix = "prefix"; final String localPart = "localPart"; when(qname.getNamespaceURI()).thenReturn(namespaceUri); when(qname.getPrefix()).thenReturn(prefix); when(qname.getLocalPart()).thenReturn(localPart); final QName typeRef = factory.createTypeRef(modelName, qname); assertEquals(namespaceUri, typeRef.getNamespaceURI()); assertEquals(modelName + "." + localPart, typeRef.getLocalPart()); assertEquals(prefix, typeRef.getPrefix()); }
|
PackageNameValidator implements FileNameValidator { @Override public boolean isValid(final String value) { if (value == null) { return false; } final Map<String, Boolean> results = evaluateIdentifiers(value.split("\\.", -1)); return !results.containsValue(Boolean.FALSE); } @Override int getPriority(); @Override boolean accept(final String fileName); @Override boolean accept(final Path path); @Override boolean isValid(final String value); }
|
@Test public void isValid() { assertEquals(valid, VALIDATOR.isValid(input)); }
|
DefaultGenericKieValidator implements GenericValidator { public List<ValidationMessage> validate(final Path path, final String content) { return validatorBuildService.validate(path, content) .stream() .filter(fromValidatedPath(path)) .collect(Collectors.toList()); } DefaultGenericKieValidator(); @Inject DefaultGenericKieValidator(final ValidatorBuildService validatorBuildService); List<ValidationMessage> validate(final Path path,
final String content); List<ValidationMessage> validate(final Path path); }
|
@Test public void testWorks() throws Exception { final Path path = resourcePath("/GuvnorM2RepoDependencyExample1/src/main/resources/rule2.drl"); final URL urlToValidate = this.getClass().getResource("/GuvnorM2RepoDependencyExample1/src/main/resources/rule2.drl"); final List<ValidationMessage> errors = validator.validate(path, Resources.toString(urlToValidate, Charset.forName("UTF-8"))); assertTrue(errors.isEmpty()); }
@Test public void validatingAnAlreadyInvalidAssetShouldReportErrors() throws Exception { final Path path = resourcePath("/BuilderExampleBrokenSyntax/src/main/resources/rule1.drl"); final URL urlToValidate = this.getClass().getResource("/BuilderExampleBrokenSyntax/src/main/resources/rule1.drl"); final List<ValidationMessage> errors1 = validator.validate(path, Resources.toString(urlToValidate, Charset.forName("UTF-8"))); final List<ValidationMessage> errors2 = validator.validate(path, Resources.toString(urlToValidate, Charset.forName("UTF-8"))); assertFalse(errors1.isEmpty()); assertFalse(errors2.isEmpty()); assertEquals(errors1.size(), errors2.size()); }
|
ValidationServiceImpl implements ValidationService { @Override public boolean validateGroupId(final String groupId) { final String[] groupIdComponents = (groupId == null ? new String[]{} : groupId.split("\\.", -1)); final boolean validGroupId = !(groupIdComponents.length == 0 || evaluateMavenIdentifiers(groupIdComponents).containsValue(Boolean.FALSE)); return validGroupId; } ValidationServiceImpl(); @Inject ValidationServiceImpl(final org.uberfire.ext.editor.commons.service.ValidationService validationService,
final PackageNameValidator packageNameValidator,
final ModuleNameValidator moduleNameValidator,
final JavaFileNameValidator javaFileNameValidator,
final Instance<SaveValidator<?>> saveValidatorInstance,
final Instance<CopyValidator<?>> copyValidatorInstance,
final Instance<DeleteValidator<?>> deleteValidatorInstance); @Override boolean isProjectNameValid(final String projectName); @Override boolean isPackageNameValid(final String packageName); @Override boolean isFileNameValid(final Path path,
final String fileName); boolean isJavaFileNameValid(final String fileName); @Override boolean isFileNameValid(String fileName); @Override boolean isBranchNameValid(final String branchName); @Override Map<String, Boolean> evaluateJavaIdentifiers(String[] identifiers); @Override Map<String, Boolean> evaluateMavenIdentifiers(String[] identifiers); @Override boolean isTimerIntervalValid(final String timerInterval); @Override boolean validate(final POM pom); @Override boolean validateGroupId(final String groupId); @Override boolean validateArtifactId(final String artifactId); @Override boolean validateGAVVersion(final String version); @Override Collection<ValidationMessage> validateForSave(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path); @Override Collection<ValidationMessage> validateForDelete(final Path path,
final T content); @Override Collection<ValidationMessage> validateForDelete(final Path path); }
|
@Test public void testValidateGroup() { assertFalse(validationService.validateGroupId("proj w spcs")); assertFalse(validationService.validateGroupId(".")); assertFalse(validationService.validateGroupId(".name")); assertFalse(validationService.validateGroupId("name.")); assertTrue(validationService.validateGroupId("proj-w-hyps")); assertTrue(validationService.validateGroupId("proj.w.int")); assertTrue(validationService.validateGroupId("proj.w.123")); }
|
ValidationServiceImpl implements ValidationService { @Override public boolean validateArtifactId(final String artifactId) { final String[] artifactIdComponents = (artifactId == null ? new String[]{} : artifactId.split("\\.", -1)); final boolean validArtifactId = !(artifactIdComponents.length == 0 || evaluateMavenIdentifiers(artifactIdComponents).containsValue(Boolean.FALSE)); return validArtifactId; } ValidationServiceImpl(); @Inject ValidationServiceImpl(final org.uberfire.ext.editor.commons.service.ValidationService validationService,
final PackageNameValidator packageNameValidator,
final ModuleNameValidator moduleNameValidator,
final JavaFileNameValidator javaFileNameValidator,
final Instance<SaveValidator<?>> saveValidatorInstance,
final Instance<CopyValidator<?>> copyValidatorInstance,
final Instance<DeleteValidator<?>> deleteValidatorInstance); @Override boolean isProjectNameValid(final String projectName); @Override boolean isPackageNameValid(final String packageName); @Override boolean isFileNameValid(final Path path,
final String fileName); boolean isJavaFileNameValid(final String fileName); @Override boolean isFileNameValid(String fileName); @Override boolean isBranchNameValid(final String branchName); @Override Map<String, Boolean> evaluateJavaIdentifiers(String[] identifiers); @Override Map<String, Boolean> evaluateMavenIdentifiers(String[] identifiers); @Override boolean isTimerIntervalValid(final String timerInterval); @Override boolean validate(final POM pom); @Override boolean validateGroupId(final String groupId); @Override boolean validateArtifactId(final String artifactId); @Override boolean validateGAVVersion(final String version); @Override Collection<ValidationMessage> validateForSave(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path); @Override Collection<ValidationMessage> validateForDelete(final Path path,
final T content); @Override Collection<ValidationMessage> validateForDelete(final Path path); }
|
@Test public void testValidateArtifact() { assertFalse(validationService.validateArtifactId("proj w spcs")); assertFalse(validationService.validateArtifactId(".")); assertFalse(validationService.validateArtifactId(".name")); assertFalse(validationService.validateArtifactId("name.")); assertTrue(validationService.validateArtifactId("proj-w-hyps")); assertTrue(validationService.validateArtifactId("proj.w.int")); assertTrue(validationService.validateArtifactId("proj.2.123")); }
|
ValidationServiceImpl implements ValidationService { @Override public boolean validateGAVVersion(final String version) { final boolean validVersion = !(version == null || version.isEmpty() || !version.matches("^[a-zA-Z0-9\\.\\-_]+$")); return validVersion; } ValidationServiceImpl(); @Inject ValidationServiceImpl(final org.uberfire.ext.editor.commons.service.ValidationService validationService,
final PackageNameValidator packageNameValidator,
final ModuleNameValidator moduleNameValidator,
final JavaFileNameValidator javaFileNameValidator,
final Instance<SaveValidator<?>> saveValidatorInstance,
final Instance<CopyValidator<?>> copyValidatorInstance,
final Instance<DeleteValidator<?>> deleteValidatorInstance); @Override boolean isProjectNameValid(final String projectName); @Override boolean isPackageNameValid(final String packageName); @Override boolean isFileNameValid(final Path path,
final String fileName); boolean isJavaFileNameValid(final String fileName); @Override boolean isFileNameValid(String fileName); @Override boolean isBranchNameValid(final String branchName); @Override Map<String, Boolean> evaluateJavaIdentifiers(String[] identifiers); @Override Map<String, Boolean> evaluateMavenIdentifiers(String[] identifiers); @Override boolean isTimerIntervalValid(final String timerInterval); @Override boolean validate(final POM pom); @Override boolean validateGroupId(final String groupId); @Override boolean validateArtifactId(final String artifactId); @Override boolean validateGAVVersion(final String version); @Override Collection<ValidationMessage> validateForSave(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path); @Override Collection<ValidationMessage> validateForDelete(final Path path,
final T content); @Override Collection<ValidationMessage> validateForDelete(final Path path); }
|
@Test public void testValidateVersion() { assertTrue(validationService.validateGAVVersion("1111")); assertTrue(validationService.validateGAVVersion("1.0-SNAPSHOT")); assertTrue(validationService.validateGAVVersion("1.1.Final")); assertTrue(validationService.validateGAVVersion("1.1-Final")); assertTrue(validationService.validateGAVVersion("1.1-Beta-11")); assertFalse(validationService.validateGAVVersion("1.1 Beta 11")); }
|
ValidationServiceImpl implements ValidationService { @Override public boolean isProjectNameValid(final String projectName) { return moduleNameValidator.isValid(projectName) && NewWorkspaceProjectUtils.sanitizeProjectName(projectName).equals(projectName.replace(" ", "")); } ValidationServiceImpl(); @Inject ValidationServiceImpl(final org.uberfire.ext.editor.commons.service.ValidationService validationService,
final PackageNameValidator packageNameValidator,
final ModuleNameValidator moduleNameValidator,
final JavaFileNameValidator javaFileNameValidator,
final Instance<SaveValidator<?>> saveValidatorInstance,
final Instance<CopyValidator<?>> copyValidatorInstance,
final Instance<DeleteValidator<?>> deleteValidatorInstance); @Override boolean isProjectNameValid(final String projectName); @Override boolean isPackageNameValid(final String packageName); @Override boolean isFileNameValid(final Path path,
final String fileName); boolean isJavaFileNameValid(final String fileName); @Override boolean isFileNameValid(String fileName); @Override boolean isBranchNameValid(final String branchName); @Override Map<String, Boolean> evaluateJavaIdentifiers(String[] identifiers); @Override Map<String, Boolean> evaluateMavenIdentifiers(String[] identifiers); @Override boolean isTimerIntervalValid(final String timerInterval); @Override boolean validate(final POM pom); @Override boolean validateGroupId(final String groupId); @Override boolean validateArtifactId(final String artifactId); @Override boolean validateGAVVersion(final String version); @Override Collection<ValidationMessage> validateForSave(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path); @Override Collection<ValidationMessage> validateForDelete(final Path path,
final T content); @Override Collection<ValidationMessage> validateForDelete(final Path path); }
|
@Test public void testProjectNameValid() { when(projectValidator.isValid(any())).thenReturn(false); assertFalse(validationService.isProjectNameValid("foo")); when(projectValidator.isValid(any())).thenReturn(true); assertTrue(validationService.isProjectNameValid("t")); assertTrue(validationService.isProjectNameValid("test")); assertTrue(validationService.isProjectNameValid("test_")); assertTrue(validationService.isProjectNameValid("test-")); assertTrue(validationService.isProjectNameValid("test.")); assertTrue(validationService.isProjectNameValid("test0")); assertTrue(validationService.isProjectNameValid("Test-0")); assertTrue(validationService.isProjectNameValid("Test-._")); assertTrue(validationService.isProjectNameValid("Test.test")); assertTrue(validationService.isProjectNameValid("test ")); assertTrue(validationService.isProjectNameValid(" test ")); assertFalse(validationService.isProjectNameValid("test@")); assertFalse(validationService.isProjectNameValid("test\\u1234")); assertFalse(validationService.isProjectNameValid("\\u1234\\u1111")); assertFalse(validationService.isProjectNameValid("test!")); }
|
ValidationServiceImpl implements ValidationService { @Override public boolean isBranchNameValid(final String branchName) { final Matcher branchNameMatcher = branchNameValidator.matcher(branchName); return branchNameMatcher.matches(); } ValidationServiceImpl(); @Inject ValidationServiceImpl(final org.uberfire.ext.editor.commons.service.ValidationService validationService,
final PackageNameValidator packageNameValidator,
final ModuleNameValidator moduleNameValidator,
final JavaFileNameValidator javaFileNameValidator,
final Instance<SaveValidator<?>> saveValidatorInstance,
final Instance<CopyValidator<?>> copyValidatorInstance,
final Instance<DeleteValidator<?>> deleteValidatorInstance); @Override boolean isProjectNameValid(final String projectName); @Override boolean isPackageNameValid(final String packageName); @Override boolean isFileNameValid(final Path path,
final String fileName); boolean isJavaFileNameValid(final String fileName); @Override boolean isFileNameValid(String fileName); @Override boolean isBranchNameValid(final String branchName); @Override Map<String, Boolean> evaluateJavaIdentifiers(String[] identifiers); @Override Map<String, Boolean> evaluateMavenIdentifiers(String[] identifiers); @Override boolean isTimerIntervalValid(final String timerInterval); @Override boolean validate(final POM pom); @Override boolean validateGroupId(final String groupId); @Override boolean validateArtifactId(final String artifactId); @Override boolean validateGAVVersion(final String version); @Override Collection<ValidationMessage> validateForSave(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path,
final T content); @Override Collection<ValidationMessage> validateForCopy(final Path path); @Override Collection<ValidationMessage> validateForDelete(final Path path,
final T content); @Override Collection<ValidationMessage> validateForDelete(final Path path); }
|
@Test public void testValidateBranchName() { assertTrue(validationService.isBranchNameValid("test")); assertTrue(validationService.isBranchNameValid("test#")); assertTrue(validationService.isBranchNameValid("test!")); assertTrue(validationService.isBranchNameValid("test-")); assertTrue(validationService.isBranchNameValid("test_")); assertTrue(validationService.isBranchNameValid("test&")); assertTrue(validationService.isBranchNameValid("test%")); assertFalse(validationService.isBranchNameValid("@test")); assertFalse(validationService.isBranchNameValid("test@")); assertFalse(validationService.isBranchNameValid("te@st")); assertFalse(validationService.isBranchNameValid("/test")); assertFalse(validationService.isBranchNameValid("test/")); assertTrue(validationService.isBranchNameValid("te/st")); assertFalse(validationService.isBranchNameValid("..test")); assertFalse(validationService.isBranchNameValid("test..")); assertFalse(validationService.isBranchNameValid("te..st")); assertTrue(validationService.isBranchNameValid("\041test")); assertTrue(validationService.isBranchNameValid("test\041")); assertTrue(validationService.isBranchNameValid("te\041st")); assertFalse(validationService.isBranchNameValid("\000test")); assertFalse(validationService.isBranchNameValid("test\000")); assertFalse(validationService.isBranchNameValid("te\000st")); assertFalse(validationService.isBranchNameValid("\010test")); assertFalse(validationService.isBranchNameValid("test\010")); assertFalse(validationService.isBranchNameValid("te\010st")); assertFalse(validationService.isBranchNameValid("\037test")); assertFalse(validationService.isBranchNameValid("test\037")); assertFalse(validationService.isBranchNameValid("te\037st")); assertFalse(validationService.isBranchNameValid("\177test")); assertFalse(validationService.isBranchNameValid("test\177")); assertFalse(validationService.isBranchNameValid("te\177st")); assertFalse(validationService.isBranchNameValid(" test")); assertFalse(validationService.isBranchNameValid("test ")); assertFalse(validationService.isBranchNameValid("te st")); assertFalse(validationService.isBranchNameValid("~test")); assertFalse(validationService.isBranchNameValid("test~")); assertFalse(validationService.isBranchNameValid("te~st")); assertFalse(validationService.isBranchNameValid("^test")); assertFalse(validationService.isBranchNameValid("test^")); assertFalse(validationService.isBranchNameValid("te^st")); assertFalse(validationService.isBranchNameValid(":test")); assertFalse(validationService.isBranchNameValid("test:")); assertFalse(validationService.isBranchNameValid("te:st")); assertFalse(validationService.isBranchNameValid("?test")); assertFalse(validationService.isBranchNameValid("test?")); assertFalse(validationService.isBranchNameValid("te?st")); assertFalse(validationService.isBranchNameValid("*test")); assertFalse(validationService.isBranchNameValid("test*")); assertFalse(validationService.isBranchNameValid("te*st")); assertFalse(validationService.isBranchNameValid("[test")); assertFalse(validationService.isBranchNameValid("test[")); assertFalse(validationService.isBranchNameValid("te[st")); assertFalse(validationService.isBranchNameValid(".test")); assertFalse(validationService.isBranchNameValid("test.")); assertTrue(validationService.isBranchNameValid("te.st")); assertFalse(validationService.isBranchNameValid(" assertFalse(validationService.isBranchNameValid("test assertFalse(validationService.isBranchNameValid("te assertFalse(validationService.isBranchNameValid("@{test")); assertFalse(validationService.isBranchNameValid("test@{")); assertFalse(validationService.isBranchNameValid("te@{st")); assertFalse(validationService.isBranchNameValid("@")); assertFalse(validationService.isBranchNameValid("\\test")); assertFalse(validationService.isBranchNameValid("test\\")); assertFalse(validationService.isBranchNameValid("te\\st")); assertFalse(validationService.isBranchNameValid("-test")); assertTrue(validationService.isBranchNameValid("te-st")); assertTrue(validationService.isBranchNameValid("test-")); }
|
DMNIncludedNodeFactory { Name createName(final DRGElement drgElement, final String modelName) { return new Name(modelName + "." + drgElement.getName().getValue()); } DMNIncludedNode makeDMNIncludeNode(final String path,
final IncludedModel includeModel,
final DRGElement drgElement); }
|
@Test public void testCreateName() { final DMNIncludedNodeFactory factory = new DMNIncludedNodeFactory(); final DRGElement drgElement = mock(DRGElement.class); final String theName = "the name"; final Name name = new Name(theName); final String modelName = "modelName"; when(drgElement.getName()).thenReturn(name); final Name createdName = factory.createName(drgElement, modelName); assertEquals(modelName + "." + theName, createdName.getValue()); }
|
DependencyServiceImpl implements DependencyService { @Override public Collection<Dependency> loadDependencies(final Collection<GAV> gavs) { final ArrayList<Dependency> dependencies = new ArrayList<Dependency>(); for (final GAV gav : gavs) { dependencies.addAll(loadDependencies(gav)); } return dependencies; } DependencyServiceImpl(); @Override Collection<Dependency> loadDependencies(final Collection<GAV> gavs); @Override Collection<Dependency> loadDependencies(final GAV gav); @Override Set<String> loadPackageNames(final GAV gav); @Override EnhancedDependencies loadEnhancedDependencies(final Collection<Dependency> dependencies); }
|
@Test public void testNoDependencies() throws Exception { GAV gav = new GAV( "artifactID", "groupID", "version" ); Collection<Dependency> dependencies = service.loadDependencies( gav ); assertTrue( dependencies.isEmpty() ); }
@Test public void testDependencies() throws Exception { Collection<Dependency> dependencies = service.loadDependencies( new GAV( "junit", "junit", "4.11" ) ); assertEquals( 1, dependencies.size() ); Dependency dependency = dependencies.iterator().next(); assertEquals( "org.hamcrest", dependency.getGroupId() ); assertEquals( "hamcrest-core", dependency.getArtifactId() ); assertEquals( "1.3", dependency.getVersion() ); }
@Test public void testDependenciesForGAVs() throws Exception { final Collection<GAV> gavs = new ArrayList<GAV>(); gavs.add( new GAV( "junit", "junit", "4.11" ) ); gavs.add( new GAV( "org.guvnor", "guvnor-web-app", "5.0" ) ); Collection<Dependency> dependencies = service.loadDependencies( gavs ); assertEquals( 2, dependencies.size() ); final Iterator<Dependency> iterator = dependencies.iterator(); Dependency dependency = iterator.next(); assertEquals( "org.hamcrest", dependency.getGroupId() ); assertEquals( "hamcrest-core", dependency.getArtifactId() ); assertEquals( "1.3", dependency.getVersion() ); dependency = iterator.next(); assertEquals( "org.drools", dependency.getGroupId() ); assertEquals( "drools-core", dependency.getArtifactId() ); assertEquals( "5.0", dependency.getVersion() ); }
|
DependencyServiceImpl implements DependencyService { @Override public Set<String> loadPackageNames(final GAV gav) { final Artifact artifact = getMavenRepository().resolveArtifact(gav.toString()); if (artifact != null) { return stripPackageNamesFromJar(artifact.getFile()); } else { return new HashSet<>(); } } DependencyServiceImpl(); @Override Collection<Dependency> loadDependencies(final Collection<GAV> gavs); @Override Collection<Dependency> loadDependencies(final GAV gav); @Override Set<String> loadPackageNames(final GAV gav); @Override EnhancedDependencies loadEnhancedDependencies(final Collection<Dependency> dependencies); }
|
@Test public void testListPackages() throws Exception { Set<String> junitPackages = service.loadPackageNames( new GAV( "junit", "junit", "4.11" ) ); Set<String> hamcrestPackages = service.loadPackageNames( new GAV( "org.hamcrest", "hamcrest-core", "1.3" ) ); assertTrue( junitPackages.contains( "org.junit.rules" ) ); assertTrue( junitPackages.contains( "org.junit.matchers" ) ); assertFalse( junitPackages.contains( "org.hamcrest" ) ); assertFalse( junitPackages.contains( "org.hamcrest.core" ) ); assertTrue( hamcrestPackages.contains( "org.hamcrest" ) ); assertTrue( hamcrestPackages.contains( "org.hamcrest.core" ) ); assertFalse( hamcrestPackages.contains( "org.junit.rules" ) ); assertFalse( hamcrestPackages.contains( "org.junit.matchers" ) ); }
@Test public void testFillDependenciesWithPackageNames() throws Exception { final Set<String> packageNames = service.loadPackageNames( new GAV( "junit", "junit", "4.11" ) ); assertEquals( 2, packageNames.size() ); assertTrue( packageNames.contains( "org.junit.rules" ) ); assertTrue( packageNames.contains( "org.junit.matchers" ) ); }
|
PackageNameWhiteListSaver implements SupportsUpdate<WhiteList> { @Override public Path save( final Path path, final WhiteList content, final Metadata metadata, final String comment ) { try { ioService.write( Paths.convert( path ), toString( content ), metadataService.setUpAttributes( path, metadata ), commentedOptionFactory.makeCommentedOption( comment ) ); return path; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } } PackageNameWhiteListSaver(); @Inject PackageNameWhiteListSaver( final @Named( "ioStrategy" ) IOService ioService,
final MetadataServerSideService metadataService,
final CommentedOptionFactory commentedOptionFactory ); @Override Path save( final Path path,
final WhiteList content,
final Metadata metadata,
final String comment ); }
|
@Test public void testSave() throws Exception { final Path path = testFileSystem.createTempFile( "whitelist" ); final WhiteList whiteList = new WhiteList(); whiteList.add( "org.drools" ); whiteList.add( "org.guvnor" ); final Metadata metadata = new Metadata(); final String comment = "comment"; final HashMap<String, Object> attributes = new HashMap<String, Object>(); when( metadataService.setUpAttributes( path, metadata ) ).thenReturn( attributes ); final CommentedOption commentedOption = mock( CommentedOption.class ); when( commentedOptionFactory.makeCommentedOption( "comment" ) ).thenReturn( commentedOption ); saver.save( path, whiteList, metadata, comment ); ArgumentCaptor<String> whiteListTextArgumentCaptor = ArgumentCaptor.forClass( String.class ); verify( ioService ).write( any( org.uberfire.java.nio.file.Path.class ), whiteListTextArgumentCaptor.capture(), eq( attributes ), eq( commentedOption ) ); final String whiteListAsText = whiteListTextArgumentCaptor.getValue(); assertTrue( whiteListAsText.contains( "org.drools" ) ); assertTrue( whiteListAsText.contains( "org.guvnor" ) ); }
|
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public WhiteList filterPackageNames(final Module module, final Collection<String> packageNames) { if (packageNames == null) { return new WhiteList(); } else if (module instanceof KieModule) { final WhiteList whiteList = load(((KieModule) module).getPackageNamesWhiteListPath()); if (whiteList.isEmpty()) { return new WhiteList(packageNames); } else { for (Package aPackage : moduleService.resolvePackages(module)) { whiteList.add(aPackage.getPackageName()); } return new PackageNameWhiteListFilter(packageNames, whiteList).getFilteredPackageNames(); } } else { return new WhiteList(packageNames); } } PackageNameWhiteListServiceImpl(); @Inject PackageNameWhiteListServiceImpl(final @Named("ioStrategy") IOService ioService,
final KieModuleService moduleService,
final PackageNameWhiteListLoader loader,
final PackageNameWhiteListSaver saver); void createModuleWhiteList(final Path packageNamesWhiteListPath,
final String initialContent); @Override WhiteList filterPackageNames(final Module module,
final Collection<String> packageNames); @Override WhiteList load(final Path packageNamesWhiteListPath); @Override Path save(final Path path,
final WhiteList content,
final Metadata metadata,
final String comment); }
|
@Test public void ifWhiteListIsEmptyWhiteListEverything() throws Exception { final PackageNameWhiteListService packageNameWhiteListService = makeService(""); WhiteList filterPackageNames = packageNameWhiteListService.filterPackageNames(mock(KieModule.class), new ArrayList<String> () {{ add("a"); add("b"); add("c"); }}); assertEquals(3, filterPackageNames.size()); assertTrue(filterPackageNames.contains("a")); assertTrue(filterPackageNames.contains("b")); assertTrue(filterPackageNames.contains("c")); }
@Test public void testWindowsEncoding() { final PackageNameWhiteListService packageNameWhiteListService = makeService("a.**\r\nb\r\n"); final Set<String> results = packageNameWhiteListService.filterPackageNames(mock(KieModule.class), new ArrayList<String>() {{ add("a"); add("b"); add("a.b"); }}); assertEquals(3, results.size()); assertContains("a", results); assertContains("b", results); assertContains("a.b", results); }
@Test public void testUnixEncoding() { final PackageNameWhiteListService packageNameWhiteListService = makeService("a.**\nb\n"); final Set<String> results = packageNameWhiteListService.filterPackageNames(mock(KieModule.class), new ArrayList<String>() {{ add("a"); add("b"); add("a.b"); }}); assertEquals(3, results.size()); assertContains("a", results); assertContains("b", results); assertContains("a.b", results); }
|
PackageNameWhiteListServiceImpl implements PackageNameWhiteListService { @Override public Path save(final Path path, final WhiteList content, final Metadata metadata, final String comment) { return saver.save(path, content, metadata, comment); } PackageNameWhiteListServiceImpl(); @Inject PackageNameWhiteListServiceImpl(final @Named("ioStrategy") IOService ioService,
final KieModuleService moduleService,
final PackageNameWhiteListLoader loader,
final PackageNameWhiteListSaver saver); void createModuleWhiteList(final Path packageNamesWhiteListPath,
final String initialContent); @Override WhiteList filterPackageNames(final Module module,
final Collection<String> packageNames); @Override WhiteList load(final Path packageNamesWhiteListPath); @Override Path save(final Path path,
final WhiteList content,
final Metadata metadata,
final String comment); }
|
@Test public void testSave() throws Exception { final PackageNameWhiteListService service = makeService(""); final Path path = mock(Path.class); final WhiteList whiteList = new WhiteList(); final Metadata metadata = new Metadata(); final String comment = "comment"; service.save(path, whiteList, metadata, comment); verify(saver).save(path, whiteList, metadata, comment); }
|
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void loadModels(final ServiceCallback<List<IncludedModel>> callback) { final List<IncludedModel> models = new ArrayList<>(); dmnImportsContentService.getModelsURIs() .then(items -> promises.all(Arrays.asList(items), file -> { final String fileName = FileUtils.getFileName(file); if (fileName.endsWith("." + DMNImportTypes.DMN.getFileExtension())) { return dmnImportsContentService.loadFile(file) .then(fileContent -> promises.create((success, failed) -> dmnImportsService.getWbDefinitions(fileContent, new ServiceCallback<Definitions>() { @Override public void onSuccess(final Definitions definitions) { final String modelPackage = ""; final String namespace = definitions.getNamespace().getValue(); final String importType = DMNImportTypes.DMN.getDefaultNamespace(); final int drgElementCount = definitions.getDrgElement().size(); final int itemDefinitionCount = definitions.getItemDefinition().size(); models.add(new DMNIncludedModel(fileName, modelPackage, fileName, namespace, importType, drgElementCount, itemDefinitionCount)); success.onInvoke(promises.resolve()); } @Override public void onError(final ClientRuntimeError error) { success.onInvoke(promises.resolve()); } }))); } if (fileName.endsWith("." + DMNImportTypes.PMML.getFileExtension())) { return dmnImportsContentService.getPMMLDocumentMetadata(file) .then(pmmlDocumentMetadata -> { int modelCount = pmmlDocumentMetadata.getModels() != null ? pmmlDocumentMetadata.getModels().size() : 0; models.add(new PMMLIncludedModel(fileName, "", fileName, DMNImportTypes.PMML.getDefaultNamespace(), modelCount)); return promises.resolve(); }); } return promises.reject("Error: " + fileName + " is an invalid file. Only *.dmn and *.pmml are supported"); }).then(v -> { callback.onSuccess(models); return promises.resolve(); })); } @Inject DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
final DMNMarshallerImportsContentService dmnImportsContentService,
final Promises promises,
final DMNIncludedNodeFactory includedModelFactory); Promise<Map<JSITImport, JSITDefinitions>> getImportDefinitionsAsync(final Metadata metadata,
final List<JSITImport> imports); void loadNodesFromModels(final List<DMNIncludedModel> includedModels,
final ServiceCallback<List<DMNIncludedNode>> callback); void loadModels(final ServiceCallback<List<IncludedModel>> callback); Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata,
final List<JSITImport> imports); @Override Map<JSITImport, String> getImportXML(final Metadata metadata,
final List<JSITImport> imports); @Override List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions); @Override List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions); void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels,
final ServiceCallback<List<PMMLDocumentMetadata>> callback); void getImportedItemDefinitionsByNamespaceAsync(final String modelName,
final String namespace,
final ServiceCallback<List<ItemDefinition>> callback); }
|
@Test public void loadModelsDMNFile() { when(dmnImportsContentService.getModelsURIs()).thenReturn(promises.resolve(new String[]{DMN_PATH})); when(dmnImportsContentService.loadFile(DMN_PATH)).thenReturn(promises.resolve(DMN_CONTENT)); importsHelper.loadModels(includedModelServiceCallback); verify(dmnImportsContentService).loadFile(eq(DMN_PATH)); }
@Test public void loadModelsPMMLFile() { final PMMLDocumentMetadata pmmlDocumentMetadata = new PMMLDocumentMetadata(PMML_PATH, PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList()); when(dmnImportsContentService.getModelsURIs()).thenReturn(promises.resolve(new String[]{PMML_PATH})); when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT)); when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT)); doReturn(promises.resolve(pmmlDocumentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH); importsHelper.loadModels(includedModelServiceCallback); verify(includedModelServiceCallback).onSuccess(modelsCapture.capture()); assertEquals(1, modelsCapture.getValue().size()); assertEquals(PMML_FILE, modelsCapture.getValue().get(0).getPath()); assertEquals(PMML_FILE, modelsCapture.getValue().get(0).getModelName()); assertEquals(PMML.getDefaultNamespace(), modelsCapture.getValue().get(0).getImportType()); assertEquals(0, ((PMMLIncludedModel) modelsCapture.getValue().get(0)).getModelCount().intValue()); }
@Test public void loadModelsInvalidFile() { when(dmnImportsContentService.getModelsURIs()).thenReturn(promises.resolve(new String[]{TEXT_PATH})); importsHelper.loadModels(includedModelServiceCallback); verify(dmnImportsContentService, never()).loadFile(anyString()); verify(dmnImportsContentService, never()).getPMMLDocumentMetadata(anyString()); verify(dmnImportsService, never()).getWbDefinitions(anyString(), any()); }
|
PackageNameSearchProvider { public PackageNameSearch newTopLevelPackageNamesSearch( final POM pom ) { return new PackageNameSearch( pom ); } PackageNameSearchProvider(); @Inject PackageNameSearchProvider( final DependencyService dependencyService ); PackageNameSearch newTopLevelPackageNamesSearch( final POM pom ); }
|
@Test public void testLoadTopLevelDependencies() throws Exception { POM pom = new POM( new GAV( "artifactID", "groupID", "version" ) ); pom.getDependencies().add( getDependency( "drools-core", "org.drools", "6.3.0" ) ); pom.getDependencies().add( getDependency( "junit", "org.junit", "4.11" ) ); HashMap<Dependency, Set<String>> map = setUpDependencyService( pom ); map.put( getGAV( "drools-core", "org.drools", "6.3.0" ), toSet( "org.drools.a", "org.drools.b", "org.drools.c" ) ); map.put( getGAV( "junit", "org.junit", "4.11" ), toSet( "junit.a", "junit.b" ) ); Set<String> packageNames = packageNameSearchProvider.newTopLevelPackageNamesSearch( pom ).search(); assertEquals( 5, packageNames.size() ); assertTrue( packageNames.contains( "org.drools.a" ) ); assertTrue( packageNames.contains( "org.drools.b" ) ); assertTrue( packageNames.contains( "org.drools.c" ) ); assertTrue( packageNames.contains( "junit.a" ) ); assertTrue( packageNames.contains( "junit.b" ) ); }
@Test public void testLoadTopLevelDependenciesWhenIncompleteDependenciesInPOM() throws Exception { POM pom = new POM( new GAV( "artifactID", "groupID", "version" ) ); pom.getDependencies().add( getDependency( "drools-core", "org.drools", null ) ); pom.getDependencies().add( getDependency( null, null, null ) ); HashMap<Dependency, Set<String>> map = setUpDependencyService( pom ); map.put( getGAV( "drools-core", "org.drools", "6.3.0" ), toSet( "org.drools.a", "org.drools.b", "org.drools.c" ) ); Set<String> packageNames = packageNameSearchProvider.newTopLevelPackageNamesSearch( pom ).search(); assertEquals( 3, packageNames.size() ); assertTrue( packageNames.contains( "org.drools.a" ) ); assertTrue( packageNames.contains( "org.drools.b" ) ); assertTrue( packageNames.contains( "org.drools.c" ) ); }
|
SessionServiceImpl implements SessionService { @Override public KieSession newKieSession(KieModule project, String ksessionName) { final KieContainer kieContainer = getKieContainer(project); if (kieContainer == null) { return null; } return kieContainer.newKieSession(ksessionName); } SessionServiceImpl(); @Inject SessionServiceImpl(final BuildInfoService buildInfoService); @Override KieSession newKieSession(KieModule project, String ksessionName); @Override KieSession newDefaultKieSessionWithPseudoClock(final KieModule project); }
|
@Test public void newDefaultKieSession() { final KieSession kSession = mock(KieSession.class); doReturn(kSession).when(kieContainer).newKieSession(eq("ksessionName")); final KieSession resultKSession = sessionService.newKieSession(kieModule, "ksessionName"); verify(builder).build(); assertEquals(resultKSession, kSession); }
|
SessionServiceImpl implements SessionService { @Override public KieSession newDefaultKieSessionWithPseudoClock(final KieModule project) { final KieContainer kieContainer = getKieContainer(project); if (kieContainer == null) { return null; } final SessionConfiguration conf = SessionConfiguration.newInstance(); conf.setClockType(ClockType.PSEUDO_CLOCK); return kieContainer.getKieBase().newKieSession(conf, null); } SessionServiceImpl(); @Inject SessionServiceImpl(final BuildInfoService buildInfoService); @Override KieSession newKieSession(KieModule project, String ksessionName); @Override KieSession newDefaultKieSessionWithPseudoClock(final KieModule project); }
|
@Test public void newDefaultKieSessionWithPseudoClock() { final KieBase kBase = mock(KieBase.class); final KieSession kSession = mock(KieSession.class); doReturn(kBase).when(kieContainer).getKieBase(); doReturn(kSession).when(kBase).newKieSession(sessionConfigurationArgumentCaptor.capture(), eq(null)); final KieSession resultKSession = sessionService.newDefaultKieSessionWithPseudoClock(kieModule); final SessionConfiguration sessionConfiguration = sessionConfigurationArgumentCaptor.getValue(); verify(builder).build(); assertEquals(ClockType.PSEUDO_CLOCK, sessionConfiguration.getClockType()); assertEquals(resultKSession, kSession); }
@Test public void manageFailureToLoadABuilder() { when(buildInfoService.getBuildInfo(any())).thenReturn(null); assertThatThrownBy(() -> sessionService.newDefaultKieSessionWithPseudoClock(kieModule)) .isInstanceOf(IllegalStateException.class) .hasMessage("Failed to clone Builder."); }
|
KieService { public T loadContent(Path path) { try { final org.uberfire.java.nio.file.Path ioPath = Paths.convert(path); if (pathResolver.isDotFile(ioPath)) { org.uberfire.java.nio.file.Path ioPrincipleFilePath = pathResolver.resolveMainFilePath(ioPath); if (!ioService.exists(ioPrincipleFilePath)) { ioPrincipleFilePath = ioPath; } final Path principleFilePath = Paths.convert(ioPrincipleFilePath); return constructContent(principleFilePath, overviewLoader.loadOverview(principleFilePath)); } else { return constructContent(path, overviewLoader.loadOverview(path)); } } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } T loadContent(Path path); String getSource(final Path path); }
|
@Test public void testBasic() throws Exception { TestModel testModel = kieService.loadContent(Paths.convert(mainFilePath)); assertNotNull(testModel); assertMetadataRequestedForMainFile(); }
@Test public void testProjectName() throws Exception { final KieModule module = mock(KieModule.class); doReturn(module).when(moduleService).resolveModule(any(Path.class)); final WorkspaceProject project = mock(WorkspaceProject.class); doReturn("test name").when(project).getName(); doReturn(project).when(projectService).resolveProject(any(Path.class)); final TestModel testModel = kieService.loadContent(Paths.convert(mainFilePath)); assertEquals("test name", testModel.overview.getProjectName()); }
@Test public void testPathPointsToDotFile() throws Exception { TestModel testModel = kieService.loadContent(Paths.convert(dotFilePath)); assertNotNull(testModel); assertMetadataRequestedForMainFile(); }
@Test public void testPathPointsToOrphanDotFile() throws Exception { TestModel testModel = kieService.loadContent(Paths.convert(orphanDotFilePath)); assertNotNull(testModel); assertMetadataRequestedForOrphanFile(); }
|
AbstractInvalidateDMOPackageCacheDeleteHelper implements DeleteHelper { @Override public boolean supports( final Path path ) { return resourceType.accept( path ); } AbstractInvalidateDMOPackageCacheDeleteHelper( final T resourceType,
final Event<InvalidateDMOPackageCacheEvent> invalidateDMOPackageCache ); @Override boolean supports( final Path path ); @Override void postProcess( final Path path ); }
|
@Test public void checkMatchesResourceType() { final Path path = mock(Path.class); when(path.getFileName()).thenReturn("file." + resourceType.getSuffix()); assertTrue(helper.supports(path)); }
@Test public void checkDoesNotMatchOtherResourceTypes() { final Path path = mock(Path.class); when(path.getFileName()).thenReturn("file.smurf"); assertFalse(helper.supports(path)); }
|
AbstractInvalidateDMOPackageCacheDeleteHelper implements DeleteHelper { @Override public void postProcess( final Path path ) { if ( supports( path ) ) { invalidateDMOPackageCache.fire( new InvalidateDMOPackageCacheEvent( path ) ); } } AbstractInvalidateDMOPackageCacheDeleteHelper( final T resourceType,
final Event<InvalidateDMOPackageCacheEvent> invalidateDMOPackageCache ); @Override boolean supports( final Path path ); @Override void postProcess( final Path path ); }
|
@Test public void checkEventFiredWhenMatchesResourceType() { final Path path = mock(Path.class); when(path.getFileName()).thenReturn("file." + resourceType.getSuffix()); helper.postProcess(path); verify(invalidateDMOPackageCache, times(1)).fire(any(InvalidateDMOPackageCacheEvent.class)); }
@Test public void checkEventNotFiredWhenNotMatchOtherResourceTypes() { final Path path = mock(Path.class); when(path.getFileName()).thenReturn("file.smurf"); helper.postProcess(path); verify(invalidateDMOPackageCache, never()).fire(any(InvalidateDMOPackageCacheEvent.class)); }
|
KModuleServiceImpl implements KModuleService { @Override public Path setUpKModule(final Path path) { try { final org.uberfire.java.nio.file.Path pathToKModuleXML = Paths.convert(path); if (ioService.exists(pathToKModuleXML)) { throw new FileAlreadyExistsException(pathToKModuleXML.toString()); } else { ioService.write(pathToKModuleXML, moduleContentHandler.toString(new KModuleModel())); return Paths.convert(pathToKModuleXML); } } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } KModuleServiceImpl(); @Inject KModuleServiceImpl(final @Named("ioStrategy") IOService ioService,
final KieModuleService moduleService,
final MetadataService metadataService,
final KModuleContentHandler moduleContentHandler); @Override boolean isKModule(final Path resource); @Override Path setUpKModule(final Path path); @Override KModuleModel load(final Path path); @Override Path save(final Path path,
final KModuleModel content,
final Metadata metadata,
final String comment); }
|
@Test public void testSetUpProjectStructure() throws Exception { Path pathToProjectRoot = mock(Path.class); org.uberfire.java.nio.file.Path directory = setUpPathToProjectRoot(pathToProjectRoot); org.uberfire.java.nio.file.Path mainJava = mock(org.uberfire.java.nio.file.Path.class); setUpDirectory(directory, "src/main/java", mainJava); org.uberfire.java.nio.file.Path mainResources = mock(org.uberfire.java.nio.file.Path.class); setUpDirectory(directory, "src/main/resources", mainResources); org.uberfire.java.nio.file.Path testJava = mock(org.uberfire.java.nio.file.Path.class); setUpDirectory(directory, "src/test/java", testJava); org.uberfire.java.nio.file.Path testResources = mock(org.uberfire.java.nio.file.Path.class); setUpDirectory(directory, "src/test/resources", testResources); org.uberfire.java.nio.file.Path kmodule = mock(org.uberfire.java.nio.file.Path.class); setUpDirectory(directory, "src/main/resources/META-INF/kmodule.xml", kmodule); serviceImpl.setUpKModule(pathToProjectRoot); verify(ioService).write(eq(kmodule), anyString()); }
|
KModuleContentHandler { public String toString(KModuleModel model) { return createXStream().toXML(model); } KModuleModel toModel(String xml); String toString(KModuleModel model); }
|
@Test public void testMarshallingOfDefaultDroolsNameSpace() throws Exception { final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler(); final String kmodule = kModuleContentHandler.toString(new KModuleModel()); assertNotNull(kmodule); assertTrue(kmodule.contains("xmlns=\"http: }
|
SourceServicesImpl implements SourceServices { @Override public boolean hasServiceFor( final Path path ) { try { final SourceService sourceService = getMatchingSourceService( path ); return sourceService != null; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } } SourceServicesImpl(); @Inject SourceServicesImpl( @Any Instance<SourceService<?>> sourceServiceList ); @Override boolean hasServiceFor( final Path path ); @Override SourceService getServiceFor( final Path path ); }
|
@Test public void testSomethingSimple() throws Exception { addToList(getSourceService(".drl")); assertTrue(new SourceServicesImpl(instance).hasServiceFor(makePath("myFile", ".drl"))); }
@Test public void testMissing() throws Exception { addToList(getSourceService(".notHere")); assertFalse(new SourceServicesImpl(instance).hasServiceFor(makePath("myFile", ".drl"))); }
|
SourceServicesImpl implements SourceServices { @Override public SourceService getServiceFor( final Path path ) { try { final SourceService sourceService = getMatchingSourceService( path ); if ( sourceService == null ) { throw new IllegalArgumentException( "No SourceService found for '" + path + "'." ); } return sourceService; } catch ( Exception e ) { throw ExceptionUtilities.handleException( e ); } } SourceServicesImpl(); @Inject SourceServicesImpl( @Any Instance<SourceService<?>> sourceServiceList ); @Override boolean hasServiceFor( final Path path ); @Override SourceService getServiceFor( final Path path ); }
|
@Test public void testShorter() throws Exception { SourceService DRL = getSourceService(".drl"); SourceService modelDRL = getSourceService(".model.drl"); addToList(DRL, modelDRL); assertEquals(DRL, new SourceServicesImpl(instance).getServiceFor(makePath("myFile", ".drl"))); sourceServices.clear(); addToList(modelDRL, DRL); assertEquals(DRL, new SourceServicesImpl(instance).getServiceFor(makePath("myFile", ".drl"))); }
@Test public void testLonger() throws Exception { SourceService DRL = getSourceService(".drl"); SourceService modelDRL = getSourceService(".model.drl"); addToList(DRL, modelDRL); assertEquals(modelDRL, new SourceServicesImpl(instance).getServiceFor(makePath("myFile", ".model.drl"))); sourceServices.clear(); addToList(modelDRL, DRL); assertEquals(modelDRL, new SourceServicesImpl(instance).getServiceFor(makePath("myFile", ".model.drl"))); }
|
BuildInfoService { public BuildInfo getBuildInfo(final Module module) { final Builder[] result = {builderCache.getBuilder(module)}; if (result[0] == null || !result[0].isBuilt()) { ((BuildServiceImpl) buildService).build(module, builder -> result[0] = builder); } return new BuildInfoImpl(result[0]); } BuildInfoService(); @Inject BuildInfoService(BuildService buildService,
LRUBuilderCache builderCache); BuildInfo getBuildInfo(final Module module); }
|
@Test public void testGetBuildInfoWhenModuleIsBuilt() { when(cache.getBuilder(module)).thenReturn(builder); when(builder.isBuilt()).thenReturn(true); BuildInfo expectedBuildInfo = new BuildInfoImpl(builder); BuildInfo result = buildInfoService.getBuildInfo(module); assertEquals(expectedBuildInfo, result); verify(cache, times(1)).getBuilder(module); verify(buildService, never()).build(eq(module), any(Consumer.class)); }
|
BuildServiceHelper { public BuildResults localBuild(Module module) { final BuildResults[] result = new BuildResults[1]; invokeLocalBuildPipeLine(module, localBinaryConfig -> { result[0] = localBinaryConfig.getBuildResults(); }); return result[0]; } BuildServiceHelper(); @Inject BuildServiceHelper(BuildPipelineInvoker buildPipelineInvoker,
DeploymentVerifier deploymentVerifier); BuildResults localBuild(Module module); void localBuild(Module module,
Consumer<LocalBinaryConfig> consumer); IncrementalBuildResults localBuild(Module module,
LocalBuildConfig.BuildType buildType,
Path resource); IncrementalBuildResults localBuild(Module module,
Map<Path, Collection<ResourceChange>> resourceChanges); BuildResults localBuildAndDeploy(final Module module,
final DeploymentMode mode,
final boolean suppressHandlers); }
|
@Test public void testLocalBuild() { prepareLocalFullBuild(); when(localBinaryConfig.getBuildResults()).thenReturn(buildResults); BuildResults result = serviceHelper.localBuild(module); assertEquals(buildResults, result); verify(pipelineInvoker, times(1)).invokeLocalBuildPipeLine(eq(expectedRequest), any(Consumer.class)); }
|
BuildServiceHelper { public BuildResults localBuildAndDeploy(final Module module, final DeploymentMode mode, final boolean suppressHandlers) { final BuildResults[] result = new BuildResults[1]; invokeLocalBuildPipeLine(module, suppressHandlers, mode, localBinaryConfig -> { result[0] = localBinaryConfig.getBuildResults(); }); return result[0]; } BuildServiceHelper(); @Inject BuildServiceHelper(BuildPipelineInvoker buildPipelineInvoker,
DeploymentVerifier deploymentVerifier); BuildResults localBuild(Module module); void localBuild(Module module,
Consumer<LocalBinaryConfig> consumer); IncrementalBuildResults localBuild(Module module,
LocalBuildConfig.BuildType buildType,
Path resource); IncrementalBuildResults localBuild(Module module,
Map<Path, Collection<ResourceChange>> resourceChanges); BuildResults localBuildAndDeploy(final Module module,
final DeploymentMode mode,
final boolean suppressHandlers); }
|
@Test public void testLocalBuildAndDeployForced() { prepareBuildAndDeploy(module, LocalBuildConfig.DeploymentType.FORCED, false); BuildResults result = serviceHelper.localBuildAndDeploy(module, DeploymentMode.FORCED, false); verifyBuildAndDeploy(result); }
@Test public void testLocalBuildAndDeployValidated() { prepareBuildAndDeploy(module, LocalBuildConfig.DeploymentType.VALIDATED, false); BuildResults result = serviceHelper.localBuildAndDeploy(module, DeploymentMode.VALIDATED, false); verifyBuildAndDeploy(result); }
|
BuildServiceImpl implements BuildService { @Override public BuildResults build(final Module module) { return buildServiceHelper.localBuild(module); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testBuild() { when(buildServiceHelper.localBuild(module)).thenReturn(buildResults); BuildResults result = buildService.build(module); assertEquals(buildResults, result); }
@Test public void testBuildWithConsumer() { when(localBinaryConfig.getBuilder()).thenReturn(builder); doAnswer(new Answer<Void>() { public Void answer(InvocationOnMock invocation) { Consumer consumer = (Consumer) invocation.getArguments()[1]; consumer.accept(localBinaryConfig); return null; } }).when(buildServiceHelper).localBuild(eq(module), any(Consumer.class)); buildService.build(module, new Consumer<Builder>() { @Override public void accept(Builder result) { assertEquals(builder, result); } }); verify(buildServiceHelper, times(1)).localBuild(eq(module), any(Consumer.class)); }
|
BuildServiceImpl implements BuildService { @Override public boolean isBuilt(final Module module) { final Builder builder = cache.assertBuilder(module); return builder.isBuilt(); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testIsBuiltTrue() { when(cache.assertBuilder(module)).thenReturn(builder); when(builder.isBuilt()).thenReturn(true); assertTrue(buildService.isBuilt(module)); }
@Test public void testIsBuiltFalse() { when(cache.assertBuilder(module)).thenReturn(builder); when(builder.isBuilt()).thenReturn(false); assertFalse(buildService.isBuilt(module)); }
|
BuildServiceImpl implements BuildService { @Override public BuildResults buildAndDeploy(final Module module) { return buildAndDeploy(module, DeploymentMode.VALIDATED); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testBuildAndDeploy() { prepareBuildAndDeploy(module, DeploymentMode.VALIDATED, false); BuildResults result = buildService.buildAndDeploy(module); assertEquals(buildResults, result); verifyBuildAndDeploy(module, DeploymentMode.VALIDATED, false); }
@Test public void testBuildAndDeployWithDeploymentMode() { prepareBuildAndDeploy(module, DeploymentMode.VALIDATED, false); BuildResults result = buildService.buildAndDeploy(module, DeploymentMode.VALIDATED); assertEquals(buildResults, result); verifyBuildAndDeploy(module, DeploymentMode.VALIDATED, false); }
@Test public void testBuildAndDeployWithSuppressHandlers() { prepareBuildAndDeploy(module, DeploymentMode.VALIDATED, false); BuildResults result = buildService.buildAndDeploy(module, false); assertEquals(buildResults, result); verifyBuildAndDeploy(module, DeploymentMode.VALIDATED, false); }
@Test public void testBuildAndDeployWithDeploymentModeAndSuppressHandlers() { prepareBuildAndDeploy(module, DeploymentMode.VALIDATED, false); BuildResults result = buildService.buildAndDeploy(module, false, DeploymentMode.VALIDATED); assertEquals(buildResults, result); verifyBuildAndDeploy(module, DeploymentMode.VALIDATED, false); }
|
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata, final List<JSITImport> imports) { if (!imports.isEmpty()) { return loadPMMLDefinitions().then(otherDefinitions -> { final Map<JSITImport, PMMLDocumentMetadata> importDefinitions = new HashMap<>(); for (final Map.Entry<String, PMMLDocumentMetadata> entry : otherDefinitions.entrySet()) { final PMMLDocumentMetadata def = entry.getValue(); findImportByPMMLDocument(FileUtils.getFileName(def.getPath()), imports).ifPresent(anImport -> { final JSITImport foundImported = Js.uncheckedCast(anImport); importDefinitions.put(foundImported, def); }); } return promises.resolve(importDefinitions); }); } return promises.resolve(Collections.emptyMap()); } @Inject DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
final DMNMarshallerImportsContentService dmnImportsContentService,
final Promises promises,
final DMNIncludedNodeFactory includedModelFactory); Promise<Map<JSITImport, JSITDefinitions>> getImportDefinitionsAsync(final Metadata metadata,
final List<JSITImport> imports); void loadNodesFromModels(final List<DMNIncludedModel> includedModels,
final ServiceCallback<List<DMNIncludedNode>> callback); void loadModels(final ServiceCallback<List<IncludedModel>> callback); Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata,
final List<JSITImport> imports); @Override Map<JSITImport, String> getImportXML(final Metadata metadata,
final List<JSITImport> imports); @Override List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions); @Override List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions); void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels,
final ServiceCallback<List<PMMLDocumentMetadata>> callback); void getImportedItemDefinitionsByNamespaceAsync(final String modelName,
final String namespace,
final ServiceCallback<List<ItemDefinition>> callback); }
|
@Test public void getPMMLDocumentsAsyncWhenModelDoesNotHaveImports() { final Promise<Map<JSITImport, PMMLDocumentMetadata>> returnPromise = importsHelper.getPMMLDocumentsAsync(metadataMock, Collections.emptyList()); returnPromise.then(p0 -> { assertEquals(0, p0.size()); return promises.resolve(); }).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); }
@Test public void getPMMLDocumentsAsyncWhenAnyFileCouldBeRead() { when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[0])); final Promise<Map<JSITImport, PMMLDocumentMetadata>> returnPromise = importsHelper.getPMMLDocumentsAsync(metadataMock, singletonList(mock(JSITImport.class))); returnPromise.then(p0 -> { assertEquals(0, p0.size()); return promises.resolve(); }).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); }
@Test public void getPMMLDocumentsAsync() { final PMMLDocumentMetadata pmmlDocumentMetadata = new PMMLDocumentMetadata(PMML_PATH, PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList()); when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[]{PMML_PATH})); when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT)); doReturn(promises.resolve(pmmlDocumentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH); final List<JSITImport> imports = new ArrayList<>(); final JSITImport jsImportMock = mock(JSITImport.class); when(jsImportMock.getLocationURI()).thenReturn(PMML_FILE); imports.add(jsImportMock); final Promise<Map<JSITImport, PMMLDocumentMetadata>> returnPromise = importsHelper.getPMMLDocumentsAsync(metadataMock, imports); returnPromise.then(def -> { assertEquals(1, def.size()); assertEquals(PMML_PATH, def.get(jsImportMock).getPath()); assertEquals(PMML_FILE, def.get(jsImportMock).getName()); assertEquals(PMML.getDefaultNamespace(), def.get(jsImportMock).getImportType()); assertEquals(0, def.get(jsImportMock).getModels().size()); return promises.resolve(); }).catch_(i -> { fail("Promise should've been resolved!"); return promises.resolve(); }); }
|
BuildServiceImpl implements BuildService { @Override public IncrementalBuildResults addPackageResource(final Path resource) { return buildIncrementally(resource, LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testAddPackageResource() { prepareIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); IncrementalBuildResults result = buildService.addPackageResource(path); assertEquals(incrementalBuildResults, result); verifyIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); }
|
BuildServiceImpl implements BuildService { @Override public IncrementalBuildResults deletePackageResource(final Path resource) { return buildIncrementally(resource, LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testDeletePackageResource() { prepareIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); IncrementalBuildResults result = buildService.deletePackageResource(path); assertEquals(incrementalBuildResults, result); verifyIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); }
|
BuildServiceImpl implements BuildService { @Override public IncrementalBuildResults updatePackageResource(final Path resource) { return buildIncrementally(resource, LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testUpdatePackageResource() { prepareIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); IncrementalBuildResults result = buildService.updatePackageResource(path); assertEquals(incrementalBuildResults, result); verifyIncrementalBuild(path, LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); }
|
BuildServiceImpl implements BuildService { @Override public IncrementalBuildResults applyBatchResourceChanges(final Module module, final Map<Path, Collection<ResourceChange>> changes) { if (module == null) { return new IncrementalBuildResults(); } return buildServiceHelper.localBuild(module, changes); } BuildServiceImpl(); @Inject BuildServiceImpl(final KieModuleService moduleService,
final BuildServiceHelper buildServiceHelper,
final LRUBuilderCache cache); @Override BuildResults build(final Module module); void build(final Module module,
final Consumer<Builder> consumer); @Override BuildResults buildAndDeploy(final Module module); @Override BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); @Override BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); @Override boolean isBuilt(final Module module); @Override IncrementalBuildResults addPackageResource(final Path resource); @Override IncrementalBuildResults deletePackageResource(final Path resource); @Override IncrementalBuildResults updatePackageResource(final Path resource); @Override IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); }
|
@Test public void testApplyBatchResourceChanges() { when(buildServiceHelper.localBuild(module, resourceChanges)).thenReturn(incrementalBuildResults); IncrementalBuildResults result = buildService.applyBatchResourceChanges(module, resourceChanges); assertEquals(incrementalBuildResults, result); verify(buildServiceHelper, times(1)).localBuild(module, resourceChanges); }
|
ClassVerifier { private void verifyClass(final String packageName, final String className) { try { final Class clazz = kieModuleMetaData.getClass(packageName, className); if (clazz != null) { if (TypeSource.JAVA_DEPENDENCY == typeSourceResolver.getTypeSource(clazz)) { verifyExternalClass(clazz); } } else { logger.warn(MessageFormat.format(ERROR_EXTERNAL_CLASS_VERIFICATION, toFQCN(packageName, className))); } } catch (Throwable e) { final String msg = MessageFormat.format(ERROR_EXTERNAL_CLASS_VERIFICATION, toFQCN(packageName, className), e.getMessage()); logger.warn(msg); logger.debug("This state is usually encountered when the Project references a class not on the classpath; e.g. in a Maven 'provided' scope or 'optional' dependency.", e); buildMessages.add(makeWarningMessage(msg)); } } ClassVerifier(final KieModuleMetaData kieModuleMetaData,
final TypeSourceResolver typeSourceResolver); List<BuildMessage> verify(WhiteList whiteList); }
|
@Test public void testVerifyClass(){ WhiteList whiteList = new WhiteList(); whiteList.add("org.kie.workbench.common.services.backend.builder"); ClassVerifier classVerifier = new ClassVerifier(kieModuleMetaData, typeSourceResolver); List<BuildMessage> messages = classVerifier.verify(whiteList); assertEquals(messages.size(), 1); assertEquals("Verification of class org.kie.workbench.common.services.backend.builder.SomeClass failed and will not be available for authoring.\n" + "Underlying system error is: The access to the class is not allowed. Please check the necessary external dependencies for this project are configured correctly.", messages.get(0).getText()); }
|
ObservableProjectImportsFile implements ResourceChangeObservableFile { @Override public boolean accept(final Path path) { final String fileName = path.getFileName(); return fileName.equals(FILENAME); } @Override boolean accept(final Path path); }
|
@Test public void testAcceptWithoutProjectImportsFile() { doReturn("Cheese.txt").when(path).getFileName(); assertFalse(observer.accept(path)); }
@Test public void testAcceptWithProjectImportsFile() { doReturn(ObservableProjectImportsFile.FILENAME).when(path).getFileName(); assertTrue(observer.accept(path)); }
|
ObservableKModuleFile implements ResourceChangeObservableFile { @Override public boolean accept(final Path path) { final String fileName = path.getFileName(); return fileName.equals(FILENAME); } @Override boolean accept(final Path path); }
|
@Test public void testAcceptWithoutKModuleFile() { doReturn("Cheese.txt").when(path).getFileName(); assertFalse(observer.accept(path)); }
@Test public void testAcceptWithKModuleFile() { doReturn(ObservableKModuleFile.FILENAME).when(path).getFileName(); assertTrue(observer.accept(path)); }
|
LRUBuilderCache extends LRUCache<Module, Builder> { protected static String validateCacheSize(final String value) { if (value == null || value.length() == 0 || !value.matches("^[0-9]*$")) { logger.error("Illeagal Argument : Property {} should be a positive integer", BUILDER_CACHE_SIZE); return DEFAULT_BUILDER_CACHE_SIZE; } return value; } LRUBuilderCache(); @Inject LRUBuilderCache(final @Named("ioStrategy") IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final @Any Instance<BuildValidationHelper> buildValidationHelperBeans,
final @Named("LRUModuleDependenciesClassLoaderCache") LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final @Named("LRUPomModelCache") LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final @JavaSourceFilter Instance<Predicate<String>> classFilterBeans); @PostConstruct void loadInstances(); @PreDestroy void destroyInstances(); void invalidateProjectCache(@Observes final InvalidateDMOModuleCacheEvent event); Builder assertBuilder(POM pom); Builder assertBuilder(final Module module); Builder getBuilder(final Module module); }
|
@Test public void testValidateCacheSize() { assertEquals(LRUBuilderCache.validateCacheSize("10"), "10"); assertEquals(LRUBuilderCache.validateCacheSize("-10"), LRUBuilderCache.DEFAULT_BUILDER_CACHE_SIZE); assertEquals(LRUBuilderCache.validateCacheSize(""), LRUBuilderCache.DEFAULT_BUILDER_CACHE_SIZE); assertEquals(LRUBuilderCache.validateCacheSize("ab"), LRUBuilderCache.DEFAULT_BUILDER_CACHE_SIZE); assertEquals(LRUBuilderCache.validateCacheSize(null), LRUBuilderCache.DEFAULT_BUILDER_CACHE_SIZE); }
|
BuildHelper { public BuildResults buildAndDeploy(final Module module) { return buildAndDeploy(module, DeploymentMode.VALIDATED); } BuildHelper(); @Inject BuildHelper(final POMService pomService,
final ExtendedM2RepoService m2RepoService,
final KieModuleService moduleService,
final DeploymentVerifier deploymentVerifier,
final LRUBuilderCache cache,
final Instance<PostBuildHandler> handlers,
final Instance<User> identity); BuildResult build(final Module module); IncrementalBuildResults addPackageResource(final Path resource); IncrementalBuildResults deletePackageResource(final Path resource); IncrementalBuildResults updatePackageResource(final Path resource); IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); BuildResults buildExceptionResults(Exception e,
GAV gav); BuildResults buildAndDeploy(final Module module); BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); }
|
@Test public void testBuildAndDeployNonSnapshotNotDeployed() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav, false); buildHelper.buildAndDeploy(module); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploy(module, gav); }
@Test public void testBuildAndDeployNonSnapshotAlreadyDeployed() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav, true); Exception exception = null; try { buildHelper.buildAndDeploy(module); } catch (Exception e) { exception = e; } verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); assertNotNull(exception); assertTrue(exception instanceof GAVAlreadyExistsException); assertEquals(gav, ((GAVAlreadyExistsException) exception).getGAV()); }
@Test public void testBuildAndDeploySnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, SNAPSHOT_VERSION); prepareBuildAndDeploy(snapshotRootPath, gav); buildHelper.buildAndDeploy(module); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploySnapshot(module, gav); }
@Test public void testBuildAndDeploySuppressHandlersNonSnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav); buildHelper.buildAndDeploy(module, true); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(true), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploy(module, gav); }
@Test public void testBuildAndDeploySuppressHandlersSnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, SNAPSHOT_VERSION); prepareBuildAndDeploy(snapshotRootPath, gav); buildHelper.buildAndDeploy(module, true); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(true), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploySnapshot(module, gav); }
|
BuildHelper { public BuildResult build(final Module module) { try { cache.invalidateCache(module); Builder builder = cache.assertBuilder(module); final BuildResults results = builder.build(); BuildMessage infoMsg = new BuildMessage(); infoMsg.setLevel(Level.INFO); infoMsg.setText(buildResultMessage(module, results).toString()); results.addBuildMessage(0, infoMsg); return new BuildResult(builder, results); } catch (Exception e) { logger.error(e.getMessage(), e); return new BuildResult(null, buildExceptionResults(e, module.getPom().getGav())); } } BuildHelper(); @Inject BuildHelper(final POMService pomService,
final ExtendedM2RepoService m2RepoService,
final KieModuleService moduleService,
final DeploymentVerifier deploymentVerifier,
final LRUBuilderCache cache,
final Instance<PostBuildHandler> handlers,
final Instance<User> identity); BuildResult build(final Module module); IncrementalBuildResults addPackageResource(final Path resource); IncrementalBuildResults deletePackageResource(final Path resource); IncrementalBuildResults updatePackageResource(final Path resource); IncrementalBuildResults applyBatchResourceChanges(final Module module,
final Map<Path, Collection<ResourceChange>> changes); BuildResults buildExceptionResults(Exception e,
GAV gav); BuildResults buildAndDeploy(final Module module); BuildResults buildAndDeploy(final Module module,
final DeploymentMode mode); BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers); BuildResults buildAndDeploy(final Module module,
final boolean suppressHandlers,
final DeploymentMode mode); }
|
@Test public void testBuildThatDoesNotUpdateTheCache() throws Exception { final Path path = path(); buildHelper.build(moduleService.resolveModule(path)); assertTrue(cachedFileSystemDoesNotChange()); }
|
Builder implements Serializable { public KieContainer getKieContainer() { BuildResults results = null; if (!isBuilt()) { results = build(); } else { results = new BuildResults(); results.addAllBuildMessages(convertMessages(kieBuilder.getResults().getMessages(), handles)); } if (results.getErrorMessages().isEmpty()) { final org.kie.api.builder.KieModule kieModule = kieBuilder.getKieModule(); final ReleaseId releaseId = kieModule.getReleaseId(); final org.drools.compiler.kie.builder.impl.KieProject kieProject = new KieModuleKieProject((InternalKieModule) kieBuilder.getKieModule(), null); final KieContainer kieContainer = new KieContainerImpl(kieProject, KieServices.Factory.get().getRepository(), releaseId); return kieContainer; } else { return null; } } Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter,
final KieBuilder kieBuilder,
final KieFileSystem kieFileSystem); Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter); Builder clone(); BuildResults build(); BuildResults build(final Path resource,
final InputStream inputStream); IncrementalBuildResults addResource(final Path resource); IncrementalBuildResults deleteResource(final Path resource); IncrementalBuildResults updateResource(final Path resource); IncrementalBuildResults updateResource(final Path resource,
final InputStream inputStream); IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes); org.kie.api.builder.KieModule getKieModule(); org.kie.api.builder.KieModule getKieModuleIgnoringErrors(); KieModuleMetaData getKieModuleMetaDataIgnoringErrors(); TypeSourceResolver getTypeSourceResolver(KieModuleMetaData kieModuleMetaData); KieContainer getKieContainer(); boolean isBuilt(); }
|
@Test public void testBuilderSimpleKModule() throws Exception { LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class); URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample1"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); assertNotNull(builder.getKieContainer()); }
@Test public void testBuilderKieContainerInstantiation() throws Exception { final URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample1"); final SimpleFileSystemProvider p = new SimpleFileSystemProvider(); final org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); assertNotNull(builder.getKieContainer()); final URL urlToValidate = this.getClass().getResource("/GuvnorM2RepoDependencyExample1/src/main/resources/rule2.drl"); final org.uberfire.java.nio.file.Path pathToValidate = p.getPath(urlToValidate.toURI()); final List<ValidationMessage> validationMessages = validator.validate(Paths.convert(pathToValidate), Resources.toString(urlToValidate, Charset.forName("UTF-8"))); assertNotNull(validationMessages); assertEquals(0, validationMessages.size()); final KieContainer kieContainer1 = builder.getKieContainer(); final KieSession kieSession1 = kieContainer1.newKieSession(); kieSession1.setGlobal("list", new ArrayList<String>()); }
|
Builder implements Serializable { public BuildResults build() { final BuildResults results = new BuildResults(projectGAV); synchronized (kieFileSystem) { kieBuilder = createKieBuilder(kieFileSystem); try { final Results kieResults = ((InternalKieBuilder) kieBuilder).buildAll(classFilter).getResults(); results.addAllBuildMessages(convertMessages(kieResults.getMessages(), handles)); } catch (LinkageError e) { final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, e.getLocalizedMessage()); logger.warn(msg); results.addBuildMessage(makeWarningMessage(msg)); } catch (Throwable e) { final String msg = e.getLocalizedMessage(); logger.error(msg, e); results.addBuildMessage(makeErrorMessage(msg)); } finally { final PomModel pomModel = ((KieBuilderImpl) kieBuilder).getPomModel(); if (pomModel != null) { pomModelCache.setEntry(project, pomModel); } } } for (Map.Entry<Path, BuildValidationHelper> e : nonKieResourceValidationHelpers.entrySet()) { final org.uberfire.backend.vfs.Path vfsPath = Paths.convert(e.getKey()); final List<ValidationMessage> validationMessages = e.getValue().validate(vfsPath); nonKieResourceValidationHelperMessages.put(e.getKey(), validationMessages); results.addAllBuildMessages(convertValidationMessages(validationMessages)); } final Path nioExternalImportsPath = projectRoot.resolve("project.imports"); if (Files.exists(nioExternalImportsPath)) { final org.uberfire.backend.vfs.Path externalImportsPath = Paths.convert(nioExternalImportsPath); final ProjectImports projectImports = importsService.load(externalImportsPath); final Imports imports = projectImports.getImports(); for (final Import item : imports.getImports()) { final String fullyQualifiedClassName = item.getType(); try { Class clazz = this.getClass().getClassLoader().loadClass(item.getType()); } catch (ClassNotFoundException cnfe) { logger.warn(cnfe.getMessage()); final String msg = MessageFormat.format(ERROR_CLASS_NOT_FOUND, fullyQualifiedClassName); results.addBuildMessage(makeWarningMessage(msg)); } } } final KieModuleMetaData kieModuleMetaData = KieModuleMetaData.Factory.newKieModuleMetaData(getKieModuleIgnoringErrors(), DependencyFilter.COMPILE_FILTER); updateDependenciesClassLoader(project, kieModuleMetaData); results.addAllBuildMessages(verifyClasses(kieModuleMetaData)); return results; } Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter,
final KieBuilder kieBuilder,
final KieFileSystem kieFileSystem); Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter); Builder clone(); BuildResults build(); BuildResults build(final Path resource,
final InputStream inputStream); IncrementalBuildResults addResource(final Path resource); IncrementalBuildResults deleteResource(final Path resource); IncrementalBuildResults updateResource(final Path resource); IncrementalBuildResults updateResource(final Path resource,
final InputStream inputStream); IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes); org.kie.api.builder.KieModule getKieModule(); org.kie.api.builder.KieModule getKieModuleIgnoringErrors(); KieModuleMetaData getKieModuleMetaDataIgnoringErrors(); TypeSourceResolver getTypeSourceResolver(KieModuleMetaData kieModuleMetaData); KieContainer getKieContainer(); boolean isBuilt(); }
|
@Test public void testBuilderKModuleHasDependency() throws Exception { URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); final BuildResults results = builder.build(); if (!results.getMessages().isEmpty()) { for (BuildMessage m : results.getMessages()) { logger.debug(m.getText()); } } assertTrue(results.getMessages().isEmpty()); }
@Test public void testBuilderKModuleHasSnapshotDependency() throws Exception { M2ServletContextListener context = new M2ServletContextListener(); GAV gav = new GAV("org.kie.workbench.common.services.builder.tests", "dependency-test1-snapshot", "1.0-SNAPSHOT"); URL urlJar = this.getClass().getResource("/dependency-test1-snapshot-1.0-SNAPSHOT.jar"); context.deploy(gav, urlJar.getPath()); URL url = this.getClass().getResource("/GuvnorM2RepoDependencyExample2Snapshot"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); final BuildResults results = builder.build(); if (!results.getMessages().isEmpty()) { for (BuildMessage m : results.getMessages()) { logger.debug(m.getText()); } } assertTrue(results.getMessages().isEmpty()); }
@Test public void testKModuleContainsXLS() throws Exception { URL url = this.getClass().getResource("/ExampleWithExcel"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); final BuildResults results = builder.build(); if (!results.getMessages().isEmpty()) { for (BuildMessage m : results.getMessages()) { logger.debug(m.getText()); } } assertTrue(results.getMessages().isEmpty()); }
@Test public void buildDetectsFilesWithSpecialCharacters() throws Exception { LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class); URL url = this.getClass().getResource("/ModuleBuildTestFileWithSpecialCharacter"); SimpleFileSystemProvider p = new SimpleFileSystemProvider(); org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); BuildResults buildResults = builder.build(); List<BuildMessage> errorMessages = buildResults.getErrorMessages(); assertEquals(2, errorMessages.size()); assertTrue(errorMessages.get(0).getText().contains("mismatched input 'Build' expecting one of the following tokens:")); }
@Test public void testBuildProjectWithDmn() throws Exception { final LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class); final URL url = this.getClass().getResource("/ProjectWithDmn"); final SimpleFileSystemProvider p = new SimpleFileSystemProvider(); final org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); final BuildResults buildResults = builder.build(); final List<BuildMessage> errorMessages = buildResults.getErrorMessages(); assertEquals(1, errorMessages.size()); assertTrue(errorMessages.get(0).getText().contains("Error compiling FEEL expression")); }
|
Builder implements Serializable { public IncrementalBuildResults addResource(final Path resource) { IncrementalBuildResults results = new IncrementalBuildResults(projectGAV); if (ioService.exists(resource)) { results = addResource(resource, ioService.newInputStream(resource)); } return results; } Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter,
final KieBuilder kieBuilder,
final KieFileSystem kieFileSystem); Builder(final Module project,
final IOService ioService,
final KieModuleService moduleService,
final ProjectImportsService importsService,
final List<BuildValidationHelper> buildValidationHelpers,
final LRUModuleDependenciesClassLoaderCache dependenciesClassLoaderCache,
final LRUPomModelCache pomModelCache,
final PackageNameWhiteListService packageNameWhiteListService,
final Predicate<String> classFilter); Builder clone(); BuildResults build(); BuildResults build(final Path resource,
final InputStream inputStream); IncrementalBuildResults addResource(final Path resource); IncrementalBuildResults deleteResource(final Path resource); IncrementalBuildResults updateResource(final Path resource); IncrementalBuildResults updateResource(final Path resource,
final InputStream inputStream); IncrementalBuildResults applyBatchResourceChanges(final Map<org.uberfire.backend.vfs.Path, Collection<ResourceChange>> changes); org.kie.api.builder.KieModule getKieModule(); org.kie.api.builder.KieModule getKieModuleIgnoringErrors(); KieModuleMetaData getKieModuleMetaDataIgnoringErrors(); TypeSourceResolver getTypeSourceResolver(KieModuleMetaData kieModuleMetaData); KieContainer getKieContainer(); boolean isBuilt(); }
|
@Test public void testIncrementalBuildWithNoFile() throws Exception { final LRUPomModelCache pomModelCache = getReference(LRUPomModelCache.class); final URL url = this.getClass().getResource("/BuildHelperTest"); final SimpleFileSystemProvider p = new SimpleFileSystemProvider(); final org.uberfire.java.nio.file.Path path = p.getPath(url.toURI()); final Module module = moduleService.resolveModule(Paths.convert(path)); final Builder builder = new Builder(module, ioService, moduleService, importsService, new ArrayList<>(), dependenciesClassLoaderCache, pomModelCache, getPackageNameWhiteListService(), alwaysTrue); IncrementalBuildResults buildResults = builder.addResource(Paths.convert(noFilePath)); List<BuildMessage> addedMessages = buildResults.getAddedMessages(); assertEquals(0, addedMessages.size()); }
|
ObservablePackageNamesWhiteListFile implements ResourceChangeObservableFile { @Override public boolean accept(final Path path) { final String fileName = path.getFileName(); return fileName.equals(FILENAME); } @Override boolean accept(final Path path); }
|
@Test public void testAcceptWithoutPNWLFile() { doReturn("Cheese.txt").when(path).getFileName(); assertFalse(observer.accept(path)); }
@Test public void testAcceptWithPNWLFile() { doReturn(ObservablePackageNamesWhiteListFile.FILENAME).when(path).getFileName(); assertTrue(observer.accept(path)); }
|
DeploymentVerifier { public void verifyWithException(final Module module, DeploymentMode deploymentMode) { if (DeploymentMode.VALIDATED.equals(deploymentMode)) { final GAV gav = module.getPom().getGav(); if (gav.isSnapshot()) { return; } final ModuleRepositories projectRepositories = moduleRepositoriesService.load(((KieModule) module).getRepositoriesPath()); final Set<MavenRepositoryMetadata> repositories = repositoryResolver.getRepositoriesResolvingArtifact(gav, module, projectRepositories.filterByIncluded()); if (repositories.size() > 0) { throw new GAVAlreadyExistsException(gav, repositories); } } } DeploymentVerifier(); @Inject DeploymentVerifier(final ModuleRepositoryResolver repositoryResolver,
final ModuleRepositoriesService moduleRepositoriesService); void verifyWithException(final Module module,
DeploymentMode deploymentMode); }
|
@Test public void testVerifyAlreadyDeployedValidatedNonSNAPSHOT() { prepareProjectIsDeployed(true); when(gav.isSnapshot()).thenReturn(false); try { deploymentVerifier.verifyWithException(module, DeploymentMode.VALIDATED); } catch (Exception e) { exception = e; } assertNotNull(exception); assertTrue(exception instanceof GAVAlreadyExistsException); assertEquals(gav, ((GAVAlreadyExistsException) exception).getGAV()); assertEquals(repositories, ((GAVAlreadyExistsException) exception).getRepositories()); }
|
LRUPomModelCache extends LRUCache<Module, PomModel> { public void invalidateProjectCache(@Observes final InvalidateDMOModuleCacheEvent event) { PortablePreconditions.checkNotNull("event", event); final Path resourcePath = event.getResourcePath(); final KieModule module = moduleService.resolveModule(resourcePath); if (module != null) { invalidateCache(module); } } LRUPomModelCache(); @Inject LRUPomModelCache(final KieModuleService moduleService); void invalidateProjectCache(@Observes final InvalidateDMOModuleCacheEvent event); }
|
@Test public void testCacheIsInvalidatedWhenResourceThatMapsToProject() { final InvalidateDMOModuleCacheEvent event = new InvalidateDMOModuleCacheEvent(sessionInfo, module, resourcePath); doReturn(module).when(moduleService).resolveModule(resourcePath); cache.invalidateProjectCache(event); verify(cache).invalidateCache(eq(module)); verify(cache, never()).invalidateCache(eq(otherModule)); }
|
ObservableDRLFile implements ResourceChangeObservableFile { @Override public boolean accept(final Path path) { try { final String fileName = path.getFileName(); if (!fileName.endsWith("." + EXTENSION)) { return false; } final String drl = ioService.readAllString(convert(path)); return PATTERN.matcher(drl.toLowerCase()).matches(); } catch (NoSuchFileException e) { return false; } } ObservableDRLFile(); @Inject ObservableDRLFile(final @Named("ioStrategy") IOService ioService); @Override boolean accept(final Path path); }
|
@Test public void testAcceptWithoutDRLFile() { doReturn("cheese.txt").when(path).getFileName(); assertFalse(observer.accept(path)); }
@Test public void testAcceptWithDRLFileDeclaringTypeSingleLine() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("declare MyType end").when(ioService).readAllString(eq(nioPath)); assertTrue(observer.accept(path)); }
@Test public void testAcceptWithDRLFileDeclaringTypeMultipleLines() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("declare MyType\nend").when(ioService).readAllString(eq(nioPath)); assertTrue(observer.accept(path)); }
@Test public void testAcceptWithDRLFileDeclaringTypeMidFile() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("MyType declaration \ndeclare MyType\nend").when(ioService).readAllString(eq(nioPath)); assertTrue(observer.accept(path)); }
@Test public void testAcceptWithDRLFileNotDeclaringType() { doReturn("cheese." + ObservableDRLFile.EXTENSION).when(path).getFileName(); doReturn("rule test when then end").when(ioService).readAllString(eq(nioPath)); assertFalse(observer.accept(path)); }
@Test public void testAcceptWithNoSuchFileException() { doThrow(new NoSuchFileException()).when(path).getFileName(); assertFalse(observer.accept(path)); }
|
DMNMarshallerImportsClientHelper implements DMNMarshallerImportsHelper<JSITImport, JSITDefinitions, JSITDRGElement, JSITItemDefinition> { public void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels, final ServiceCallback<List<PMMLDocumentMetadata>> callback) { if (includedModels == null || includedModels.isEmpty()) { callback.onSuccess(Collections.emptyList()); return; } loadPMMLDefinitions().then(allDefinitions -> { final Map<String, String> filesToNameMap = includedModels.stream().collect(Collectors.toMap(PMMLIncludedModel::getPath, PMMLIncludedModel::getModelName)); final List<PMMLDocumentMetadata> pmmlDocumentMetadata = allDefinitions.entrySet().stream() .filter(entry -> filesToNameMap.keySet().contains(FileUtils.getFileName(entry.getKey()))) .map(entry -> new PMMLDocumentMetadata(entry.getValue().getPath(), filesToNameMap.get(FileUtils.getFileName(entry.getKey())), entry.getValue().getImportType(), entry.getValue().getModels())) .collect(Collectors.toList()); pmmlDocumentMetadata.sort(Comparator.comparing(PMMLDocumentMetadata::getName)); callback.onSuccess(pmmlDocumentMetadata); return promises.resolve(); }); } @Inject DMNMarshallerImportsClientHelper(final DMNMarshallerImportsService dmnImportsService,
final DMNMarshallerImportsContentService dmnImportsContentService,
final Promises promises,
final DMNIncludedNodeFactory includedModelFactory); Promise<Map<JSITImport, JSITDefinitions>> getImportDefinitionsAsync(final Metadata metadata,
final List<JSITImport> imports); void loadNodesFromModels(final List<DMNIncludedModel> includedModels,
final ServiceCallback<List<DMNIncludedNode>> callback); void loadModels(final ServiceCallback<List<IncludedModel>> callback); Promise<Map<JSITImport, PMMLDocumentMetadata>> getPMMLDocumentsAsync(final Metadata metadata,
final List<JSITImport> imports); @Override Map<JSITImport, String> getImportXML(final Metadata metadata,
final List<JSITImport> imports); @Override List<JSITDRGElement> getImportedDRGElements(final Map<JSITImport, JSITDefinitions> importDefinitions); @Override List<JSITItemDefinition> getImportedItemDefinitions(final Map<JSITImport, JSITDefinitions> importDefinitions); void getPMMLDocumentsMetadataFromFiles(final List<PMMLIncludedModel> includedModels,
final ServiceCallback<List<PMMLDocumentMetadata>> callback); void getImportedItemDefinitionsByNamespaceAsync(final String modelName,
final String namespace,
final ServiceCallback<List<ItemDefinition>> callback); }
|
@Test public void getPMMLDocumentsMetadataFromFilesEmptyFiles() { importsHelper.getPMMLDocumentsMetadataFromFiles(Collections.emptyList(), pmmlMetadataServiceCallback); importsHelper.getPMMLDocumentsMetadataFromFiles(null, pmmlMetadataServiceCallback); verify(pmmlMetadataServiceCallback, times(2)).onSuccess(eq(Collections.emptyList())); }
@Test public void getPMMLDocumentsMetadataFromFiles() { final PMMLDocumentMetadata documentMetadata = new PMMLDocumentMetadata(PMML_FILE, PMML.getDefaultNamespace(), Collections.emptyList()); final List<PMMLIncludedModel> includedModels = Arrays.asList(new PMMLIncludedModel(PMML_MODEL_NAME, "", PMML_FILE, PMML.getDefaultNamespace(), 0)); when(dmnImportsContentService.getModelsPMMLFilesURIs()).thenReturn(promises.resolve(new String[]{PMML_PATH})); when(dmnImportsContentService.loadFile(PMML_PATH)).thenReturn(promises.resolve(PMML_CONTENT)); doReturn(promises.resolve(documentMetadata)).when(dmnImportsContentService).getPMMLDocumentMetadata(PMML_PATH); importsHelper.getPMMLDocumentsMetadataFromFiles(includedModels, pmmlMetadataServiceCallback); verify(pmmlMetadataServiceCallback, times(1)).onSuccess(pmmlDocumentMetadataArgumentCaptor.capture()); assertEquals(1, pmmlDocumentMetadataArgumentCaptor.getValue().size()); assertEquals(PMML_FILE, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getPath()); assertEquals(PMML_MODEL_NAME, pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getName()); assertEquals(PMML.getDefaultNamespace(), pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getImportType()); assertTrue(pmmlDocumentMetadataArgumentCaptor.getValue().get(0).getModels().isEmpty()); }
|
MessageConverter { static BuildMessage convertMessage(final Message message, Handles handles) { final BuildMessage m = new BuildMessage(); switch (message.getLevel()) { case ERROR: m.setLevel(Level.ERROR); break; case WARNING: m.setLevel(Level.WARNING); break; case INFO: m.setLevel(Level.INFO); break; } m.setId(message.getId()); m.setLine(message.getLine()); m.setPath(convertPath(message.getPath(), handles)); m.setColumn(message.getColumn()); m.setText(convertMessageText(message)); return m; } }
|
@Test public void checkMessageWithKieBase() { final MessageImpl m = new MessageImpl(ID, Message.Level.ERROR, FILE, TEXT); m.setKieBaseName(KIE_BASE_NAME); final BuildMessage bm = MessageConverter.convertMessage(m, handles); assertConversion(bm, () -> "[KBase: " + KIE_BASE_NAME + "]: " + TEXT); }
@Test public void checkMessageWithoutKieBase() { final Message m = new MessageImpl(ID, Message.Level.ERROR, FILE, TEXT); final BuildMessage bm = MessageConverter.convertMessage(m, handles); assertConversion(bm, () -> TEXT); }
|
LocalBuildExecConfigExecutor implements BiFunctionConfigExecutor<LocalBuildConfigInternal, LocalBuildExecConfig, LocalBinaryConfig> { @Override public Optional<LocalBinaryConfig> apply(LocalBuildConfigInternal localBuildConfigInternal, LocalBuildExecConfig localBuildExecConfig) { Optional<LocalBinaryConfig> result = Optional.empty(); BuildHelper.BuildResult buildResult; switch (localBuildConfigInternal.getBuildType()) { case FULL_BUILD: buildResult = buildHelper.build(localBuildConfigInternal.getModule()); result = Optional.of(new LocalBuildBinaryImpl(buildResult.getBuilder(), buildResult.getBuildResults())); break; case INCREMENTAL_ADD_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.addPackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_UPDATE_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.updatePackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_DELETE_RESOURCE: result = Optional.of(new LocalBuildBinaryImpl( buildHelper.deletePackageResource(localBuildConfigInternal.getResource()))); break; case INCREMENTAL_BATCH_CHANGES: result = Optional.of( new LocalBuildBinaryImpl(buildHelper.applyBatchResourceChanges( localBuildConfigInternal.getModule(), localBuildConfigInternal.getResourceChanges()))); break; case FULL_BUILD_AND_DEPLOY: result = Optional.of( new LocalBuildBinaryImpl( buildHelper.buildAndDeploy(localBuildConfigInternal.getModule(), localBuildConfigInternal.isSuppressHandlers(), toDeploymentMode(localBuildConfigInternal.getDeploymentType())))); break; } return result; } LocalBuildExecConfigExecutor(); @Inject LocalBuildExecConfigExecutor(BuildHelper buildHelper); @Override Optional<LocalBinaryConfig> apply(LocalBuildConfigInternal localBuildConfigInternal, LocalBuildExecConfig localBuildExecConfig); @Override Class<? extends Config> executeFor(); @Override String outputId(); }
|
@Test public void testApplyForModuleFullBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD); when(internalBuildConfig.getModule()).thenReturn(module); when(buildHelper.build(module)).thenReturn(buildResult); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(builder, result.get().getBuilder()); assertEquals(buildResults, result.get().getBuildResults()); verify(buildHelper, times(1)).build(module); }
@Test public void testApplyForIncrementalResourceAddBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_ADD_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.addPackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).addPackageResource(path); }
@Test public void testApplyForIncrementalResourceUpdateBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_UPDATE_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.updatePackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).updatePackageResource(path); }
@Test public void testApplyForIncrementalResourceDeleteBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_DELETE_RESOURCE); when(internalBuildConfig.getResource()).thenReturn(path); when(buildHelper.deletePackageResource(path)).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).deletePackageResource(path); }
@Test public void testApplyForIncrementalBatchChangesBuild() { when(internalBuildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES); when(internalBuildConfig.getModule()).thenReturn(module); when(buildHelper.applyBatchResourceChanges(eq(module), anyMap())).thenReturn(incrementalBuildResults); Optional<LocalBinaryConfig> result = executor.apply(internalBuildConfig, buildExecConfig); assertTrue(result.isPresent()); assertEquals(incrementalBuildResults, result.get().getIncrementalBuildResults()); verify(buildHelper, times(1)).applyBatchResourceChanges(eq(module), anyMap()); }
|
BuildPipelineInvoker { public void invokeLocalBuildPipeLine(LocalBuildRequest buildRequest, Consumer<LocalBinaryConfig> consumer) { Pipeline pipe = pipelineRegistry.getPipelineByName(BuildPipelineInitializer.LOCAL_BUILD_PIPELINE); Input input = new Input() { { put(LocalSourceConfig.ROOT_PATH, buildRequest.getModule().getRootPath().toURI()); put(LocalBuildConfig.BUILD_TYPE, buildRequest.getBuildType().name()); if (buildRequest.isSingleResource()) { put(LocalBuildConfig.RESOURCE, encodePath(buildRequest.getResource())); } else { addResourceChanges(this, buildRequest.getResourceChanges()); } if (buildRequest.getDeploymentType() != null) { put(LocalBuildConfig.DEPLOYMENT_TYPE, buildRequest.getDeploymentType().name()); put(LocalBuildConfig.SUPPRESS_HANDLERS, Boolean.toString(buildRequest.isSuppressHandlers())); } } }; executor.execute(input, pipe, consumer); } BuildPipelineInvoker(); @Inject BuildPipelineInvoker(@Named("buildPipelineExecutor") final PipelineExecutor executor,
final PipelineRegistry pipelineRegistry); void invokeLocalBuildPipeLine(LocalBuildRequest buildRequest,
Consumer<LocalBinaryConfig> consumer); LocalBinaryConfig invokeLocalBuildPipeLine(LocalBuildRequest buildRequest); }
|
@Test public void testFullBuildRequest() { when(buildRequest.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD); input = createFullBuildInput(ROOT_PATH_URI); preparePipeline(input); LocalBinaryConfig result = pipelineInvoker.invokeLocalBuildPipeLine(buildRequest); verifyPipelineInvocation(localBinaryConfig, result); }
@Test public void testIncrementalBuildResourceChanges() { Map<Path, Collection<ResourceChange>> resourceChanges = createResourceChanges(changes); when(buildRequest.getBuildType()).thenReturn(LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES); when(buildRequest.isSingleResource()).thenReturn(false); when(buildRequest.getResourceChanges()).thenReturn(resourceChanges); input = createBatchChangesInput(ROOT_PATH_URI, LocalBuildConfig.BuildType.INCREMENTAL_BATCH_CHANGES.name(), changes); preparePipeline(input); LocalBinaryConfig result = pipelineInvoker.invokeLocalBuildPipeLine(buildRequest); verifyPipelineInvocation(localBinaryConfig, result); }
|
LocalSourceConfigExecutor implements FunctionConfigExecutor< LocalSourceConfig, Source > { @Override public Optional< Source > apply( LocalSourceConfig localSourceConfig ) { Path path = Paths.get( URI.create( localSourceConfig.getRootPath() ) ); return Optional.of( new LocalSource( path ) ); } LocalSourceConfigExecutor( ); @Override Optional< Source > apply( LocalSourceConfig localSourceConfig ); @Override Class< ? extends Config > executeFor( ); @Override String outputId( ); }
|
@Test public void testApply( ) { when( sourceConfig.getRootPath( ) ).thenReturn( ROOT_PATH_URI ); Optional< Source > result = executor.apply( sourceConfig ); assertTrue( result.isPresent( ) ); assertEquals( ROOT_PATH, result.get( ).getPath( ) ); }
|
LocalModuleConfigExecutor implements BiFunctionConfigExecutor<Source, LocalProjectConfig, ProjectConfig> { @Override public Optional<ProjectConfig> apply(Source source, LocalProjectConfig localProjectConfig) { Module module = moduleService.resolveModule(Paths.convert(source.getPath().resolve("pom.xml"))); return Optional.of(new LocalModuleImpl(module)); } LocalModuleConfigExecutor(); @Inject LocalModuleConfigExecutor(final KieModuleService moduleService); @Override Optional<ProjectConfig> apply(Source source,
LocalProjectConfig localProjectConfig); @Override Class<? extends Config> executeFor(); @Override String outputId(); }
|
@Test public void testApply() { Path pomPath = Paths.convert(POM_PATH); when(sourceConfig.getPath()).thenReturn(ROOT_PATH); when(moduleService.resolveModule(pomPath)).thenReturn(module); Optional<ProjectConfig> result = executor.apply(sourceConfig, projectConfig); assertTrue(result.isPresent()); assertEquals(module, ((LocalModule) result.get()).getModule()); }
|
LocalBuildConfigExecutor implements BiFunctionConfigExecutor<LocalModule, LocalBuildConfig, BuildConfig> { @Override public Optional<BuildConfig> apply(LocalModule localModule, LocalBuildConfig localBuildConfig) { Optional<BuildConfig> result = Optional.empty(); LocalBuildConfig.BuildType buildType = decodeBuildType(localBuildConfig.getBuildType()); switch (buildType) { case FULL_BUILD: result = Optional.of(new LocalBuildConfigInternal(localModule.getModule())); break; case INCREMENTAL_ADD_RESOURCE: case INCREMENTAL_DELETE_RESOURCE: case INCREMENTAL_UPDATE_RESOURCE: result = Optional.of(new LocalBuildConfigInternal(localModule.getModule(), buildType, decodePath(localBuildConfig.getResource()))); break; case INCREMENTAL_BATCH_CHANGES: result = Optional.of(new LocalBuildConfigInternal(localModule.getModule(), getResourceChanges(localBuildConfig.getResourceChanges()))); break; case FULL_BUILD_AND_DEPLOY: result = Optional.of(new LocalBuildConfigInternal(localModule.getModule(), decodeDeploymentType(localBuildConfig.getDeploymentType()), decodeSuppressHandlers(localBuildConfig.getSuppressHandlers()))); } return result; } LocalBuildConfigExecutor(); @Override Optional<BuildConfig> apply(LocalModule localModule, LocalBuildConfig localBuildConfig); @Override Class<? extends Config> executeFor(); @Override String outputId(); }
|
@Test public void testApplyForModuleFullBuild() { when(localModule.getModule()).thenReturn(project); when(buildConfig.getBuildType()).thenReturn(LocalBuildConfig.BuildType.FULL_BUILD.name()); Optional<BuildConfig> result = executor.apply(localModule, buildConfig); assertTrue(result.isPresent()); assertEquals(LocalBuildConfig.BuildType.FULL_BUILD, ((LocalBuildConfigInternal) result.get()).getBuildType()); assertEquals(project, ((LocalBuildConfigInternal) result.get()).getModule()); }
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.