DATAREST-1163 - ValidationErrors now properly looks up null values.
The field value lookup in ValidationErrors previously threw a NotReadablePropertyException in case a property value was null as we incorrectly piped the null value into an Optional in turn. We now eagerly reject the property if we can't find a PersistentProperty in the metamodel to avoid this.
This commit is contained in:
@@ -63,6 +63,14 @@ public class ValidationErrorsUnitTests {
|
||||
expectedErrorBehavior(new ValidationErrors(new Foo(), entities));
|
||||
}
|
||||
|
||||
@Test // DATAREST-1163
|
||||
public void returnsNullForPropertyValue() {
|
||||
|
||||
ValidationErrors errors = new ValidationErrors(new Foo(), entities);
|
||||
|
||||
assertThat(errors.getFieldValue("bar")).isNull();
|
||||
}
|
||||
|
||||
private static void expectedErrorBehavior(Errors errors) {
|
||||
|
||||
assertThat(errors.getFieldValue("bars")).isNotNull();
|
||||
@@ -79,6 +87,7 @@ public class ValidationErrorsUnitTests {
|
||||
|
||||
static class Foo {
|
||||
List<Bar> bars = Collections.singletonList(new Bar());
|
||||
Bar bar = null;
|
||||
}
|
||||
|
||||
static class Bar {
|
||||
|
||||
Reference in New Issue
Block a user