RenderSupport implements Renderer { @Override public void render(final Shape renderable) { if (this.supports(renderable)) { this.origin.render(renderable); } } RenderSupport(final Renderer origin, final Class<?>... clazz); @Override void render(final Shape renderable);  }
@Test public void delegatesToWrappedWhenSupported() { final Renderer rend = Mockito.mock(Renderer.class); final Shape shape = new Shape(Mockito.mock(Line.class)); final RenderSupport renderer = new RenderSupport(rend, Line.class); renderer.render(shape); Mockito.verify(rend).render(shape); }
@Test public void ignoresUnsupportedShape() { final Renderer rend = Mockito.mock(Renderer.class); final Shape shape = new Shape(Mockito.mock(Renderable.class)); final RenderSupport renderer = new RenderSupport(rend, Line.class); renderer.render(shape); Mockito.verify(rend, Mockito.never()).render(shape); }