### Question:
DescriptionService { public List<PythianStateDescription> findAllStateDescriptions() { Set<Class<? extends PythianState>> classes = classRepository.getStateClasses(); List<PythianStateDescription> descriptions = new ArrayList<>(); for (Class<? extends PythianState> clazz : classes) { try { PythianStateDescription description = stateDescriptionFactory.createDescription(clazz); descriptions.add(description); } catch (Exception ex) { ex.printStackTrace(); } } return descriptions; }  List<ComponentDescription> findAllComponentDescriptions(); List<PythianStateDescription> findAllStateDescriptions();  }### Answer:
@Test public void should_load_state_descriptions() { when(classRepository.getStateClasses()).thenReturn(newHashSet(State1.class, State2.class)); PythianStateDescription state1Description = mock(PythianStateDescription.class); PythianStateDescription state2Description = mock(PythianStateDescription.class); when(stateDescriptionFactory.createDescription(State1.class)).thenReturn(state1Description); when(stateDescriptionFactory.createDescription(State2.class)).thenReturn(state2Description); List<PythianStateDescription> actualDescriptions = service.findAllStateDescriptions(); assertThat(actualDescriptions).containsOnly(state1Description, state2Description); }