### Question:
ReflectionObjectFactory implements ObjectFactory { @Override public <T> Collection<T> instantiateAll(Class<? extends Annotation> annotation, Object... parameter) throws InitializationException { Set<Class<?>> pluginClasses = finder.getTypesAnnotatedWith(annotation); return Collections2.transform(pluginClasses, new Instantiate<>(parameter)); } ReflectionObjectFactory(AnnotationFinder finder, InterfaceFinder interfaceFinder); @Override Collection<T> instantiateOrdered(Class<? extends Annotation> annotation,
                                              Object... parameter); @Override Collection<T> instantiateAll(Class<? extends Annotation> annotation,
                                          Object... parameter); @Override Collection<T> instantiateAllImplementers(Class<T> interfaceClass, Object... parameter);  }### Answer:
@Test public void findsNoClassesWhenAnnotationUnknown() { Collection<Object> result = factory.instantiateAll(DummyAnnotation.class); assertThat(result, hasSize(0)); }
@Test public void instantiatesClassWhenFinderDiscoversThem() { annotatedClasses.add(AnnotatedDummy.class); Collection<Object> result = factory.instantiateAll(DummyAnnotation.class); assertThat(result, contains(is(instanceOf(AnnotatedDummy.class)))); }
@Test public void usesConstructorArguments() { annotatedClasses.add(AnnotatedDummy.class); Collection<AnnotatedDummy> result = factory.instantiateAll(DummyAnnotation.class, "Parameter"); Iterables.getOnlyElement(result).assertStringConstructorWasUsed(); }
@Test public void instantiatesAllClassesAnnotated() { annotatedClasses.add(AnnotatedDummy.class); annotatedClasses.add(AnotherAnnotatedDummy.class); Collection<AnnotatedDummy> result = factory.instantiateAll(DummyAnnotation.class); assertThat(result, hasSize(2)); }