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 c53d9e0a0..1f2aae28e 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 @@ -598,15 +598,12 @@ public class BeanMappingMethod extends MappingMethod { } else { ForgedMethodHistory history = forgedMethod.getHistory(); - while ( history.getPrevHistory() != null ) { - history = history.getPrevHistory(); - } ctx.getMessager().printMessage( this.method.getExecutable(), Message.PROPERTYMAPPING_MAPPING_NOT_FOUND, - history.getSourceElement(), + history.createSourcePropertyErrorMessage(), history.getTargetType(), - history.getTargetPropertyName(), + history.createTargetPropertyName(), history.getTargetType(), history.getSourceType() ); diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/ContainerMappingMethodBuilder.java b/processor/src/main/java/org/mapstruct/ap/internal/model/ContainerMappingMethodBuilder.java index 447583d27..79bb7574a 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/ContainerMappingMethodBuilder.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/ContainerMappingMethodBuilder.java @@ -185,7 +185,14 @@ public abstract class ContainerMappingMethodBuilder builder) { - ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element ); + ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element, "[]" ); ContainerMappingMethod iterableMappingMethod = builder .mappingContext( ctx ) @@ -591,7 +591,7 @@ public class PropertyMapping extends ModelElement { } private ForgedMethod prepareForgedMethod(Type sourceType, Type targetType, SourceRHS source, - ExecutableElement element) { + ExecutableElement element, String suffix) { String name = getName( sourceType, targetType ); name = Strings.getSaveVariableName( name, ctx.getNamesOfMappingsToGenerate() ); @@ -604,19 +604,14 @@ public class PropertyMapping extends ModelElement { config, element, method.getContextParameters(), - new ForgedMethodHistory( getForgedMethodHistory( source ), - source.getSourceErrorMessagePart(), - targetPropertyName, - source.getSourceType(), - targetType - ) + getForgedMethodHistory( source, suffix ) ); } private Assignment forgeMapMapping(Type sourceType, Type targetType, SourceRHS source, ExecutableElement element) { - ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element ); + ForgedMethod methodRef = prepareForgedMethod( sourceType, targetType, source, element, "{}" ); MapMappingMethod.Builder builder = new MapMappingMethod.Builder(); MapMappingMethod mapMappingMethod = builder @@ -669,13 +664,17 @@ public class PropertyMapping extends ModelElement { } private ForgedMethodHistory getForgedMethodHistory(SourceRHS sourceRHS) { + return getForgedMethodHistory( sourceRHS, "" ); + } + + private ForgedMethodHistory getForgedMethodHistory(SourceRHS sourceRHS, String suffix) { ForgedMethodHistory history = null; if ( method instanceof ForgedMethod ) { ForgedMethod method = (ForgedMethod) this.method; history = method.getHistory(); } - return new ForgedMethodHistory( history, sourceRHS.getSourceErrorMessagePart(), - targetPropertyName, sourceRHS.getSourceType(), targetType + return new ForgedMethodHistory( history, getSourceElementName() + suffix, + targetPropertyName + suffix, sourceRHS.getSourceType(), targetType, true, "property" ); } @@ -694,6 +693,20 @@ public class PropertyMapping extends ModelElement { return builder.toString(); } + private String getSourceElementName() { + Parameter sourceParam = sourceReference.getParameter(); + List propertyEntries = sourceReference.getPropertyEntries(); + if ( propertyEntries.isEmpty() ) { + return sourceParam.getName(); + } + else if ( propertyEntries.size() == 1 ) { + PropertyEntry propertyEntry = propertyEntries.get( 0 ); + return propertyEntry.getName(); + } + else { + return Strings.join( sourceReference.getElementNames(), "." ); + } + } } public static class ConstantMappingBuilder extends MappingBuilderBase { diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethodHistory.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethodHistory.java index 2a793e27b..754866baf 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethodHistory.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/ForgedMethodHistory.java @@ -19,6 +19,7 @@ package org.mapstruct.ap.internal.model.source; import org.mapstruct.ap.internal.model.common.Type; +import org.mapstruct.ap.internal.util.Strings; /** * Keeps the context where the ForgedMethod is generated, especially handy with nested forged methods @@ -32,22 +33,18 @@ public class ForgedMethodHistory { private final String targetPropertyName; private final Type targetType; private final Type sourceType; + private final boolean usePropertyNames; + private String elementType; public ForgedMethodHistory(ForgedMethodHistory history, String sourceElement, String targetPropertyName, - Type sourceType, Type targetType) { + Type sourceType, Type targetType, boolean usePropertyNames, String elementType) { prevHistory = history; this.sourceElement = sourceElement; this.targetPropertyName = targetPropertyName; this.sourceType = sourceType; this.targetType = targetType; - } - - public String getSourceElement() { - return sourceElement; - } - - public String getTargetPropertyName() { - return targetPropertyName; + this.usePropertyNames = usePropertyNames; + this.elementType = elementType; } public Type getTargetType() { @@ -58,8 +55,77 @@ public class ForgedMethodHistory { return sourceType; } - public ForgedMethodHistory getPrevHistory() { - return prevHistory; + public String createSourcePropertyErrorMessage() { + return conditionallyCapitalizedElementType() + " \"" + getSourceType() + " " + + stripBrackets( getDottedSourceElement() ) + "\""; } + /** + * Capitalization mostly matters to avoid the funny "Can't map map key" message. However it's irrelevant for the + * "Can't map property" message. + * + * @return capitalized or non-capitalized element type + */ + private String conditionallyCapitalizedElementType() { + if ( "property".equals( elementType ) ) { + return elementType; + } + else { + return Strings.capitalize( elementType ); + } + } + + public String createTargetPropertyName() { + return stripBrackets( getDottedTargetPropertyName() ); + } + + private String getDottedSourceElement() { + if ( prevHistory == null ) { + return sourceElement; + } + else { + if ( usePropertyNames ) { + return getCorrectDottedPath( prevHistory.getDottedSourceElement(), sourceElement ); + } + else { + return prevHistory.getDottedSourceElement(); + } + } + } + + private String getDottedTargetPropertyName() { + if ( prevHistory == null ) { + return targetPropertyName; + } + else { + if ( usePropertyNames ) { + return getCorrectDottedPath( prevHistory.getDottedTargetPropertyName(), targetPropertyName ); + } + else { + return prevHistory.getDottedTargetPropertyName(); + } + + } + } + + private String getCorrectDottedPath(String previousPath, String currentProperty) { + if ( "map key".equals( elementType ) ) { + return stripBrackets( previousPath ) + "{:key}"; + } + else if ( "map value".equals( elementType ) ) { + return stripBrackets( previousPath ) + "{:value}"; + } + else { + return previousPath + "." + currentProperty; + } + } + + private String stripBrackets(String dottedName) { + if ( dottedName.endsWith( "[]" ) || dottedName.endsWith( "{}" ) ) { + dottedName = dottedName.substring( 0, dottedName.length() - 2 ); + } + return dottedName; + } } + + diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/Strings.java b/processor/src/main/java/org/mapstruct/ap/internal/util/Strings.java index 2fc325ba3..4c670b15a 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/util/Strings.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/Strings.java @@ -177,6 +177,17 @@ public class Strings { return identifier.replace( "[]", "Array" ); } + /** + * Returns a stub property name from full class name by stripping away the package and decapitalizing the name + * For example will return {@code fooBar} for {@code com.foo.bar.baz.FooBar} class name + * + * @param fullyQualifiedName fully qualified class name, such as com.foo.bar.baz.FooBar + * @return stup property name, such as fooBar + */ + public static String stubPropertyName(String fullyQualifiedName) { + return Strings.decapitalize( fullyQualifiedName.substring( fullyQualifiedName.lastIndexOf( '.' ) + 1 ) ); + } + /** * It removes the dots from the name and creates an {@link Iterable} from them. * 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 7dfb648d0..5c605a5bc 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 @@ -66,8 +66,8 @@ public class ErroneousCollectionMappingTest { kind = Kind.ERROR, line = 26, messageRegExp = "Can't map property \"java.util.List strings\" to \"int strings\". " - + "Consider to declare/implement a mapping method: \"int map\\(java.util.List" - + " value\\)\"") + + "Consider to declare/implement a mapping method: \"int map\\(java.util.List" + + " value\\)\"") } ) public void shouldFailToGenerateImplementationBetweenCollectionAndPrimitive() { @@ -115,8 +115,9 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoElementMappingFound.class, kind = Kind.ERROR, line = 37, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = + "Can't map Collection element \".*AttributedString attributedString\" to \".*String string\". " + + "Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)") } ) public void shouldFailOnNoElementMappingFound() { @@ -131,8 +132,8 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoKeyMappingFound.class, kind = Kind.ERROR, line = 37, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = "Can't map Map key \".*AttributedString attributedString\" to \".*String string\". " + + "Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)") } ) public void shouldFailOnNoKeyMappingFound() { @@ -147,8 +148,8 @@ public class ErroneousCollectionMappingTest { @Diagnostic(type = ErroneousCollectionNoValueMappingFound.class, kind = Kind.ERROR, line = 37, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = "Can't map Map value \".*AttributedString attributedString\" to \".*String string\". " + + "Consider to declare/implement a mapping method: \".*String map(.*AttributedString 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 3851c94ab..7e650e640 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 @@ -100,7 +100,7 @@ public class CollectionMappingTest { @Diagnostic(type = ErroneousCollectionNonMappableSetMapper.class, kind = Kind.ERROR, line = 30, - messageRegExp = "Can't map property \".* nonMappableSet\" to \".* nonMappableSet\". " + messageRegExp = "Can't map Collection element \".* nonMappableSet\" to \".* nonMappableSet\". " + "Consider to declare/implement a mapping method: .*."), } ) @@ -120,7 +120,7 @@ public class CollectionMappingTest { @Diagnostic(type = ErroneousCollectionNonMappableMapMapper.class, kind = Kind.ERROR, line = 30, - messageRegExp = "Can't map property \".* nonMappableMap\" to \".* nonMappableMap\". " + messageRegExp = "Can't map Map key \".* nonMappableMap\\{:key\\}\" to \".* nonMappableMap\\{:key\\}\". " + "Consider to declare/implement a mapping method: .*."), } ) 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 b743092cb..093eb75c8 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 @@ -115,8 +115,8 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousStreamToStreamNoElementMappingFound.class, kind = Kind.ERROR, line = 36, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = "Can't map Stream element .*AttributedString attributedString\" to .*String string\"." + + " Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)") } ) public void shouldFailOnNoElementMappingFoundForStreamToStream() { @@ -130,8 +130,8 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousListToStreamNoElementMappingFound.class, kind = Kind.ERROR, line = 37, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = "Can't map .*AttributedString attributedString\" to .*String string\". " + + "Consider to declare/implement a mapping method: \".*String map(.*AttributedString value)") } ) public void shouldFailOnNoElementMappingFoundForListToStream() { @@ -145,8 +145,8 @@ public class ErroneousStreamMappingTest { @Diagnostic(type = ErroneousStreamToListNoElementMappingFound.class, kind = Kind.ERROR, line = 37, - messageRegExp = "Can't map .*AttributedString to .*String. " + - "Consider to implement a mapping method: \".*String map(.*AttributedString value)") + messageRegExp = "Can't map Stream element .*AttributedString attributedString\" to .*String string\"." + + " Consider to declare/implement a mapping method: \".*String map(.*AttributedString 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 d791519d3..16f837942 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 @@ -83,7 +83,7 @@ public class ForgedStreamMappingTest { @Diagnostic(type = ErroneousStreamNonMappableStreamMapper.class, kind = Kind.ERROR, line = 30, - messageRegExp = "Can't map property \".* nonMappableStream\" to \".* nonMappableStream\". " + messageRegExp = "Can't map Stream element \".* nonMappableStream\" to \".* nonMappableStream\". " + "Consider to declare/implement a mapping method: .*."), } ) diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/DottedErrorMessageTest.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/DottedErrorMessageTest.java new file mode 100644 index 000000000..c3923e6df --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/DottedErrorMessageTest.java @@ -0,0 +1,186 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans; + +import org.junit.Test; + +import org.junit.runner.RunWith; +import org.mapstruct.ap.test.nestedbeans.erroneous.Computer; +import org.mapstruct.ap.test.nestedbeans.erroneous.ComputerDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Dictionary; +import org.mapstruct.ap.test.nestedbeans.erroneous.DictionaryDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.ForeignWord; +import org.mapstruct.ap.test.nestedbeans.erroneous.ForeignWordDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Cat; +import org.mapstruct.ap.test.nestedbeans.erroneous.CatDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Info; +import org.mapstruct.ap.test.nestedbeans.erroneous.InfoDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableCollectionElementPropertyMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepListMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepMapKeyMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepMapValueMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableValuePropertyMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.UserDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.User; +import org.mapstruct.ap.test.nestedbeans.erroneous.WheelDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Wheel; +import org.mapstruct.ap.test.nestedbeans.erroneous.Car; +import org.mapstruct.ap.test.nestedbeans.erroneous.CarDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.House; +import org.mapstruct.ap.test.nestedbeans.erroneous.HouseDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Color; +import org.mapstruct.ap.test.nestedbeans.erroneous.ColorDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.Roof; +import org.mapstruct.ap.test.nestedbeans.erroneous.RoofDto; +import org.mapstruct.ap.test.nestedbeans.erroneous.UnmappableDeepNestingMapper; +import org.mapstruct.ap.test.nestedbeans.erroneous.Word; +import org.mapstruct.ap.test.nestedbeans.erroneous.WordDto; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; +import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; +import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; +import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; + +@WithClasses({ + Car.class, CarDto.class, Color.class, ColorDto.class, + House.class, HouseDto.class, Roof.class, RoofDto.class, + User.class, UserDto.class, Wheel.class, WheelDto.class, + Dictionary.class, DictionaryDto.class, Word.class, WordDto.class, + ForeignWord.class, ForeignWordDto.class, + Computer.class, ComputerDto.class, + Cat.class, CatDto.class, Info.class, InfoDto.class +}) +@RunWith(AnnotationProcessorTestRunner.class) +public class DottedErrorMessageTest { + + private static final String PROPERTY = "property"; + private static final String COLLECTION_ELEMENT = "Collection element"; + private static final String MAP_KEY = "Map key"; + private static final String MAP_VALUE = "Map value"; + + @Test + @WithClasses({ + UnmappableDeepNestingMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableDeepNestingMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + PROPERTY + + " \".*Color house\\.roof\\.color\" to \".*house\\.roof\\.color\"\\. " + + "Consider to declare/implement a mapping method: \".*ColorDto map\\(.*Color value\\)\"\\.") + } + ) + public void testDeepNestedBeans() { + } + + @Test + @WithClasses({ + UnmappableDeepListMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableDeepListMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + COLLECTION_ELEMENT + + " \".*Wheel car\\.wheels\" to \".*car\\.wheels\"\\. " + + "Consider to declare/implement a mapping method: \".*WheelDto map\\(.*Wheel value\\)\"\\.") + } + ) + public void testIterables() { + } + + @Test + @WithClasses({ + UnmappableDeepMapKeyMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableDeepMapKeyMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + MAP_KEY + + " \".*Word dictionary\\.wordMap\\{:key\\}\" to \".*dictionary\\.wordMap\\{:key\\}\"\\. " + + "Consider to declare/implement a mapping method: \".*WordDto map\\(.*Word value\\)\"\\.") + } + ) + public void testMapKeys() { + } + + @Test + @WithClasses({ + UnmappableDeepMapValueMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableDeepMapValueMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + MAP_VALUE + + " \".*ForeignWord dictionary\\.wordMap\\{:value\\}\" " + + "to \".*dictionary\\.wordMap\\{:value\\}\"\\. " + + "Consider to declare/implement a mapping method: " + + "\".*ForeignWordDto map\\(.*ForeignWord value\\)\"\\.") + } + ) + public void testMapValues() { + } + + @Test + @WithClasses({ + UnmappableCollectionElementPropertyMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableCollectionElementPropertyMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + PROPERTY + + " \".*Info computers\\[\\].info\" to \".*computers\\[\\].info\"\\. " + + "Consider to declare/implement a mapping method: \".*InfoDto map\\(.*Info value\\)\"\\.") + } + ) + public void testCollectionElementProperty() { + } + + @Test + @WithClasses({ + UnmappableValuePropertyMapper.class + }) + @ExpectedCompilationOutcome( + value = CompilationResult.FAILED, + diagnostics = { + @Diagnostic(type = UnmappableValuePropertyMapper.class, + kind = javax.tools.Diagnostic.Kind.ERROR, + line = 26, + messageRegExp = "Can't map " + PROPERTY + + " \".*Info catNameMap\\{:value\\}.info\" to \".*catNameMap\\{:value\\}.info\"\\. " + + "Consider to declare/implement a mapping method: \".*InfoDto map\\(.*Info value\\)\"\\.") + } + ) + public void testMapValueProperty() { + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Car.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Car.java new file mode 100644 index 000000000..b74ed368e --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Car.java @@ -0,0 +1,53 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.List; + +public class Car { + + private String name; + private int year; + private List wheels; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public List getWheels() { + return wheels; + } + + public void setWheels(List wheels) { + this.wheels = wheels; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CarDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CarDto.java new file mode 100644 index 000000000..d8c9a80e6 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CarDto.java @@ -0,0 +1,53 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.List; + +public class CarDto { + + private String name; + private int year; + private List wheels; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public List getWheels() { + return wheels; + } + + public void setWheels(List wheels) { + this.wheels = wheels; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Cat.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Cat.java new file mode 100644 index 000000000..c5ed659ba --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Cat.java @@ -0,0 +1,33 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Cat { + + private Info info; + + public Info getInfo() { + return info; + } + + public void setInfo(Info info) { + this.info = info; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CatDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CatDto.java new file mode 100644 index 000000000..cf3321730 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/CatDto.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class CatDto { + + private InfoDto info; + + public InfoDto getInfo() { + return info; + } + + public void setInfo(InfoDto info) { + this.info = info; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Color.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Color.java new file mode 100644 index 000000000..eddc7dfe7 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Color.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Color { + private String cmyk; + + public Color() { + } + + public Color(String cmyk) { + this.cmyk = cmyk; + } + + public String getCmyk() { + return cmyk; + } + + public void setCmyk(String cmyk) { + this.cmyk = cmyk; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ColorDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ColorDto.java new file mode 100644 index 000000000..30eb26140 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ColorDto.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class ColorDto { + private String rgb; + + public String getRgb() { + return rgb; + } + + public void setRgb(String rgb) { + this.rgb = rgb; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Computer.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Computer.java new file mode 100644 index 000000000..6cd2bee32 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Computer.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Computer { + + private Info info; + + public Info getInfo() { + return info; + } + + public void setInfo(Info info) { + this.info = info; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ComputerDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ComputerDto.java new file mode 100644 index 000000000..660ec226f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ComputerDto.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class ComputerDto { + + private InfoDto info; + + public InfoDto getInfo() { + return info; + } + + public void setInfo(InfoDto info) { + this.info = info; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Dictionary.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Dictionary.java new file mode 100644 index 000000000..3ac5a27f5 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Dictionary.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.Map; + +public class Dictionary { + + private Map wordMap; + + public Map getWordMap() { + return wordMap; + } + + public void setWordMap( + Map wordMap) { + this.wordMap = wordMap; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/DictionaryDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/DictionaryDto.java new file mode 100644 index 000000000..21e55f7d5 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/DictionaryDto.java @@ -0,0 +1,35 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.Map; + +public class DictionaryDto { + + private Map wordMap; + + public Map getWordMap() { + return wordMap; + } + + public void setWordMap( + Map wordMap) { + this.wordMap = wordMap; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWord.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWord.java new file mode 100644 index 000000000..1b94862d8 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWord.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class ForeignWord { + + private String meaning; + + public String getMeaning() { + return meaning; + } + + public void setMeaning(String meaning) { + this.meaning = meaning; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWordDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWordDto.java new file mode 100644 index 000000000..3f64cc9c0 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/ForeignWordDto.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class ForeignWordDto { + private String pronunciation; + + public String getPronunciation() { + return pronunciation; + } + + public void setPronunciation(String pronunciation) { + this.pronunciation = pronunciation; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/House.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/House.java new file mode 100644 index 000000000..0f7ae15dc --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/House.java @@ -0,0 +1,51 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class House { + + private String name; + private int year; + private Roof roof; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public Roof getRoof() { + return roof; + } + + public void setRoof(Roof roof) { + this.roof = roof; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/HouseDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/HouseDto.java new file mode 100644 index 000000000..19e95b637 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/HouseDto.java @@ -0,0 +1,51 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class HouseDto { + + private String name; + private int year; + private RoofDto roof; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } + + public RoofDto getRoof() { + return roof; + } + + public void setRoof(RoofDto roof) { + this.roof = roof; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Info.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Info.java new file mode 100644 index 000000000..8bbb21d40 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Info.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Info { + private String size; + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/InfoDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/InfoDto.java new file mode 100644 index 000000000..b8a804aef --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/InfoDto.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class InfoDto { + private String color; + + public String getColor() { + return color; + } + + public void setColor(String color) { + this.color = color; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Roof.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Roof.java new file mode 100644 index 000000000..b62268a41 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Roof.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Roof { + private Color color; + + public Color getColor() { + return color; + } + + public void setColor(Color color) { + this.color = color; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/RoofDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/RoofDto.java new file mode 100644 index 000000000..3768fd44d --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/RoofDto.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class RoofDto { + private ColorDto color; + + public ColorDto getColor() { + return color; + } + + public void setColor(ColorDto color) { + this.color = color; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableCollectionElementPropertyMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableCollectionElementPropertyMapper.java new file mode 100644 index 000000000..1fb4f584c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableCollectionElementPropertyMapper.java @@ -0,0 +1,43 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableCollectionElementPropertyMapper { + + abstract UserDto userToUserDto(User user); + + public HouseDto map(House house) { + return new HouseDto(); + } + + public CarDto map(Car carDto) { + return new CarDto(); + } + + public DictionaryDto map(Dictionary dictionary) { + return new DictionaryDto(); + } + + public CatDto map(Cat cat) { + return new CatDto(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepListMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepListMapper.java new file mode 100644 index 000000000..78d6faabf --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepListMapper.java @@ -0,0 +1,43 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableDeepListMapper { + + abstract UserDto userToUserDto(User user); + + public HouseDto map(House house) { + return new HouseDto(); + } + + public DictionaryDto map(Dictionary dictionary) { + return new DictionaryDto(); + } + + public ComputerDto map(Computer computer) { + return new ComputerDto(); + } + + public CatDto map(Cat cat) { + return new CatDto(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapKeyMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapKeyMapper.java new file mode 100644 index 000000000..00fe65b56 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapKeyMapper.java @@ -0,0 +1,48 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableDeepMapKeyMapper { + + abstract UserDto userToUserDto(User user); + + public CarDto map(Car carDto) { + return new CarDto(); + } + + public HouseDto map(House house) { + return new HouseDto(); + } + + public ForeignWordDto map(ForeignWord word) { + return new ForeignWordDto(); + } + + public ComputerDto map(Computer computer) { + return new ComputerDto(); + } + + public CatDto map(Cat cat) { + return new CatDto(); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapValueMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapValueMapper.java new file mode 100644 index 000000000..a2aafa267 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepMapValueMapper.java @@ -0,0 +1,48 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableDeepMapValueMapper { + + abstract UserDto userToUserDto(User user); + + public CarDto map(Car carDto) { + return new CarDto(); + } + + public HouseDto map(House house) { + return new HouseDto(); + } + + public WordDto map(Word word) { + return new WordDto(); + } + + public ComputerDto map(Computer computer) { + return new ComputerDto(); + } + + public CatDto map(Cat cat) { + return new CatDto(); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepNestingMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepNestingMapper.java new file mode 100644 index 000000000..a01896cad --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableDeepNestingMapper.java @@ -0,0 +1,44 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableDeepNestingMapper { + + abstract UserDto userToUserDto(User user); + + public CarDto map(Car carDto) { + return new CarDto(); + } + + public DictionaryDto map(Dictionary dictionary) { + return new DictionaryDto(); + } + + public ComputerDto map(Computer computer) { + return new ComputerDto(); + } + + public CatDto map(Cat cat) { + return new CatDto(); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableValuePropertyMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableValuePropertyMapper.java new file mode 100644 index 000000000..40f79307c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UnmappableValuePropertyMapper.java @@ -0,0 +1,43 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import org.mapstruct.Mapper; + +@Mapper +public abstract class UnmappableValuePropertyMapper { + + abstract UserDto userToUserDto(User user); + + public HouseDto map(House house) { + return new HouseDto(); + } + + public CarDto map(Car carDto) { + return new CarDto(); + } + + public DictionaryDto map(Dictionary dictionary) { + return new DictionaryDto(); + } + + public ComputerDto map(Computer computer) { + return new ComputerDto(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/User.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/User.java new file mode 100644 index 000000000..10ce16b70 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/User.java @@ -0,0 +1,85 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.List; +import java.util.Map; + +public class User { + + private String name; + //list of Wheels inside + private Car car; + //deep nesting inside Roof->Color + private House house; + //unmappable keys/values + private Dictionary dictionary; + //collection element's property can't be mapped + private List computers; + //map value property can't be mapped + private Map catNameMap; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Car getCar() { + return car; + } + + public void setCar(Car car) { + this.car = car; + } + + public House getHouse() { + return house; + } + + public void setHouse(House house) { + this.house = house; + } + + public Dictionary getDictionary() { + return dictionary; + } + + public void setDictionary(Dictionary dictionary) { + this.dictionary = dictionary; + } + + public List getComputers() { + return computers; + } + + public void setComputers(List computers) { + this.computers = computers; + } + + public Map getCatNameMap() { + return catNameMap; + } + + public void setCatNameMap(Map catNameMap) { + this.catNameMap = catNameMap; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UserDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UserDto.java new file mode 100644 index 000000000..9f0048b12 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/UserDto.java @@ -0,0 +1,81 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +import java.util.List; +import java.util.Map; + +public class UserDto { + + private String name; + private CarDto car; + private HouseDto house; + private DictionaryDto dictionary; + private List computers; + private Map catNameMap; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CarDto getCar() { + return car; + } + + public void setCar(CarDto car) { + this.car = car; + } + + public HouseDto getHouse() { + return house; + } + + public void setHouse(HouseDto house) { + this.house = house; + } + + public DictionaryDto getDictionary() { + return dictionary; + } + + public void setDictionary(DictionaryDto dictionary) { + this.dictionary = dictionary; + } + + public List getComputers() { + return computers; + } + + public void setComputers(List computers) { + this.computers = computers; + } + + public Map getCatNameMap() { + return catNameMap; + } + + public void setCatNameMap( + Map catNameMap) { + this.catNameMap = catNameMap; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Wheel.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Wheel.java new file mode 100644 index 000000000..1c7102a6c --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Wheel.java @@ -0,0 +1,41 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Wheel { + private boolean front; + private boolean right; + + public boolean isFront() { + return front; + } + + public void setFront(boolean front) { + this.front = front; + } + + public boolean isRight() { + return right; + } + + public void setRight(boolean right) { + this.right = right; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WheelDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WheelDto.java new file mode 100644 index 000000000..7e185b073 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WheelDto.java @@ -0,0 +1,40 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class WheelDto { + private boolean front; + private boolean left; + + public boolean isFront() { + return front; + } + + public void setFront(boolean front) { + this.front = front; + } + + public boolean isLeft() { + return left; + } + + public void setLeft(boolean left) { + this.left = left; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Word.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Word.java new file mode 100644 index 000000000..b27767783 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/Word.java @@ -0,0 +1,32 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class Word { + + private String meaning; + + public String getMeaning() { + return meaning; + } + + public void setMeaning(String meaning) { + this.meaning = meaning; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WordDto.java b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WordDto.java new file mode 100644 index 000000000..fdce91ef2 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/nestedbeans/erroneous/WordDto.java @@ -0,0 +1,31 @@ +/** + * Copyright 2012-2017 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.nestedbeans.erroneous; + +public class WordDto { + private String pronunciation; + + public String getPronunciation() { + return pronunciation; + } + + public void setPronunciation(String pronunciation) { + this.pronunciation = pronunciation; + } +} 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 b28350da1..9398e634b 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 @@ -168,10 +168,10 @@ public class ConversionTest { @Diagnostic(type = ErroneousSourceTargetMapper6.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 29, - messageRegExp = "Can't map property \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" - + " foo\" to" - + " \"org.mapstruct.ap.test.selection.generics.WildCardSuperWrapper" + - " foo\"") + messageRegExp = "Can't map property \"java.lang.String " + + "foo\\.wrapped\" to" + + " \"org.mapstruct.ap.test.selection.generics.TypeA " + + "foo\\.wrapped\"") }) public void shouldFailOnNonMatchingWildCards() { }