### Question:
DescriptionService { public List<ComponentDescription> findAllComponentDescriptions() { Set<Class<? extends Component>> classes = classRepository.getComponentClasses(); List<ComponentDescription> descriptions = new ArrayList<>(); for (Class<? extends Component> componentClass : classes) { try { ComponentDescription description = componentDescriptionFactory.createDescription(componentClass); descriptions.add(description); } catch (Exception ex) { ex.printStackTrace(); } } return descriptions; }  List<ComponentDescription> findAllComponentDescriptions(); List<PythianStateDescription> findAllStateDescriptions();  }### Answer:
@Test public void should_load_component_descriptions() { when(classRepository.getComponentClasses()).thenReturn(newHashSet(TestAnalytics.class, TestLearner1.class, TestLearner2.class)); ComponentDescription testAnalyticsDescription = mock(ComponentDescription.class); ComponentDescription testLearner1Description = mock(ComponentDescription.class); ComponentDescription testLearner2Description = mock(ComponentDescription.class); when(componentDescriptionFactory.createDescription(TestAnalytics.class)).thenReturn(testAnalyticsDescription); when(componentDescriptionFactory.createDescription(TestLearner1.class)).thenReturn(testLearner1Description); when(componentDescriptionFactory.createDescription(TestLearner2.class)).thenReturn(testLearner2Description); List<ComponentDescription> actualDescriptions = service.findAllComponentDescriptions(); assertThat(actualDescriptions).containsOnly(testAnalyticsDescription, testLearner1Description, testLearner2Description); }