#1150 Improve error reporting for nested properties

This commit is contained in:
Filip Hrisafov 2017-06-29 20:25:42 +02:00 committed by GitHub
parent a3eca8c8ca
commit 7a9464c525
4 changed files with 12 additions and 6 deletions

View File

@ -324,7 +324,9 @@ public class PropertyMapping extends ModelElement {
*/
private void reportCannotCreateMapping() {
if ( method instanceof ForgedMethod && ( (ForgedMethod) method ).getHistory() != null ) {
ForgedMethodHistory history = ( (ForgedMethod) method ).getHistory();
// The history that is part of the ForgedMethod misses the information from the current right hand
// side. Therefore we need to extract the most relevant history and use that in the error reporting.
ForgedMethodHistory history = getForgedMethodHistory( rightHandSide );
reportCannotCreateMapping(
method,
history.createSourcePropertyErrorMessage(),

View File

@ -57,7 +57,13 @@ public class ErroneousJavaInternalTest {
line = 29,
messageRegExp = "Can't map property \".*List<.*MyType> types\" to \".*List<.*String> types\"\\" +
". Consider to declare/implement a mapping method: \".*List<.*String> map\\(.*List<.*MyType> " +
"value\\)\"\\.")
"value\\)\"\\."),
@Diagnostic(type = ErroneousJavaInternalMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR,
line = 29,
messageRegExp = "Can't map property \".*List<.*MyType> nestedMyType\\.deepNestedType\\.types\" to \"" +
".*List<.*String> nestedMyType\\.deepNestedType\\.types\"\\. Consider to declare/implement a " +
"mapping method: \".*List<.*String> map\\(.*List<.*MyType> value\\)\"\\.")
})
@Test
public void shouldNotNestIntoJavaPackageObjects() throws Exception {

View File

@ -47,8 +47,6 @@ class Source {
public MyType date;
public MyType calendar;
public List<MyType> types;
//TODO Nested error messages do not work yet. I think that this should be solved as part of #1150
// (or we solve that one first :))
//public NestedMyType nestedMyType;
public NestedMyType nestedMyType;
//CHECKSTYLE:ON
}

View File

@ -43,6 +43,6 @@ class Target {
public Date date;
public GregorianCalendar calendar;
public List<String> types;
//public TargetNested nestedMyType;
public TargetNested nestedMyType;
//CHECKSTYLE:ON
}