Fix cast exception in integration test

- Although the class only has fields of Property type it would appear that CircleCI et al. may use libraries that add fields to classes later on, so we need to check for the field type
This commit is contained in:
ljacqu 2016-01-08 23:40:54 +01:00
parent d0b7d0ff06
commit 752ebe5022

View File

@ -35,10 +35,12 @@ public class NewSettingIntegrationTest {
public static void generatePropertyMap() {
propertyMap = new PropertyMap();
for (Field field : TestConfiguration.class.getDeclaredFields()) {
Property<?> property =
(Property<?>) ReflectionTestUtils.getFieldValue(TestConfiguration.class, null, field.getName());
String[] comments = new String[]{"Comment for '" + property.getPath() + "'"};
propertyMap.put(property, comments);
Object fieldValue = ReflectionTestUtils.getFieldValue(TestConfiguration.class, null, field.getName());
if (fieldValue instanceof Property<?>) {
Property<?> property = (Property<?>) fieldValue;
String[] comments = new String[]{"Comment for '" + property.getPath() + "'"};
propertyMap.put(property, comments);
}
}
}