### Question:
AnnotatorFactory { public Annotator getAnnotator(AnnotationStyle style) { switch (style) { case JACKSON: case JACKSON2: return new Jackson2Annotator(generationConfig); case JACKSON1: return new Jackson1Annotator(generationConfig); case GSON: return new GsonAnnotator(generationConfig); case MOSHI1: return new Moshi1Annotator(generationConfig); case NONE: return new NoopAnnotator(); default: throw new IllegalArgumentException("Unrecognised annotation style: " + style); } } AnnotatorFactory(GenerationConfig generationConfig); Annotator getAnnotator(AnnotationStyle style); Annotator getAnnotator(Class<? extends Annotator> clazz); CompositeAnnotator getAnnotator( Annotator... annotators );  }### Answer:
@Test public void canCreateCorrectAnnotatorFromAnnotationStyle() { assertThat(factory.getAnnotator(JACKSON1), is(instanceOf(Jackson1Annotator.class))); assertThat(factory.getAnnotator(JACKSON), is(instanceOf(Jackson2Annotator.class))); assertThat(factory.getAnnotator(JACKSON2), is(instanceOf(Jackson2Annotator.class))); assertThat(factory.getAnnotator(GSON), is(instanceOf(GsonAnnotator.class))); assertThat(factory.getAnnotator(MOSHI1), is(instanceOf(Moshi1Annotator.class))); assertThat(factory.getAnnotator(NONE), is(instanceOf(NoopAnnotator.class))); }
@Test public void canCreateCorrectAnnotatorFromClass() { assertThat(factory.getAnnotator(Jackson1Annotator.class), is(instanceOf(Jackson1Annotator.class))); }
@Test public void canCreateCompositeAnnotator() { Annotator annotator1 = mock(Annotator.class); Annotator annotator2 = mock(Annotator.class); CompositeAnnotator composite = factory.getAnnotator(annotator1, annotator2); assertThat(composite.annotators.length, equalTo(2)); assertThat(composite.annotators[0], is(equalTo(annotator1))); assertThat(composite.annotators[1], is(equalTo(annotator2))); }