### Question:
SizeHandler implements TransformationHandler { @Override public void handle(Builder<? extends InputStream> builder, Resource config) throws IOException { int width = config.getValueMap().get(PN_WIDTH, -1); int height = config.getValueMap().get(PN_HEIGHT, -1); builder.size(width, height); }  @Override String getResourceType(); @Override void handle(Builder<? extends InputStream> builder, Resource config); static final String PN_HEIGHT; static final String PN_WIDTH; }### Answer:
@Test public void testResize() throws IOException { Map<String, Object> config = new HashMap<>(); config.put(SizeHandler.PN_WIDTH, 200); config.put(SizeHandler.PN_HEIGHT, 200); sizer.handle(builder, new MockResource("/conf", config, Mockito.mock(ResourceResolver.class))); assertNotNull(builder.asBufferedImage()); }
@Test public void testInvalidWidth() throws IOException { try { Map<String, Object> config = new HashMap<>(); config.put(SizeHandler.PN_WIDTH, "K"); config.put(SizeHandler.PN_HEIGHT, 200); sizer.handle(builder, new MockResource("/conf", config, Mockito.mock(ResourceResolver.class))); fail(); } catch (IOException | IllegalArgumentException e) { } }
@Test public void testInvalidHeight() throws IOException { try { Map<String, Object> config = new HashMap<>(); config.put(SizeHandler.PN_WIDTH, 200); config.put(SizeHandler.PN_HEIGHT, "h"); sizer.handle(builder, new MockResource("/conf", config, Mockito.mock(ResourceResolver.class))); fail(); } catch (IOException | IllegalArgumentException e) { } }