### Question:
ReflectionHelper { public static void setProperties(Object obj, List<PropertyConfiguration> properties) { for (PropertyConfiguration property : properties) { setProperty(obj, property); } }  @SuppressWarnings("unchecked") static Map<String, Stream> getOutputStreams(Component component); @SuppressWarnings("unchecked") static Stream getOutputStream(Object obj, String name); @SuppressWarnings("unchecked") static List<String> getInputStreamNames(Class<? extends Component> componentClazz); static void setProperties(Object obj, List<PropertyConfiguration> properties); static void setInputStreams(Component component, Map<String, Stream> inputStreams); @SuppressWarnings("unchecked") static void setTopology(Component component, TridentTopology topology); @SuppressWarnings("unchecked") static void setConfiguration(Component component, Config config); @SuppressWarnings("unchecked") static void setFeaturesMapper(Component component, String streamName, NamedFeaturesMapper mapper); @SuppressWarnings("unchecked") static void setFeaturesMapper(Component component, String streamName, ListedFeaturesMapper mapper); @SuppressWarnings("unchecked") static void setStateFactory(Component component, String stateName, StateFactory stateFactory); @SuppressWarnings("unchecked") static void setInputStream(Component component, String name, Stream stream); @SuppressWarnings("unchecked") static NameMapper getNameMapper(Class<?> clazz, String stream); @SuppressWarnings("unchecked") static ListMapper getListMapper(Class<?> clazz, String stream); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object getEnumValue(Class<?> clazz, String name);  }### Answer:
@Test public void should_set_properties() { class TestObject { @Property(name = "prop1") public String prop1; @Property(name = "prop2") public Integer prop2; @Property(name = "prop3") private Boolean prop3; } TestObject test = new TestObject(); List<PropertyConfiguration> properties = Arrays.asList( new PropertyConfiguration("prop1", "hey", new PropertyDescription("prop1", "", false, STRING)), new PropertyConfiguration("prop2", 3, new PropertyDescription("prop2", "", false, INTEGER)), new PropertyConfiguration("prop3", true, new PropertyDescription("prop3", "", false, BOOLEAN))); ReflectionHelper.setProperties(test, properties); assertThat(test.prop1).isEqualTo("hey"); assertThat(test.prop2).isEqualTo(3); assertThat(test.prop3).isEqualTo(true); }
@Test(expected = IllegalArgumentException.class) public void should_fail_when_setting_bad_properties() { class TestObject { @Property(name = "prop1") public String prop1; } TestObject test = new TestObject(); List<PropertyConfiguration> properties = Arrays.asList(new PropertyConfiguration("prop1", true)); ReflectionHelper.setProperties(test, properties); }
@Test public void should_set_enum_property() { class Test { @Property(name = "gender") public Gender gender; } Test test = new Test(); List<PropertyConfiguration> properties = new ArrayList<>(); properties.add(new PropertyConfiguration("gender", "MALE", new PropertyDescription("gender", "", false, ENUM))); ReflectionHelper.setProperties(test, properties); assertThat(test.gender).isEqualTo(MALE); }