### Question:
RendererBuilder { protected Class getPrototypeClass(T content) { if (prototypes.size() == 1) { return prototypes.get(0).getClass(); } else { return binding.get(content.getClass()); } } RendererBuilder();  RendererBuilder(Renderer<T> renderer);  RendererBuilder(Collection<? extends Renderer<? extends T>> prototypes); final List<Renderer<? extends T>> getPrototypes(); final void setPrototypes(Collection<? extends Renderer<? extends T>> prototypes); RendererBuilder<T> withPrototypes(Collection<? extends Renderer<? extends T>> prototypes); RendererBuilder<T> withPrototype(Renderer<? extends T> renderer); RendererBuilder<T> bind(Class<G> clazz, Renderer<? extends G> prototype); RendererBuilder<T> bind(Class<G> clazz, Class<? extends Renderer<? extends G>> prototypeClass);  }### Answer:
@Test public void shouldReturnCreatedRenderer() { when(rendererBuilder.getPrototypeClass(mockedContent)).thenReturn(ObjectRenderer.class); Renderer<Object> renderer = buildRenderer(mockedContent, null, mockedParent, mockedLayoutInflater); assertEquals(objectRenderer.getClass(), renderer.getClass()); }
@Test public void shouldReturnRecycledRenderer() { when(rendererBuilder.getPrototypeClass(mockedContent)).thenReturn(ObjectRenderer.class); when(mockedConvertView.getTag()).thenReturn(objectRenderer); Renderer<Object> renderer = buildRenderer(mockedContent, mockedConvertView, mockedParent, mockedLayoutInflater); assertEquals(objectRenderer, renderer); }
@Test public void shouldCreateRendererEvenIfTagInConvertViewIsNotNull() { when(rendererBuilder.getPrototypeClass(mockedContent)).thenReturn(ObjectRenderer.class); when(mockedConvertView.getTag()).thenReturn(subObjectRenderer); Renderer<Object> renderer = buildRenderer(mockedContent, mockedConvertView, mockedParent, mockedLayoutInflater); assertEquals(objectRenderer.getClass(), renderer.getClass()); }
@Test public void shouldAddPrototyeAndconfigureBindingOnConstruction() { RendererBuilder<Object> rendererBuilder = new RendererBuilder<Object>(new ObjectRenderer()); assertEquals(ObjectRenderer.class, rendererBuilder.getPrototypeClass(new Object())); }