### Question:
ReflectionObjectFactory implements ObjectFactory { @Override public <T> Collection<T> instantiateAllImplementers(Class<T> interfaceClass, Object... parameter) { Collection<Class<? extends T>> filteredClasses = findLegalImplementers(interfaceClass); return Collections2.transform(filteredClasses, 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 instantiatesAllClassesImplementingInterface() { Set<Class<? extends DummyInterface>> implementingClasses = new LinkedHashSet<>(); implementingClasses.add(AnnotatedDummy.class); implementingClasses.add(AnotherAnnotatedDummy.class); when(interfaceFinder.findAll(DummyInterface.class)).thenReturn(implementingClasses); Collection<DummyInterface> result = factory.instantiateAllImplementers(DummyInterface.class); assertThat(result, hasSize(2)); }
@Test public void ignoresBlackListedImplementors() { Set<Class<? extends DummyInterface>> implementingClasses = new LinkedHashSet<>(); implementingClasses.add(IgnoredDummy.class); when(interfaceFinder.findAll(DummyInterface.class)).thenReturn(implementingClasses); Collection<DummyInterface> result = factory.instantiateAllImplementers(DummyInterface.class); assertThat(result, hasSize(0)); }
@Test public void ignoresAbstractImplementors() { Set<Class<? extends DummyInterface>> implementingClasses = new LinkedHashSet<>(); implementingClasses.add(AbstractDummy.class); when(interfaceFinder.findAll(DummyInterface.class)).thenReturn(implementingClasses); Collection<DummyInterface> result = factory.instantiateAllImplementers(DummyInterface.class); assertThat(result, hasSize(0)); }