diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/Address.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Address.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/Address.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Address.java index db66dc8b6..ec8e63052 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/Address.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Address.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; public class Address { diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/DeliveryAddress.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/DeliveryAddress.java similarity index 97% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/DeliveryAddress.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/DeliveryAddress.java index 7e06b76bb..a5e04c5d5 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/DeliveryAddress.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/DeliveryAddress.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; public class DeliveryAddress { diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper.java similarity index 88% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper.java index 60649f271..2b96b4b1e 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper2.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper2.java similarity index 89% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper2.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper2.java index d4f9a2585..5d71d120a 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ErroneousSourceTargetMapper2.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ErroneousSourceTargetMapper2.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; import org.mapstruct.Mapper; import org.mapstruct.Mapping; diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/SeveralSourceParametersTest.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ManySourceArgumentsTest.java similarity index 87% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/SeveralSourceParametersTest.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ManySourceArgumentsTest.java index 4ac88be38..2f56517e0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/SeveralSourceParametersTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ManySourceArgumentsTest.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; import static org.assertj.core.api.Assertions.assertThat; @@ -28,7 +28,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; */ @IssueKey("31") @RunWith(AnnotationProcessorTestRunner.class) -public class SeveralSourceParametersTest { +public class ManySourceArgumentsTest { @Before public void reset() { @@ -134,6 +134,29 @@ public class SeveralSourceParametersTest { assertThat( deliveryAddress.getStreet() ).isEqualTo( "Main street" ); } + @IssueKey( "1593" ) + @Test + @WithClasses( { + Person.class, + Address.class, + DeliveryAddress.class, + SourceTargetMapperWithConfig.class, + SourceTargetConfig.class } ) + public void shouldUseConfig() { + Person person = new Person( "Bob", "Garner", 181, "An actor" ); + Address address = new Address( "Main street", 12345, 42, "His address" ); + + DeliveryAddress deliveryAddress = SourceTargetMapperWithConfig.INSTANCE + .personAndAddressToDeliveryAddress( person, address ); + + assertThat( deliveryAddress ).isNotNull(); + assertThat( deliveryAddress.getLastName() ).isEqualTo( "Garner" ); + assertThat( deliveryAddress.getZipCode() ).isEqualTo( 12345 ); + assertThat( deliveryAddress.getHouseNumber() ).isEqualTo( 42 ); + assertThat( deliveryAddress.getDescription() ).isEqualTo( "An actor" ); + + } + @Test @WithClasses({ ErroneousSourceTargetMapper.class, Address.class, DeliveryAddress.class }) @ProcessorOption(name = "mapstruct.unmappedTargetPolicy", value = "IGNORE") diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/Person.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Person.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/Person.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Person.java index fab70df8a..bfe3dc65d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/Person.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/Person.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; public class Person { diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ReferencedMapper.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ReferencedMapper.java similarity index 92% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/ReferencedMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ReferencedMapper.java index 0cd2cf20c..005ef3f4b 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/ReferencedMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/ReferencedMapper.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; import org.mapstruct.BeforeMapping; diff --git a/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetConfig.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetConfig.java new file mode 100644 index 000000000..b64186e6b --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetConfig.java @@ -0,0 +1,18 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package org.mapstruct.ap.test.source.manysourcearguments; + +import org.mapstruct.MapperConfig; +import org.mapstruct.Mapping; + +@MapperConfig +public interface SourceTargetConfig { + + @Mapping(source = "address.houseNo", target = "houseNumber") + @Mapping(source = "person.description", target = "description") + DeliveryAddress personAndAddressToDeliveryAddress(Person person, Address address); + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/severalsources/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapper.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/severalsources/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapper.java index 80a498d07..f9289dc99 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severalsources/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapper.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severalsources; +package org.mapstruct.ap.test.source.manysourcearguments; import org.mapstruct.Mapper; import org.mapstruct.Mapping; diff --git a/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapperWithConfig.java b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapperWithConfig.java new file mode 100644 index 000000000..5b31fe02f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manysourcearguments/SourceTargetMapperWithConfig.java @@ -0,0 +1,20 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package org.mapstruct.ap.test.source.manysourcearguments; + +import org.mapstruct.InheritConfiguration; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper( config = SourceTargetConfig.class ) +public interface SourceTargetMapperWithConfig { + + SourceTargetMapperWithConfig INSTANCE = Mappers.getMapper( SourceTargetMapperWithConfig.class ); + + @InheritConfiguration + DeliveryAddress personAndAddressToDeliveryAddress(Person person, Address address); + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/Source.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Source.java similarity index 91% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/Source.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Source.java index b3b4810fe..f83199c0d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Source.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; /** * @author Sjaak Derksen diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceTargetMapper.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceTargetMapper.java index 9d075ee4c..06084b4e6 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceTargetMapper.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; import org.mapstruct.Mapper; import org.mapstruct.Mapping; diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourcePropertyMapSeveralTimesTest.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceToManyTargetPropertiesTest.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourcePropertyMapSeveralTimesTest.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceToManyTargetPropertiesTest.java index 79b7363f3..2da3dc872 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/SourcePropertyMapSeveralTimesTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/SourceToManyTargetPropertiesTest.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; import static org.assertj.core.api.Assertions.assertThat; @@ -27,7 +27,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; TimeAndFormatMapper.class }) @RunWith(AnnotationProcessorTestRunner.class) -public class SourcePropertyMapSeveralTimesTest { +public class SourceToManyTargetPropertiesTest { @Test @IssueKey("94") diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/Target.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Target.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/Target.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Target.java index 1a66774de..cb755f994 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/Target.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; import java.util.Date; diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormat.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormat.java similarity index 90% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormat.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormat.java index 2884d82c7..3c6d5806c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormat.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormat.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; import java.util.Date; diff --git a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormatMapper.java b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormatMapper.java similarity index 88% rename from processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormatMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormatMapper.java index 219f84d57..4ea9f9296 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/severaltargets/TimeAndFormatMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/source/manytargetproperties/TimeAndFormatMapper.java @@ -3,7 +3,7 @@ * * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 */ -package org.mapstruct.ap.test.severaltargets; +package org.mapstruct.ap.test.source.manytargetproperties; import java.util.Date;