Add @UnmappedPropertyValue support
Update @PropertyMapping support to allow single enum values to be marked as an @UnmappedPropertyValue. This change is primarily so that users can replace "default" values globally for across all tests. See gh-6455
This commit is contained in:
@@ -185,6 +185,20 @@ public class AnnotationsPropertySourceTests {
|
||||
assertThat(source.getProperty("aliasing.value")).isEqualTo("baz");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enumValueMapped() throws Exception {
|
||||
AnnotationsPropertySource source = new AnnotationsPropertySource(
|
||||
EnumValueMapped.class);
|
||||
assertThat(source.getProperty("testenum.value")).isEqualTo(EnumItem.TWO);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void enumValueNotMapped() throws Exception {
|
||||
AnnotationsPropertySource source = new AnnotationsPropertySource(
|
||||
EnumValueNotMapped.class);
|
||||
assertThat(source.containsProperty("testenum.value")).isFalse();
|
||||
}
|
||||
|
||||
static class NoAnnotation {
|
||||
|
||||
}
|
||||
@@ -382,4 +396,32 @@ public class AnnotationsPropertySourceTests {
|
||||
|
||||
}
|
||||
|
||||
@EnumAnnotation(EnumItem.TWO)
|
||||
static class EnumValueMapped {
|
||||
|
||||
}
|
||||
|
||||
@EnumAnnotation(EnumItem.DEFAULT)
|
||||
static class EnumValueNotMapped {
|
||||
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@PropertyMapping("testenum")
|
||||
static @interface EnumAnnotation {
|
||||
|
||||
EnumItem value();
|
||||
|
||||
}
|
||||
|
||||
enum EnumItem {
|
||||
|
||||
@UnmappedPropertyValue DEFAULT,
|
||||
|
||||
ONE,
|
||||
|
||||
TWO
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user