### Question:
FilterBlur implements Filter { @Override public ImageBuffer filter(ImageBuffer source) { final int width = source.getWidth(); final int height = source.getHeight(); if (width < MIN_SIZE || height < MIN_SIZE) { return source; } final int[] inPixels = new int[width * height]; final int[] outPixels = new int[width * height]; source.getRgb(0, 0, width, height, inPixels, 0, width); final Kernel kernel = createKernel(radius, width, height); compute(kernel, inPixels, outPixels, width, height, alpha, edge); compute(kernel, outPixels, inPixels, height, width, alpha, edge); final ImageBuffer dest = Graphics.createImageBuffer(width, height, source.getTransparentColor()); dest.setRgb(0, 0, width, height, inPixels, 0, width); return dest; } FilterBlur(); void setRadius(float radius); void setAlpha(boolean alpha); void setEdgeMode(int edge); @Override ImageBuffer filter(ImageBuffer source); @Override Transform getTransform(double scaleX, double scaleY); static final int CLAMP_EDGES; static final int WRAP_EDGES; }### Answer:
@Test void testNoPixel() { final FilterBlur blur = new FilterBlur(); final ImageBuffer image = Graphics.createImageBuffer(1, 1); final ImageBuffer filtered = blur.filter(image); assertNotNull(filtered); assertEquals(image.getWidth(), filtered.getWidth()); assertEquals(image.getHeight(), filtered.getHeight()); image.dispose(); filtered.dispose(); }
@Test void testSinglePixel() { final FilterBlur blur = new FilterBlur(); final ImageBuffer image = Graphics.createImageBuffer(1, 1); final ImageBuffer filtered = blur.filter(image); assertEquals(image, filtered); image.dispose(); filtered.dispose(); }
@Test void testLowWidth() { final FilterBlur blur = new FilterBlur(); final ImageBuffer image = Graphics.createImageBuffer(1, 3); final ImageBuffer filtered = blur.filter(image); assertEquals(image, filtered); image.dispose(); filtered.dispose(); }
@Test void testLowHeight() { final FilterBlur blur = new FilterBlur(); final ImageBuffer image = Graphics.createImageBuffer(3, 1); final ImageBuffer filtered = blur.filter(image); assertEquals(image, filtered); image.dispose(); filtered.dispose(); }