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:
Oliver Gierke
2017-11-29 10:28:09 +01:00
parent 4ba413d084
commit 1ebdeb9589
2 changed files with 29 additions and 22 deletions

View File

@@ -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 {