### Question:
ReferencedStateDescriptionFactory { @SuppressWarnings("unchecked") public List<ReferencedStateDescription> createDescriptions(Class<?> componentClass) { List<ReferencedStateDescription> descriptions = new ArrayList<>(); Set<Field> fields = getFields(componentClass, withAnnotation(State.class)); for (Field field : fields) { checkSupportedType(field); State annotation = field.getAnnotation(State.class); ReferencedStateDescription description = new ReferencedStateDescription(annotation.name(), annotation.description()); descriptions.add(description); } return descriptions; }  @SuppressWarnings("unchecked") List<ReferencedStateDescription> createDescriptions(Class<?> componentClass);  }### Answer:
@Test public void should_create_descriptions() { class TestComponent implements Component { @State(name = "Word count", description = "State containing count by word") private StateFactory stateFactory; @Override public void init() { } } List<ReferencedStateDescription> actualDescriptions = factory.createDescriptions(TestComponent.class); assertThat(actualDescriptions).containsOnly(new ReferencedStateDescription("Word count", "State containing count by word")); }
@Test(expected = IllegalArgumentException.class) public void should_fail_if_state_annotation_is_not_on_a_state_factory_field() { class TestComponent implements Component { @State(name = "Word count") private Object stateFactory; @Override public void init() { } } factory.createDescriptions(TestComponent.class); }