### Question:
BasicImaging implements Imaging { @Override public Image mosaic(java.util.List<Image> images, PixelRange imgBounds) { if (images.isEmpty()) throw new IllegalArgumentException("Require at least one image"); BasicImage baseTile = (BasicImage) images.get(0); if (imgBounds.getWidth() == 0 || imgBounds.getHeight() == 0) { return createEmptyImage(baseTile, atLeastOnePixel(imgBounds)); } BufferedImage baseImage = getIndexedColorsConverted(baseTile); Dimension dimension = imgBounds.getDimension(); WritableRaster raster = baseImage.getData().createCompatibleWritableRaster(dimension.width, dimension.height); BufferedImage res = new BufferedImage(baseImage.getColorModel(), raster, baseImage.isAlphaPremultiplied(), null); mosaic(images, imgBounds, res); return new BasicImage(res, imgBounds.getMinX(), imgBounds.getMinY()); }  @Override Image createEmptyImage(Dimension dimension, ImageFormat tileImageFormat); @Override Image createEmptyImage(Image baseImage, Dimension dimension); @Override Image mosaic(java.util.List<Image> images, PixelRange imgBounds); @Override Image crop(Image source, PixelRange cropBnds); @Override Image scale(Image source, Dimension dimension); @Override Image overlay(Image src1, Image src2); @Override Image affineTransform(Image image, AffineTransform atf); @Override Image affineTransform(Image image, int tx, int ty, double sx, double sy); @Override Image read(InputStream is, int minX, int minY, boolean forceArgb); @Override Image fromRenderedImage(RenderedImage image); @Override Image reprojectByWarping(Image srcImg, MapUnitToPixelTransform mupTransform, CrsId srs, CoordinateReferenceSystem<?> requestedSRS, MapUnitToPixelTransform targetMupTransform, double v);  }### Answer:
@Test public void testMosaicNoCrop() throws IOException { Image img00 = readTileImage("00.png", false, 0,256); Image img01 = readTileImage("01.png", false, 0, 0); Image img10 = readTileImage("10.png", false, 256, 256); Image img11 = readTileImage("11.png", false, 256, 0); List<Image> images = Arrays.asList(img00, img01, img10 , img11); Image result = imaging.mosaic(images, new PixelRange(0, 0, 512, 512)); assertEquals(0, result.getMinX()); assertEquals(0, result.getMinY()); assertEquals(512,result.getWidth()); assertEquals(512, result.getHeight()); Image received = imageAfterIO(result, ImageFormat.PNG); Image expected = readTileImage("mosaic-no-crop.png", true); assertImageEquals(expected, received); }
@Test public void testMosaicCrop() throws IOException { Image img00 = readTileImage("00.png", false, 0,256); Image img01 = readTileImage("01.png", false, 0, 0); Image img10 = readTileImage("10.png", false, 256, 256); Image img11 = readTileImage("11.png", false, 256, 0); List<Image> images = Arrays.asList(img00, img01, img10 , img11); Image result = imaging.mosaic(images, new PixelRange(128, 128, 256, 256)); assertEquals(128, result.getMinX()); assertEquals(128, result.getMinY()); assertEquals(256,result.getWidth()); assertEquals(256, result.getHeight()); Image received = imageAfterIO(result, ImageFormat.PNG); Image expected = readTileImage("mosaic-crop.png", true); assertImageEquals(expected, received); }