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:
Oliver Gierke
2013-10-10 13:01:09 +02:00
parent 06c2f41584
commit 048394690f
3 changed files with 59 additions and 19 deletions

View File

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