### Question:
CropHandler implements TransformationHandler { @Override public void handle(Builder<? extends InputStream> builder, Resource config) throws IOException { String positionStr = config.getValueMap().get(PN_POSITION, "CENTER").toUpperCase(); try { Positions pos = Positions.valueOf(positionStr); builder.crop(pos); } catch (IllegalArgumentException e) { throw new IOException("Unable to load crop position from " + positionStr, e); } }  @Override String getResourceType(); @Override void handle(Builder<? extends InputStream> builder, Resource config); static final String PN_POSITION; }### Answer:
@Test public void testCrop() throws IOException { Resource config = new MockResource("/conf", Collections.singletonMap(CropHandler.PN_POSITION, "CENTER"), Mockito.mock(ResourceResolver.class)); cropper.handle(builder, config); assertNotNull(builder.asBufferedImage()); }
@Test public void testCropLower() throws IOException { Resource config = new MockResource("/conf", Collections.singletonMap(CropHandler.PN_POSITION, "center"), Mockito.mock(ResourceResolver.class)); cropper.handle(builder, config); assertNotNull(builder.asBufferedImage()); }
@Test public void testInvalidParam() throws IOException { try { Resource config = new MockResource("/conf", Collections.singletonMap(CropHandler.PN_POSITION, "centerz"), Mockito.mock(ResourceResolver.class)); cropper.handle(builder, config); fail(); } catch (IOException e) { } }