diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java index 4fab9de41..864b6ac7f 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/BeanMappingMethod.java @@ -829,7 +829,7 @@ public class BeanMappingMethod extends NormalTypeMappingMethod { ForgedMethodHistory history = forgedMethod.getHistory(); ctx.getMessager().printMessage( this.method.getExecutable(), - Message.PROPERTYMAPPING_MAPPING_NOT_FOUND, + Message.PROPERTYMAPPING_FORGED_MAPPING_WITH_HISTORY_NOT_FOUND, history.createSourcePropertyErrorMessage(), history.getTargetType(), history.createTargetPropertyName(), diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/MapMappingMethod.java b/processor/src/main/java/org/mapstruct/ap/internal/model/MapMappingMethod.java index 815541422..694ed4a64 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/MapMappingMethod.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/MapMappingMethod.java @@ -184,7 +184,6 @@ public class MapMappingMethod extends NormalTypeMappingMethod { .getFactoryMethod( method, null, ctx ); } - keyAssignment = new LocalVarWrapper( keyAssignment, method.getThrownTypes(), keyTargetType, false ); valueAssignment = new LocalVarWrapper( valueAssignment, method.getThrownTypes(), valueTargetType, false ); diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java b/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java index 405df915a..efad6f3ee 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/Message.java @@ -32,7 +32,8 @@ public enum Message { BEANMAPPING_UNKNOWN_PROPERTY_IN_DEPENDS_ON( "\"%s\" is no property of the method return type." ), PROPERTYMAPPING_MAPPING_NOT_FOUND( "Can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ), - PROPERTYMAPPING_FORGED_MAPPING_NOT_FOUND( "Can't map %s to %s. Consider to implement a mapping method: \"%s map(%s value)\"." ), + PROPERTYMAPPING_FORGED_MAPPING_WITH_HISTORY_NOT_FOUND( "No target bean properties found: can't map %s to \"%s %s\". Consider to declare/implement a mapping method: \"%s map(%s value)\"." ), + PROPERTYMAPPING_FORGED_MAPPING_NOT_FOUND( "No target bean properties found: can't map %s to %s. Consider to implement a mapping method: \"%s map(%s value)\"." ), PROPERTYMAPPING_DUPLICATE_TARGETS( "Target property \"%s\" must not be mapped more than once." ), PROPERTYMAPPING_EMPTY_TARGET( "Target must not be empty in @Mapping." ), PROPERTYMAPPING_SOURCE_AND_CONSTANT_BOTH_DEFINED( "Source and constant are both defined in @Mapping, either define a source or a constant." ), diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/erroneous/ErroneousCollectionMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/erroneous/ErroneousCollectionMappingTest.java index 8a1a138c4..feefb92b4 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/erroneous/ErroneousCollectionMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/erroneous/ErroneousCollectionMappingTest.java @@ -104,9 +104,9 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoElementMappingFound.class, kind = Kind.ERROR, line = 25, - messageRegExp = "Can't map Collection element \".*WithProperties withProperties\" to \".*NoProperties" + - " noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" + - ".*WithProperties value\\)") + messageRegExp = "No target bean properties found: can't map Collection element \".*WithProperties " + + "withProperties\" to \".*NoProperties noProperties\". Consider to declare/implement " + + "a mapping method: \".*NoProperties map\\(.*WithProperties value\\)") } ) public void shouldFailOnNoElementMappingFound() { @@ -138,9 +138,10 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoKeyMappingFound.class, kind = Kind.ERROR, line = 25, - messageRegExp = "Can't map Map key \".*WithProperties withProperties\" to \".*NoProperties " + - "noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" + - ".*WithProperties value\\)") + messageRegExp = "No target bean properties found: can't map Map key \".*WithProperties " + + "withProperties\" to " + + "\".*NoProperties noProperties\". Consider to declare/implement a mapping method: " + + "\".*NoProperties map\\(.*WithProperties value\\)" ) } ) public void shouldFailOnNoKeyMappingFound() { @@ -171,9 +172,10 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoValueMappingFound.class, kind = Kind.ERROR, line = 25, - messageRegExp = "Can't map Map value \".*WithProperties withProperties\" to \".*NoProperties " + - "noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" + - ".*WithProperties value\\)") + messageRegExp = "No target bean properties found: can't map Map value \".*WithProperties " + + "withProperties\" to " + + "\".*NoProperties noProperties\". Consider to declare/implement a mapping method: " + + "\".*NoProperties map\\(.*WithProperties value\\)" ) } ) public void shouldFailOnNoValueMappingFound() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java index 0c4480b3b..c538318fd 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/forged/CollectionMappingTest.java @@ -87,8 +87,8 @@ public class CollectionMappingTest { @Diagnostic(type = ErroneousCollectionNonMappableSetMapper.class, kind = Kind.ERROR, line = 17, - messageRegExp = "Can't map Collection element \".* nonMappableSet\" to \".* nonMappableSet\". " - + "Consider to declare/implement a mapping method: .*."), + messageRegExp = "No target bean properties found: can't map Collection element \".* nonMappableSet\" " + + "to \".* nonMappableSet\". Consider to declare/implement a mapping method: .*." ), } ) public void shouldGenerateNonMappleMethodForSetMapping() { @@ -107,13 +107,15 @@ public class CollectionMappingTest { @Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class, kind = Kind.ERROR, line = 17, - messageRegExp = "Can't map Map key \".* nonMappableMap\\{:key\\}\" to \".* nonMappableMap\\{:key\\}\". " - + "Consider to declare/implement a mapping method: .*."), + messageRegExp = "No target bean properties found: can't map Map key \".* nonMappableMap\\{:key\\}\" " + + "to \".* " + + "nonMappableMap\\{:key\\}\". Consider to declare/implement a mapping method: .*." ), @Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class, kind = Kind.ERROR, line = 17, - messageRegExp = "Can't map Map value \".* nonMappableMap\\{:value\\}\" to \".* " + - "nonMappableMap\\{:value\\}\". Consider to declare/implement a mapping method: .*."), + messageRegExp = "No target bean properties found: can't map Map value \".* " + + "nonMappableMap\\{:value\\}\" to \".* nonMappableMap\\{:value\\}\". " + + "Consider to declare/implement a mapping method: .*." ), } ) public void shouldGenerateNonMappleMethodForMapMapping() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/java8stream/erroneous/ErroneousStreamMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/java8stream/erroneous/ErroneousStreamMappingTest.java index e195b037e..dfa9849f0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/java8stream/erroneous/ErroneousStreamMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/java8stream/erroneous/ErroneousStreamMappingTest.java @@ -104,9 +104,10 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousStreamToStreamNoElementMappingFound.class, kind = Kind.ERROR, line = 24, - messageRegExp = "Can't map Stream element \".*WithProperties withProperties\" to \".*NoProperties " + - "noProperties\". Consider to declare/implement a mapping method: \".*NoProperties map\\(" + - ".*WithProperties value\\)") + messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties " + + "withProperties\" to \".*NoProperties noProperties\". " + + "Consider to declare/implement a mapping method: \".*NoProperties " + + "map\\(.*WithProperties value\\)" ) } ) public void shouldFailOnNoElementMappingFoundForStreamToStream() { @@ -136,10 +137,11 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousListToStreamNoElementMappingFound.class, kind = Kind.ERROR, line = 25, - messageRegExp = - "Can't map Stream element \".*WithProperties withProperties\" to \".*NoProperties noProperties\"." + - " Consider to declare/implement a mapping method: \".*NoProperties map\\(.*WithProperties " + - "value\\)") + messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties " + + "withProperties\" to \".*NoProperties noProperties\"." + + " Consider to declare/implement a mapping method: \".*NoProperties map\\(" + + ".*WithProperties " + + "value\\)" ) } ) public void shouldFailOnNoElementMappingFoundForListToStream() { @@ -154,8 +156,9 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousListToStreamNoElementMappingFoundDisabledAuto.class, kind = Kind.ERROR, line = 20, - messageRegExp = "Can't map stream element \".*AttributedString\" to \".*String \". Consider to " + - "declare/implement a mapping method: \".*String map\\(.*AttributedString value\\)") + messageRegExp = "Can't map stream element \".*AttributedString\" to " + + "\".*String \". Consider to declare/implement a mapping method: \".*String " + + "map\\(.*AttributedString value\\)" ) } ) public void shouldFailOnNoElementMappingFoundForListToStreamWithDisabledAuto() { @@ -169,9 +172,10 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousStreamToListNoElementMappingFound.class, kind = Kind.ERROR, line = 25, - messageRegExp = - "Can't map Stream element \".*WithProperties withProperties\" to .*NoProperties noProperties\"." + - " Consider to declare/implement a mapping method: \".*NoProperties map(.*WithProperties value)") + messageRegExp = "No target bean properties found: can't map Stream element \".*WithProperties " + + "withProperties\" to .*NoProperties noProperties\"." + + " Consider to declare/implement a mapping method: \".*NoProperties map(" + + ".*WithProperties value)" ) } ) public void shouldFailOnNoElementMappingFoundForStreamToList() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/java8stream/forged/ForgedStreamMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/java8stream/forged/ForgedStreamMappingTest.java index 3737584a8..67091f579 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/java8stream/forged/ForgedStreamMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/java8stream/forged/ForgedStreamMappingTest.java @@ -70,9 +70,8 @@ public class ForgedStreamMappingTest { @Diagnostic(type = ErroneousStreamNonMappableStreamMapper.class, kind = Kind.ERROR, line = 17, - messageRegExp = "Can't map Stream element \".* nonMappableStream\" to \".* nonMappableStream\". " - + "Consider to declare/implement a mapping method: .*."), - } + messageRegExp = "No target bean properties found: can't map Stream element \".* nonMappableStream\" " + + "to \".* nonMappableStream\". Consider to declare/implement a mapping method: .*." ) } ) public void shouldGenerateNonMappableMethodForSetMapping() { } diff --git a/processor/src/test/java/org/mapstruct/ap/test/selection/generics/ConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/selection/generics/ConversionTest.java index bf3aa6ec0..4b0b824b0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/selection/generics/ConversionTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/selection/generics/ConversionTest.java @@ -85,9 +85,9 @@ public class ConversionTest { diagnostics = { @Diagnostic(type = ErroneousSourceTargetMapper1.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 16, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.UpperBoundWrapper" - + " fooUpperBoundFailure\" to " - + "\"org.mapstruct.ap.test.selection.generics.TypeA fooUpperBoundFailure\"") + messageRegExp = "No target bean properties found: can't map property \"org.mapstruct.ap.test.selection." + + "generics.UpperBoundWrapper " + + "fooUpperBoundFailure\" to \"org.mapstruct.ap.test.selection.generics.TypeA fooUpperBoundFailure\"") }) public void shouldFailOnUpperBound() { } @@ -99,7 +99,8 @@ public class ConversionTest { @Diagnostic(type = ErroneousSourceTargetMapper2.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 16, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardExtendsWrapper" + messageRegExp = "No target bean properties found: can't map property " + + "\"org.mapstruct.ap.test.selection.generics.WildCardExtendsWrapper" + " fooWildCardExtendsTypeAFailure\" to" + " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardExtendsTypeAFailure\"") }) @@ -113,7 +114,8 @@ public class ConversionTest { @Diagnostic(type = ErroneousSourceTargetMapper3.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 16, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics." + messageRegExp = "No target bean properties found: can't map property " + + "\"org.mapstruct.ap.test.selection.generics." + "WildCardExtendsMBWrapper " + "fooWildCardExtendsMBTypeBFailure\" to \"org.mapstruct.ap.test.selection.generics.TypeB " + "fooWildCardExtendsMBTypeBFailure\"") @@ -128,7 +130,8 @@ public class ConversionTest { @Diagnostic(type = ErroneousSourceTargetMapper4.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 16, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" + messageRegExp = "No target bean properties found: can't map property " + + "\"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" + " fooWildCardSuperTypeAFailure\" to" + " \"org.mapstruct.ap.test.selection.generics.TypeA fooWildCardSuperTypeAFailure\"") }) @@ -142,7 +145,8 @@ public class ConversionTest { @Diagnostic(type = ErroneousSourceTargetMapper5.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 16, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" + messageRegExp = "No target bean properties found: can't map property " + + "\"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" + " fooWildCardSuperTypeCFailure\" to" + " \"org.mapstruct.ap.test.selection.generics.TypeC fooWildCardSuperTypeCFailure\"") })