DATACMNS-381 - Improved exception message in PropertyReferenceException.
PropertyReferenceException now not only exposes the property not found but also the already resolved Property path to make it easier to understand what is causing the exception in the first place.
This commit is contained in:
@@ -36,8 +36,7 @@ import org.springframework.data.util.TypeInformation;
|
||||
@SuppressWarnings("unused")
|
||||
public class PropertyPathUnitTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
@Rule public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
@@ -307,6 +306,19 @@ public class PropertyPathUnitTests {
|
||||
assertThat(path.next().getSegment(), is("UUID"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATACMNS-381
|
||||
*/
|
||||
public void exposesPreviouslyReferencedPathInExceptionMessage() {
|
||||
|
||||
exception.expect(PropertyReferenceException.class);
|
||||
exception.expectMessage("bar"); // missing variable
|
||||
exception.expectMessage("String"); // type
|
||||
exception.expectMessage("Bar.user.name"); // previously referenced path
|
||||
|
||||
PropertyPath.from("userNameBar", Bar.class);
|
||||
}
|
||||
|
||||
private class Foo {
|
||||
|
||||
String userName;
|
||||
|
||||
Reference in New Issue
Block a user