ReflectionUtil { public String getStringValueFromObject(final Object object, final String fieldName) { return convertToString(getValueFromObject(object, fieldName, Object.class)); }  String getStringValueFromObject(final Object object, final String fieldName); T getValueFromObject(final Object object, final String fieldName, final Class<T> valueClass); static final char ATTRIBUTE_SEPARATOR; }
@Test void testGetStringValueFromObjectByProperty() { assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "aProperty")).isEqualTo("aPropertyByField"); }
@Test void testGetStringValueFromObjectByGetter() { assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "bProperty")).isEqualTo("bPropertyByGetter"); }
@Test void testGetStringValuePropertyWithDotNotation() { assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "innerDemoPojo.cProperty")).isEqualTo("cPropertyByField"); assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "innerDemoPojo.dProperty")).isEqualTo("dPropertyByGetter"); assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "innerDemoPojo.innerInnerDemoPojo.eProperty")).isEqualTo("ePropertyByField"); assertThat(new ReflectionUtil().getStringValueFromObject(new DemoPojo(), "innerDemoPojo.innerInnerDemoPojo.fProperty")).isEqualTo("fPropertyByGetter"); }