DATACMNS-546 - PropertyPath has better exception messages now.

PropertyPath now exposes the complete property named the resolution failed for in case it can't resolve a source String. It will expose the part of the Path from the deepest successful resolution result.

Changed the resolution algorithm to use a List instead of a Stack and a fresh instance of the former so that the nested recursion steps keep track of the correct resolution depths.
This commit is contained in:
Oliver Gierke
2014-07-21 18:04:29 +02:00
parent 5bc89af4e7
commit ba70380555
3 changed files with 55 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2013 the original author or authors.
* Copyright 2011-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -310,6 +310,7 @@ public class PropertyPathUnitTests {
/**
* @see DATACMNS-381
*/
@Test
public void exposesPreviouslyReferencedPathInExceptionMessage() {
exception.expect(PropertyReferenceException.class);
@@ -352,6 +353,26 @@ public class PropertyPathUnitTests {
from("foo", (TypeInformation<?>) null);
}
@Test
public void returnsCompletePathIfResolutionFailedCompletely() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("somethingDifferent");
from("somethingDifferent", Foo.class);
}
@Test
public void foobar() {
exception.expect(PropertyReferenceException.class);
exception.expectMessage("fooName");
exception.expectMessage(FooBar.class.getSimpleName());
exception.expectMessage("Bar.user");
from("userFooName", Bar.class);
}
private class Foo {
String userName;