diff --git a/integrationtest/src/test/java/org/mapstruct/itest/tests/FullFeatureCompilationTest.java b/integrationtest/src/test/java/org/mapstruct/itest/tests/FullFeatureCompilationTest.java new file mode 100644 index 000000000..328d5f819 --- /dev/null +++ b/integrationtest/src/test/java/org/mapstruct/itest/tests/FullFeatureCompilationTest.java @@ -0,0 +1,92 @@ +/** + * Copyright 2012-2015 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.itest.tests; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.junit.runner.RunWith; +import org.mapstruct.itest.tests.FullFeatureCompilationTest.CompilationExclusionCliEnhancer; +import org.mapstruct.itest.testutil.runner.ProcessorSuite; +import org.mapstruct.itest.testutil.runner.ProcessorSuite.CommandLineEnhancer; +import org.mapstruct.itest.testutil.runner.ProcessorSuite.ProcessorType; +import org.mapstruct.itest.testutil.runner.ProcessorSuiteRunner; + +/** + * Integration test that compiles all test mappers in the processor-module, excluding all classes that contain one of + * the following in their path/file name: + * + * + * @author Andreas Gudian + */ +@RunWith(ProcessorSuiteRunner.class) +@ProcessorSuite( + baseDir = "fullFeatureTest", + commandLineEnhancer = CompilationExclusionCliEnhancer.class, + processorTypes = { + ProcessorType.ORACLE_JAVA_6, + ProcessorType.ORACLE_JAVA_7, + ProcessorType.ORACLE_JAVA_8, + ProcessorType.ORACLE_JAVA_9, + ProcessorType.ECLIPSE_JDT_JAVA_6, + ProcessorType.ECLIPSE_JDT_JAVA_7, + ProcessorType.ECLIPSE_JDT_JAVA_8 +}) +public class FullFeatureCompilationTest { + /** + * Adds explicit exclusions of test mappers that are known or expected to not work with specific compilers. + * + * @author Andreas Gudian + */ + public static final class CompilationExclusionCliEnhancer implements CommandLineEnhancer { + @Override + public Collection getAdditionalCommandLineArguments(ProcessorType processorType) { + List additionalExcludes = new ArrayList<>(); + + switch ( processorType ) { + case ORACLE_JAVA_6: + additionalExcludes.add( "org/mapstruct/ap/test/abstractclass/generics/*.java" ); + case ECLIPSE_JDT_JAVA_6: + case ORACLE_JAVA_7: + case ECLIPSE_JDT_JAVA_7: + additionalExcludes.add( "**/java8*/**/*.java" ); + break; + case ORACLE_JAVA_9: + // TODO find out why this fails: + additionalExcludes.add( "org/mapstruct/ap/test/collection/wildcard/BeanMapper.java" ); + break; + default: + } + + Collection result = new ArrayList( additionalExcludes.size() ); + for ( int i = 0; i < additionalExcludes.size(); i++ ) { + result.add( "-DadditionalExclude" + i + "=" + additionalExcludes.get( i ) ); + } + + return result; + } + } +} diff --git a/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuite.java b/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuite.java index 27d59a515..de3b2e7cf 100644 --- a/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuite.java +++ b/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuite.java @@ -23,6 +23,9 @@ import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.Collection; + +import org.apache.maven.it.Verifier; /** * Declares the content of the integration test. @@ -69,6 +72,12 @@ public @interface ProcessorSuite { */ ORACLE_JAVA_9( new Toolchain( "oracle", "9", "10" ), "javac", "1.9" ), + /** + * Use the eclipse compiler with 1.6 source/target level from tycho-compiler-jdt to perform the build and + * processing + */ + ECLIPSE_JDT_JAVA_6( null, "jdt", "1.6" ), + /** * Use the eclipse compiler with 1.7 source/target level from tycho-compiler-jdt to perform the build and * processing @@ -90,8 +99,8 @@ public @interface ProcessorSuite { /** * Use all available processing variants */ - ALL( ORACLE_JAVA_6, ORACLE_JAVA_7, ORACLE_JAVA_8, ORACLE_JAVA_9, ECLIPSE_JDT_JAVA_7, ECLIPSE_JDT_JAVA_8, - PROCESSOR_PLUGIN_JAVA_8 ), + ALL( ORACLE_JAVA_6, ORACLE_JAVA_7, ORACLE_JAVA_8, ORACLE_JAVA_9, ECLIPSE_JDT_JAVA_6, ECLIPSE_JDT_JAVA_7, + ECLIPSE_JDT_JAVA_8, PROCESSOR_PLUGIN_JAVA_8 ), /** * Use all JDK8 compatible processing variants @@ -143,6 +152,20 @@ public @interface ProcessorSuite { } } + /** + * Can be configured to provide additional command line arguments for the invoked Maven process, depending on the + * {@link ProcessorType} the test is executed for. + * + * @author Andreas Gudian + */ + public interface CommandLineEnhancer { + /** + * @param processorType the processor type for which the test is executed. + * @return additional command line arguments to be passed to the Maven {@link Verifier}. + */ + Collection getAdditionalCommandLineArguments(ProcessorType processorType); + } + /** * @return a path in the classpath that contains the maven module to run as integration test: {@code mvn clean test} */ @@ -152,4 +175,9 @@ public @interface ProcessorSuite { * @return the variants to execute the integration tests with. See {@link ProcessorType}. */ ProcessorType[] processorTypes() default { ProcessorType.ALL }; + + /** + * @return the {@link CommandLineEnhancer} implementation. Must have a default constructor. + */ + Class commandLineEnhancer() default CommandLineEnhancer.class; } diff --git a/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuiteRunner.java b/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuiteRunner.java index 2687c4335..6ee3d8e97 100644 --- a/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuiteRunner.java +++ b/integrationtest/src/test/java/org/mapstruct/itest/testutil/runner/ProcessorSuiteRunner.java @@ -18,13 +18,10 @@ */ package org.mapstruct.itest.testutil.runner; -import static org.apache.maven.it.util.ResourceExtractor.extractResourceToDestination; -import static org.apache.maven.shared.utils.io.FileUtils.copyURLToFile; -import static org.apache.maven.shared.utils.io.FileUtils.deleteDirectory; - import java.io.File; import java.io.IOException; import java.io.PrintStream; +import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -43,11 +40,16 @@ import org.junit.runner.notification.RunNotifier; import org.junit.runner.notification.StoppedByUserException; import org.junit.runners.ParentRunner; import org.junit.runners.model.InitializationError; +import org.mapstruct.itest.testutil.runner.ProcessorSuite.CommandLineEnhancer; import org.mapstruct.itest.testutil.runner.ProcessorSuite.ProcessorType; import org.mapstruct.itest.testutil.runner.ProcessorSuiteRunner.ProcessorTestCase; import org.mapstruct.itest.testutil.runner.xml.Toolchains; import org.mapstruct.itest.testutil.runner.xml.Toolchains.ProviderDescription; +import static org.apache.maven.it.util.ResourceExtractor.extractResourceToDestination; +import static org.apache.maven.shared.utils.io.FileUtils.copyURLToFile; +import static org.apache.maven.shared.utils.io.FileUtils.deleteDirectory; + /** * Runner for processor integration tests. Requires the annotation {@link ProcessorSuite} on the test class. * @@ -73,10 +75,13 @@ public class ProcessorSuiteRunner extends ParentRunner { private final String baseDir; private final ProcessorType processor; private final boolean ignored; + private final Constructor cliEnhancerConstructor; - public ProcessorTestCase(String baseDir, ProcessorType processor) { + public ProcessorTestCase(String baseDir, ProcessorType processor, + Constructor cliEnhancerConstructor) { this.baseDir = baseDir; this.processor = processor; + this.cliEnhancerConstructor = cliEnhancerConstructor; this.ignored = !ENABLED_PROCESSOR_TYPES.contains( processor ); } } @@ -100,10 +105,25 @@ public class ProcessorSuiteRunner extends ParentRunner { throw new InitializationError( "ProcessorSuite#processorTypes must not be empty" ); } - methods = initializeTestCases( suite ); + Constructor cliEnhancerConstructor = null; + if ( suite.commandLineEnhancer() != CommandLineEnhancer.class ) { + try { + cliEnhancerConstructor = suite.commandLineEnhancer().getConstructor(); + } + catch ( NoSuchMethodException e ) { + throw new InitializationError( + suite.commandLineEnhancer().getName() + " does not have a default constructor." ); + } + catch ( SecurityException e ) { + throw new InitializationError( e ); + } + } + + methods = initializeTestCases( suite, cliEnhancerConstructor ); } - private List initializeTestCases(ProcessorSuite suite) { + private List initializeTestCases(ProcessorSuite suite, + Constructor cliEnhancerConstructor) { List types = new ArrayList(); for ( ProcessorType compiler : suite.processorTypes() ) { @@ -118,7 +138,7 @@ public class ProcessorSuiteRunner extends ParentRunner { List result = new ArrayList( types.size() ); for ( ProcessorType type : types ) { - result.add( new ProcessorTestCase( suite.baseDir(), type ) ); + result.add( new ProcessorTestCase( suite.baseDir(), type, cliEnhancerConstructor ) ); } return result; @@ -208,6 +228,8 @@ public class ProcessorSuiteRunner extends ParentRunner { goals.add( "test" ); + addAdditionalCliArguments( child, verifier ); + originalOut.println( "executing " + child.processor.name().toLowerCase() ); verifier.executeGoals( goals ); @@ -218,6 +240,19 @@ public class ProcessorSuiteRunner extends ParentRunner { } } + private void addAdditionalCliArguments(ProcessorTestCase child, final Verifier verifier) throws Exception { + if ( child.cliEnhancerConstructor != null ) { + CommandLineEnhancer enhancer = child.cliEnhancerConstructor.newInstance(); + Collection additionalArgs = enhancer.getAdditionalCommandLineArguments( child.processor ); + + if ( additionalArgs != null ) { + for ( String arg : additionalArgs ) { + verifier.addCliOption( arg ); + } + } + } + } + private void configureProcessor(ProcessorTestCase child, Verifier verifier) { if ( child.processor.getCompilerId() != null ) { verifier.addCliOption( "-Pgenerate-via-compiler-plugin" ); diff --git a/integrationtest/src/test/resources/fullFeatureTest/pom.xml b/integrationtest/src/test/resources/fullFeatureTest/pom.xml new file mode 100644 index 000000000..2fd2df0ab --- /dev/null +++ b/integrationtest/src/test/resources/fullFeatureTest/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + + org.mapstruct + mapstruct-it-parent + 1.0.0 + ../pom.xml + + + fullFeatureTest + jar + + + x + x + x + x + + + + ../../../../../processor/src/test/java + + + org.apache.maven.plugins + maven-compiler-plugin + + + **/erroneous/**/*.java + **/*Erroneous*.java + **/*Test.java + **/testutil/**/*.java + ${additionalExclude0} + ${additionalExclude1} + ${additionalExclude2} + ${additionalExclude3} + + + + + + + + + com.google.guava + guava + + + javax.inject + javax.inject + + + + + org.springframework + spring-beans + + + org.springframework + spring-context + + + + joda-time + joda-time + + + diff --git a/integrationtest/src/test/resources/fullFeatureTest/src/test/java/org/mapstruct/itest/simple/AnimalTest.java b/integrationtest/src/test/resources/fullFeatureTest/src/test/java/org/mapstruct/itest/simple/AnimalTest.java new file mode 100644 index 000000000..668e2c043 --- /dev/null +++ b/integrationtest/src/test/resources/fullFeatureTest/src/test/java/org/mapstruct/itest/simple/AnimalTest.java @@ -0,0 +1,72 @@ +/** + * Copyright 2012-2015 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.ignore; + +import static org.fest.assertions.Assertions.assertThat; + +import org.junit.Test; + +import org.mapstruct.ap.test.ignore.AnimalMapper; +import org.mapstruct.ap.test.ignore.Animal; +import org.mapstruct.ap.test.ignore.AnimalDto; + +/** + * Test for ignoring properties during the mapping. + * + * @author Gunnar Morling + */ +public class AnimalTest { + + @Test + public void shouldNotPropagateIgnoredPropertyGivenViaTargetAttribute() { + Animal animal = new Animal( "Bruno", 100, 23, "black" ); + + AnimalDto animalDto = AnimalMapper.INSTANCE.animalToDto( animal ); + + assertThat( animalDto ).isNotNull(); + assertThat( animalDto.getName() ).isEqualTo( "Bruno" ); + assertThat( animalDto.getSize() ).isEqualTo( 100 ); + assertThat( animalDto.getAge() ).isNull(); + assertThat( animalDto.getColor() ).isNull(); + } + + @Test + public void shouldNotPropagateIgnoredPropertyInReverseMappingWhenNameIsSame() { + AnimalDto animalDto = new AnimalDto( "Bruno", 100, 23, "black" ); + + Animal animal = AnimalMapper.INSTANCE.animalDtoToAnimal( animalDto ); + + assertThat( animal ).isNotNull(); + assertThat( animalDto.getName() ).isEqualTo( "Bruno" ); + assertThat( animalDto.getSize() ).isEqualTo( 100 ); + assertThat( animal.getAge() ).isNull(); + } + + @Test + public void shouldNotPropagateIgnoredPropertyInReverseMappingWhenSourceAndTargetAreSpecified() { + AnimalDto animalDto = new AnimalDto( "Bruno", 100, 23, "black" ); + + Animal animal = AnimalMapper.INSTANCE.animalDtoToAnimal( animalDto ); + + assertThat( animal ).isNotNull(); + assertThat( animalDto.getName() ).isEqualTo( "Bruno" ); + assertThat( animalDto.getSize() ).isEqualTo( 100 ); + assertThat( animal.getColour() ).isNull(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousAbstractSourceTargetMapperPrivate.java similarity index 80% rename from processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java rename to processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousAbstractSourceTargetMapperPrivate.java index 546b74199..642822ba9 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/AbstractSourceTargetMapperPrivate.java +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousAbstractSourceTargetMapperPrivate.java @@ -27,10 +27,10 @@ import org.mapstruct.factory.Mappers; * @author Sjaak Derksen */ @Mapper -public abstract class AbstractSourceTargetMapperPrivate extends SourceTargetmapperPrivateBase { +public abstract class ErroneousAbstractSourceTargetMapperPrivate extends SourceTargetmapperPrivateBase { - public static final AbstractSourceTargetMapperPrivate INSTANCE = - Mappers.getMapper( AbstractSourceTargetMapperPrivate.class ); + public static final ErroneousAbstractSourceTargetMapperPrivate INSTANCE = + Mappers.getMapper( ErroneousAbstractSourceTargetMapperPrivate.class ); @Mapping(source = "referencedSource", target = "referencedTarget") public abstract Target toTarget(Source source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperDefaultOther.java similarity index 86% rename from processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java rename to processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperDefaultOther.java index 546af2db2..382753fbe 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperDefaultOther.java +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperDefaultOther.java @@ -28,9 +28,10 @@ import org.mapstruct.factory.Mappers; * @author Sjaak Derksen */ @Mapper(uses = ReferencedMapperDefaultOther.class) -public interface SourceTargetMapperDefaultOther { +public interface ErroneousSourceTargetMapperDefaultOther { - SourceTargetMapperDefaultOther INSTANCE = Mappers.getMapper( SourceTargetMapperDefaultOther.class ); + ErroneousSourceTargetMapperDefaultOther INSTANCE = + Mappers.getMapper( ErroneousSourceTargetMapperDefaultOther.class ); @Mapping(source = "referencedSource", target = "referencedTarget") Target toTarget(Source source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperPrivate.java similarity index 87% rename from processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java rename to processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperPrivate.java index 4072eab8a..64bff46d9 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/SourceTargetMapperPrivate.java +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ErroneousSourceTargetMapperPrivate.java @@ -27,9 +27,9 @@ import org.mapstruct.factory.Mappers; * @author Sjaak Derksen */ @Mapper(uses = ReferencedMapperPrivate.class) -public interface SourceTargetMapperPrivate { +public interface ErroneousSourceTargetMapperPrivate { - SourceTargetMapperPrivate INSTANCE = Mappers.getMapper( SourceTargetMapperPrivate.class ); + ErroneousSourceTargetMapperPrivate INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapperPrivate.class ); @Mapping(source = "referencedSource", target = "referencedTarget") Target toTarget(Source source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java index 48ee68887..53dccc033 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/accessibility/referenced/ReferencedAccessibilityTest.java @@ -39,11 +39,11 @@ public class ReferencedAccessibilityTest { @Test @IssueKey( "206" ) - @WithClasses( { SourceTargetMapperPrivate.class, ReferencedMapperPrivate.class } ) + @WithClasses( { ErroneousSourceTargetMapperPrivate.class, ReferencedMapperPrivate.class } ) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = SourceTargetMapperPrivate.class, + @Diagnostic( type = ErroneousSourceTargetMapperPrivate.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 35, messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." @@ -65,13 +65,13 @@ public class ReferencedAccessibilityTest { @Test @IssueKey( "206" ) - @WithClasses( { SourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } ) + @WithClasses( { ErroneousSourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } ) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = SourceTargetMapperDefaultOther.class, + @Diagnostic( type = ErroneousSourceTargetMapperDefaultOther.class, kind = javax.tools.Diagnostic.Kind.ERROR, - line = 36, + line = 37, messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." + "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\." + "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" ) @@ -86,11 +86,11 @@ public class ReferencedAccessibilityTest { @Test @IssueKey( "206" ) - @WithClasses( { AbstractSourceTargetMapperPrivate.class, SourceTargetmapperPrivateBase.class } ) + @WithClasses( { ErroneousAbstractSourceTargetMapperPrivate.class, SourceTargetmapperPrivateBase.class } ) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = AbstractSourceTargetMapperPrivate.class, + @Diagnostic( type = ErroneousAbstractSourceTargetMapperPrivate.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 36, messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Issue580Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Issue580Test.java index e2ab0bec5..116a165ec 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Issue580Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Issue580Test.java @@ -26,6 +26,9 @@ import javax.xml.datatype.XMLGregorianCalendar; import org.junit.Test; import org.junit.runner.RunWith; +import org.mapstruct.ap.test.bugs._580.java8.Source; +import org.mapstruct.ap.test.bugs._580.java8.SourceTargetMapper; +import org.mapstruct.ap.test.bugs._580.java8.Target; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Source.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Source.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Source.java rename to processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Source.java index c423415fc..c85c28d70 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Source.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.bugs._580; +package org.mapstruct.ap.test.bugs._580.java8; import javax.xml.datatype.XMLGregorianCalendar; diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/SourceTargetMapper.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/bugs/_580/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/SourceTargetMapper.java index b9b9f9bd4..bd79b5d14 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/SourceTargetMapper.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.bugs._580; +package org.mapstruct.ap.test.bugs._580.java8; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Target.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Target.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Target.java rename to processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Target.java index ee2dab0cf..d7a5d0ed9 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_580/java8/Target.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.bugs._580; +package org.mapstruct.ap.test.bugs._580.java8; import java.time.LocalDate; diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/ErroneousSourceTargetMapper.java similarity index 91% rename from processor/src/test/java/org/mapstruct/ap/test/bugs/_590/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/bugs/_590/ErroneousSourceTargetMapper.java index 107ed2af9..82a1184dc 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/ErroneousSourceTargetMapper.java @@ -30,8 +30,8 @@ import org.mapstruct.factory.Mappers; * @author Andreas Gudian */ @Mapper(unmappedTargetPolicy = ReportingPolicy.WARN) -public abstract class SourceTargetMapper { - public static final SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); +public abstract class ErroneousSourceTargetMapper { + public static final ErroneousSourceTargetMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper.class ); public abstract void sourceToTarget(@MappingTarget Target target, Source source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/Issue590Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/Issue590Test.java index 9e6ecdf33..3d32fdde3 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/Issue590Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_590/Issue590Test.java @@ -32,12 +32,12 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; * @author Andreas Gudian */ @RunWith(AnnotationProcessorTestRunner.class) -@WithClasses(SourceTargetMapper.class) +@WithClasses(ErroneousSourceTargetMapper.class) public class Issue590Test { @Test @ExpectedCompilationOutcome(value = CompilationResult.FAILED, - diagnostics = { @Diagnostic(type = SourceTargetMapper.class, + diagnostics = { @Diagnostic(type = ErroneousSourceTargetMapper.class, kind = Kind.ERROR, messageRegExp = "Can't map property \"java\\.lang\\.String prop\" to \"[^ ]+ prop\"") }) public void showsCantMapPropertyError() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/ErroneousSourceTargetMapper.java similarity index 85% rename from processor/src/test/java/org/mapstruct/ap/test/bugs/_631/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/bugs/_631/ErroneousSourceTargetMapper.java index 6b5bc99a9..9bef1207d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/ErroneousSourceTargetMapper.java @@ -28,9 +28,9 @@ import org.mapstruct.factory.Mappers; * @param */ @Mapper -public interface SourceTargetMapper { +public interface ErroneousSourceTargetMapper { - SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); + ErroneousSourceTargetMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper.class ); X mapIntegerToBase1(Integer obj); diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/Issue631Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/Issue631Test.java index 668f1c3d1..a73f764c0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/Issue631Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_631/Issue631Test.java @@ -40,17 +40,17 @@ public class Issue631Test { @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic(type = SourceTargetMapper.class, + @Diagnostic(type = ErroneousSourceTargetMapper.class, kind = Kind.ERROR, line = 35, messageRegExp = "Can't generate mapping method for a generic type variable target."), - @Diagnostic(type = SourceTargetMapper.class, + @Diagnostic(type = ErroneousSourceTargetMapper.class, kind = Kind.ERROR, line = 37, messageRegExp = "Can't generate mapping method for a generic type variable source.") } ) - @WithClasses({SourceTargetMapper.class, Base1.class, Base2.class}) + @WithClasses({ErroneousSourceTargetMapper.class, Base1.class, Base2.class}) public void showsCantMapPropertyError() { } diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java index 35b0cc7e1..248f3569f 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java @@ -18,7 +18,7 @@ */ package org.mapstruct.ap.test.builtin; -import org.mapstruct.ap.test.builtin.mapper.SourceTargetWithSqlDateMapper; +import org.mapstruct.ap.test.builtin.mapper.ErroneousSourceTargetWithSqlDateMapper; import java.text.DateFormat; import java.text.ParseException; @@ -320,11 +320,11 @@ public class BuiltInTest { @Test @IssueKey( "277" ) - @WithClasses( { SourceWithDate.class, TargetWithSqlDate.class, SourceTargetWithSqlDateMapper.class } ) + @WithClasses( { SourceWithDate.class, TargetWithSqlDate.class, ErroneousSourceTargetWithSqlDateMapper.class } ) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = SourceTargetWithSqlDateMapper.class, + @Diagnostic( type = ErroneousSourceTargetWithSqlDateMapper.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 35, messageRegExp = "Can't map property \"java\\.util\\.Date date\" to " diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/SourceTargetWithSqlDateMapper.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/ErroneousSourceTargetWithSqlDateMapper.java similarity index 86% rename from processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/SourceTargetWithSqlDateMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/ErroneousSourceTargetWithSqlDateMapper.java index d9aed50e1..b405e988d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/SourceTargetWithSqlDateMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/mapper/ErroneousSourceTargetWithSqlDateMapper.java @@ -28,9 +28,9 @@ import org.mapstruct.factory.Mappers; * */ @Mapper -public interface SourceTargetWithSqlDateMapper { +public interface ErroneousSourceTargetWithSqlDateMapper { - SourceTargetWithSqlDateMapper INSTANCE = Mappers.getMapper( SourceTargetWithSqlDateMapper.class ); + ErroneousSourceTargetWithSqlDateMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetWithSqlDateMapper.class ); TargetWithSqlDate toTargetWithSqlDate(SourceWithDate source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableExtendsBoundTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableExtendsBoundTargetMapper.java similarity index 94% rename from processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableExtendsBoundTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableExtendsBoundTargetMapper.java index 9f84424ac..9207c0fe7 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableExtendsBoundTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableExtendsBoundTargetMapper.java @@ -27,7 +27,7 @@ import org.mapstruct.Mapper; * @author Sjaak Derksen */ @Mapper -public interface IterableExtendsBoundTargetMapper { +public interface ErroneousIterableExtendsBoundTargetMapper { List map(List in); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableSuperBoundSourceMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableSuperBoundSourceMapper.java similarity index 94% rename from processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableSuperBoundSourceMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableSuperBoundSourceMapper.java index 19e32d32c..81f7ca358 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableSuperBoundSourceMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableSuperBoundSourceMapper.java @@ -27,7 +27,7 @@ import org.mapstruct.Mapper; * @author Sjaak Derksen */ @Mapper -public interface IterableSuperBoundSourceMapper { +public interface ErroneousIterableSuperBoundSourceMapper { List map(List in); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMapper.java similarity index 92% rename from processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMapper.java index ec6942e63..cd0332f6c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMapper.java @@ -27,7 +27,7 @@ import org.mapstruct.Mapper; * @author Sjaak Derksen */ @Mapper -public interface IterableTypeVarBoundMapperOnMapper { +public interface ErroneousIterableTypeVarBoundMapperOnMapper { List map(List in); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMethod.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMethod.java similarity index 94% rename from processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMethod.java rename to processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMethod.java index 91ddf35cf..9bc379ef5 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/IterableTypeVarBoundMapperOnMethod.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/ErroneousIterableTypeVarBoundMapperOnMethod.java @@ -27,7 +27,7 @@ import org.mapstruct.Mapper; * @author Sjaak Derksen */ @Mapper -public interface IterableTypeVarBoundMapperOnMethod { +public interface ErroneousIterableTypeVarBoundMapperOnMethod { List map(List in); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java index 6eaaaa678..d8ce4faa2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java @@ -19,9 +19,10 @@ package org.mapstruct.ap.test.collection.wildcard; import java.math.BigDecimal; + import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; -import static org.fest.assertions.Assertions.assertThat; + import org.junit.Test; import org.junit.runner.RunWith; import org.mapstruct.ap.testutil.IssueKey; @@ -31,6 +32,8 @@ import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; import org.mapstruct.ap.testutil.compilation.annotation.ExpectedCompilationOutcome; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; +import static org.fest.assertions.Assertions.assertThat; + /** * Reproducer for https://github.com/mapstruct/mapstruct/issues/527. * @@ -79,11 +82,11 @@ public class WildCardTest { } @Test - @WithClasses({ IterableSuperBoundSourceMapper.class }) + @WithClasses({ ErroneousIterableSuperBoundSourceMapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = IterableSuperBoundSourceMapper.class, + @Diagnostic( type = ErroneousIterableSuperBoundSourceMapper.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 32, messageRegExp = "Can't generate mapping method for a wildcard super bound source." ) @@ -93,11 +96,11 @@ public class WildCardTest { } @Test - @WithClasses({ IterableExtendsBoundTargetMapper.class }) + @WithClasses({ ErroneousIterableExtendsBoundTargetMapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = IterableExtendsBoundTargetMapper.class, + @Diagnostic( type = ErroneousIterableExtendsBoundTargetMapper.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 32, messageRegExp = "Can't generate mapping method for a wildcard extends bound result." ) @@ -107,11 +110,11 @@ public class WildCardTest { } @Test - @WithClasses({ IterableTypeVarBoundMapperOnMethod.class }) + @WithClasses({ ErroneousIterableTypeVarBoundMapperOnMethod.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = IterableTypeVarBoundMapperOnMethod.class, + @Diagnostic(type = ErroneousIterableTypeVarBoundMapperOnMethod.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 32, messageRegExp = "Can't generate mapping method for a generic type variable target." ) @@ -121,11 +124,11 @@ public class WildCardTest { } @Test - @WithClasses({ IterableTypeVarBoundMapperOnMapper.class }) + @WithClasses({ ErroneousIterableTypeVarBoundMapperOnMapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic( type = IterableTypeVarBoundMapperOnMapper.class, + @Diagnostic( type = ErroneousIterableTypeVarBoundMapperOnMapper.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 32, messageRegExp = "Can't generate mapping method for a generic type variable source." ) diff --git a/processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithCyclicDependency.java b/processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithCyclicDependency.java similarity index 86% rename from processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithCyclicDependency.java rename to processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithCyclicDependency.java index cb74b690e..5e20cef5d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithCyclicDependency.java +++ b/processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithCyclicDependency.java @@ -24,9 +24,10 @@ import org.mapstruct.Mappings; import org.mapstruct.factory.Mappers; @Mapper -public interface AddressMapperWithCyclicDependency { +public interface ErroneousAddressMapperWithCyclicDependency { - AddressMapperWithCyclicDependency INSTANCE = Mappers.getMapper( AddressMapperWithCyclicDependency.class ); + ErroneousAddressMapperWithCyclicDependency INSTANCE = + Mappers.getMapper( ErroneousAddressMapperWithCyclicDependency.class ); @Mappings({ @Mapping(target = "lastName", dependsOn = "middleName"), diff --git a/processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithUnknownPropertyInDependsOn.java b/processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithUnknownPropertyInDependsOn.java similarity index 82% rename from processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithUnknownPropertyInDependsOn.java rename to processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithUnknownPropertyInDependsOn.java index d40906035..5373ee081 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/dependency/AddressMapperWithUnknownPropertyInDependsOn.java +++ b/processor/src/test/java/org/mapstruct/ap/test/dependency/ErroneousAddressMapperWithUnknownPropertyInDependsOn.java @@ -23,10 +23,10 @@ import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @Mapper -public interface AddressMapperWithUnknownPropertyInDependsOn { +public interface ErroneousAddressMapperWithUnknownPropertyInDependsOn { - AddressMapperWithUnknownPropertyInDependsOn INSTANCE = Mappers.getMapper( - AddressMapperWithUnknownPropertyInDependsOn.class + ErroneousAddressMapperWithUnknownPropertyInDependsOn INSTANCE = Mappers.getMapper( + ErroneousAddressMapperWithUnknownPropertyInDependsOn.class ); @Mapping(target = "lastName", dependsOn = "doesnotexist") diff --git a/processor/src/test/java/org/mapstruct/ap/test/dependency/OrderingTest.java b/processor/src/test/java/org/mapstruct/ap/test/dependency/OrderingTest.java index 85b04272e..88767ee8d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/dependency/OrderingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/dependency/OrderingTest.java @@ -69,13 +69,13 @@ public class OrderingTest { @Test @IssueKey("304") - @WithClasses(AddressMapperWithCyclicDependency.class) + @WithClasses(ErroneousAddressMapperWithCyclicDependency.class) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic(type = AddressMapperWithCyclicDependency.class, + @Diagnostic(type = ErroneousAddressMapperWithCyclicDependency.class, kind = javax.tools.Diagnostic.Kind.ERROR, - line = 36, + line = 37, messageRegExp = "Cycle\\(s\\) between properties given via dependsOn\\(\\): firstName -> lastName -> " + "middleName -> firstName" ) @@ -86,11 +86,11 @@ public class OrderingTest { @Test @IssueKey("304") - @WithClasses(AddressMapperWithUnknownPropertyInDependsOn.class) + @WithClasses(ErroneousAddressMapperWithUnknownPropertyInDependsOn.class) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic(type = AddressMapperWithUnknownPropertyInDependsOn.class, + @Diagnostic(type = ErroneousAddressMapperWithUnknownPropertyInDependsOn.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 32, messageRegExp = "\"doesnotexist\" is no property of the method return type" diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/AttributeInheritanceTest.java b/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/AttributeInheritanceTest.java index f4618d825..8f42ecb99 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/AttributeInheritanceTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/AttributeInheritanceTest.java @@ -50,11 +50,11 @@ public class AttributeInheritanceTest { } @Test - @WithClasses({ Source.class, Target.class, TargetSourceMapper.class }) + @WithClasses({ Source.class, Target.class, ErroneousTargetSourceMapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = @Diagnostic( - type = TargetSourceMapper.class, + type = ErroneousTargetSourceMapper.class, kind = Kind.ERROR, line = 29, messageRegExp = "Can't map property \"java.lang.CharSequence foo\" to \"java.lang.String foo\"" diff --git a/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/TargetSourceMapper.java b/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/ErroneousTargetSourceMapper.java similarity index 87% rename from processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/TargetSourceMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/ErroneousTargetSourceMapper.java index a651776a8..a006e26d0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/TargetSourceMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/inheritance/attribute/ErroneousTargetSourceMapper.java @@ -22,9 +22,9 @@ import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @Mapper -public interface TargetSourceMapper { +public interface ErroneousTargetSourceMapper { - TargetSourceMapper INSTANCE = Mappers.getMapper( TargetSourceMapper.class ); + ErroneousTargetSourceMapper INSTANCE = Mappers.getMapper( ErroneousTargetSourceMapper.class ); Source targetToSource(Target target); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java index f92a33b14..66d20d9a8 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/ConfigTest.java @@ -77,10 +77,10 @@ public class ConfigTest { } @Test - @WithClasses( { TargetNoFoo.class, SourceTargetMapperError.class } ) + @WithClasses( { TargetNoFoo.class, SourceTargetMapperErroneous.class } ) @ExpectedCompilationOutcome(value = CompilationResult.FAILED, diagnostics = { - @Diagnostic(type = SourceTargetMapperError.class, + @Diagnostic(type = SourceTargetMapperErroneous.class, kind = javax.tools.Diagnostic.Kind.ERROR, line = 33, messageRegExp = "Unmapped target property: \"noFoo\"") }) diff --git a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperErroneous.java similarity index 88% rename from processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java rename to processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperErroneous.java index 222806f05..8a985f926 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperError.java +++ b/processor/src/test/java/org/mapstruct/ap/test/mapperconfig/SourceTargetMapperErroneous.java @@ -26,9 +26,9 @@ import org.mapstruct.factory.Mappers; * @author Sjaak Derksen */ @Mapper(uses = { CustomMapperViaMapper.class }, config = CentralConfig.class ) -public interface SourceTargetMapperError { +public interface SourceTargetMapperErroneous { - SourceTargetMapperError INSTANCE = Mappers.getMapper( SourceTargetMapperError.class ); + SourceTargetMapperErroneous INSTANCE = Mappers.getMapper( SourceTargetMapperErroneous.class ); TargetNoFoo toTarget( Source source ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java index 4c48ce60f..1e305f2b6 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/InheritInverseConfigurationTest.java @@ -22,6 +22,10 @@ import javax.tools.Diagnostic.Kind; import org.junit.Test; import org.junit.runner.RunWith; +import org.mapstruct.ap.test.reverse.erroneous.SourceTargetMapperAmbiguous1; +import org.mapstruct.ap.test.reverse.erroneous.SourceTargetMapperAmbiguous2; +import org.mapstruct.ap.test.reverse.erroneous.SourceTargetMapperAmbiguous3; +import org.mapstruct.ap.test.reverse.erroneous.SourceTargetMapperNonMatchingName; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; @@ -69,12 +73,12 @@ public class InheritInverseConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous1.class, kind = Kind.ERROR, - line = 49, + line = 51, messageRegExp = "Several matching inverse methods exist: forward\\(\\), " + "forwardNotToReverse\\(\\). Specify a name explicitly."), @Diagnostic(type = SourceTargetMapperAmbiguous1.class, kind = Kind.WARNING, - line = 54, + line = 56, messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") } ) @@ -88,12 +92,12 @@ public class InheritInverseConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous2.class, kind = Kind.ERROR, - line = 49, + line = 51, messageRegExp = "None of the candidates forward\\(\\), forwardNotToReverse\\(\\) matches given " + "name: \"blah\"."), @Diagnostic(type = SourceTargetMapperAmbiguous2.class, kind = Kind.WARNING, - line = 54, + line = 56, messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") } ) @@ -107,12 +111,12 @@ public class InheritInverseConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous3.class, kind = Kind.ERROR, - line = 50, + line = 52, messageRegExp = "Given name \"forward\" matches several candidate methods: .*forward\\(.+\\), " + ".*forward\\(.+\\)"), @Diagnostic(type = SourceTargetMapperAmbiguous3.class, kind = Kind.WARNING, - line = 55, + line = 57, messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") } ) @@ -126,12 +130,12 @@ public class InheritInverseConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperNonMatchingName.class, kind = Kind.ERROR, - line = 42, + line = 44, messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " + "\"forward\"."), @Diagnostic(type = SourceTargetMapperNonMatchingName.class, kind = Kind.WARNING, - line = 47, + line = 49, messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") } ) diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous1.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java rename to processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous1.java index 046cea77a..7235e0d3e 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous1.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous1.java @@ -16,12 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.reverse; +package org.mapstruct.ap.test.reverse.erroneous; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.reverse.Source; +import org.mapstruct.ap.test.reverse.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous2.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java rename to processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous2.java index e063bfcb8..d151bbb07 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous2.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous2.java @@ -16,12 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.reverse; +package org.mapstruct.ap.test.reverse.erroneous; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.reverse.Source; +import org.mapstruct.ap.test.reverse.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous3.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java rename to processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous3.java index 63195a7ba..5f851936a 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperAmbiguous3.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperAmbiguous3.java @@ -16,13 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.reverse; +package org.mapstruct.ap.test.reverse.erroneous; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.reverse.Source; +import org.mapstruct.ap.test.reverse.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperNonMatchingName.java similarity index 92% rename from processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java rename to processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperNonMatchingName.java index 855738570..b75a525c9 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/reverse/SourceTargetMapperNonMatchingName.java +++ b/processor/src/test/java/org/mapstruct/ap/test/reverse/erroneous/SourceTargetMapperNonMatchingName.java @@ -16,12 +16,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.reverse; +package org.mapstruct.ap.test.reverse.erroneous; import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.reverse.Source; +import org.mapstruct.ap.test.reverse.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/template/InheritConfigurationTest.java b/processor/src/test/java/org/mapstruct/ap/test/template/InheritConfigurationTest.java index 7c2658972..9c010ef19 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/template/InheritConfigurationTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/template/InheritConfigurationTest.java @@ -23,6 +23,10 @@ import javax.tools.Diagnostic.Kind; import org.junit.Test; import org.junit.runner.RunWith; +import org.mapstruct.ap.test.template.erroneous.SourceTargetMapperAmbiguous1; +import org.mapstruct.ap.test.template.erroneous.SourceTargetMapperAmbiguous2; +import org.mapstruct.ap.test.template.erroneous.SourceTargetMapperAmbiguous3; +import org.mapstruct.ap.test.template.erroneous.SourceTargetMapperNonMatchingName; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; @@ -130,12 +134,12 @@ public class InheritConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous1.class, kind = Kind.ERROR, - line = 54, + line = 56, messageRegExp = "Several matching methods exist: forwardCreate\\(\\), " + "forwardCreate1\\(\\). Specify a name explicitly."), @Diagnostic(type = SourceTargetMapperAmbiguous1.class, kind = Kind.WARNING, - line = 55, + line = 57, messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " + "expressionProp, nestedResultProp\"") } @@ -150,12 +154,12 @@ public class InheritConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous2.class, kind = Kind.ERROR, - line = 54, + line = 56, messageRegExp = "None of the candidates forwardCreate\\(\\), forwardCreate1\\(\\) matches given " + "name: \"blah\"."), @Diagnostic(type = SourceTargetMapperAmbiguous2.class, kind = Kind.WARNING, - line = 55, + line = 57, messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " + "expressionProp, nestedResultProp\"") } @@ -170,12 +174,12 @@ public class InheritConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperAmbiguous3.class, kind = Kind.ERROR, - line = 54, + line = 56, messageRegExp = "Given name \"forwardCreate\" matches several candidate methods: " + ".*forwardCreate.*, .*forwardCreate.*"), @Diagnostic(type = SourceTargetMapperAmbiguous3.class, kind = Kind.WARNING, - line = 55, + line = 57, messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " + "expressionProp, nestedResultProp\"") } ) @@ -189,12 +193,12 @@ public class InheritConfigurationTest { diagnostics = { @Diagnostic(type = SourceTargetMapperNonMatchingName.class, kind = Kind.ERROR, - line = 45, + line = 47, messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " + "\"forwardCreate\"."), @Diagnostic(type = SourceTargetMapperNonMatchingName.class, kind = Kind.WARNING, - line = 46, + line = 48, messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " + "expressionProp, nestedResultProp\"") } diff --git a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous1.java b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous1.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous1.java rename to processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous1.java index 75cc2770e..0dfe9a011 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous1.java +++ b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous1.java @@ -16,13 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.template; +package org.mapstruct.ap.test.template.erroneous; import org.mapstruct.InheritConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.template.Source; +import org.mapstruct.ap.test.template.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous2.java b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous2.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous2.java rename to processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous2.java index c1ed95286..4dbec7eed 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous2.java +++ b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous2.java @@ -16,13 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.template; +package org.mapstruct.ap.test.template.erroneous; import org.mapstruct.InheritConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.template.Source; +import org.mapstruct.ap.test.template.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous3.java b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous3.java similarity index 93% rename from processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous3.java rename to processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous3.java index 3b0390ab9..3280af95a 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperAmbiguous3.java +++ b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperAmbiguous3.java @@ -16,13 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.template; +package org.mapstruct.ap.test.template.erroneous; import org.mapstruct.InheritConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.template.Source; +import org.mapstruct.ap.test.template.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperNonMatchingName.java b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperNonMatchingName.java similarity index 92% rename from processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperNonMatchingName.java rename to processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperNonMatchingName.java index b1327947f..5d436ccc0 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/template/SourceTargetMapperNonMatchingName.java +++ b/processor/src/test/java/org/mapstruct/ap/test/template/erroneous/SourceTargetMapperNonMatchingName.java @@ -16,13 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.template; +package org.mapstruct.ap.test.template.erroneous; import org.mapstruct.InheritConfiguration; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingTarget; import org.mapstruct.Mappings; +import org.mapstruct.ap.test.template.Source; +import org.mapstruct.ap.test.template.Target; import org.mapstruct.factory.Mappers; /** diff --git a/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/StrictSourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/ErroneousStrictSourceTargetMapper.java similarity index 87% rename from processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/StrictSourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/ErroneousStrictSourceTargetMapper.java index ad19beaef..33ee084a8 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/StrictSourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/ErroneousStrictSourceTargetMapper.java @@ -23,9 +23,9 @@ import org.mapstruct.ReportingPolicy; import org.mapstruct.factory.Mappers; @Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR) -public interface StrictSourceTargetMapper { +public interface ErroneousStrictSourceTargetMapper { - StrictSourceTargetMapper INSTANCE = Mappers.getMapper( StrictSourceTargetMapper.class ); + ErroneousStrictSourceTargetMapper INSTANCE = Mappers.getMapper( ErroneousStrictSourceTargetMapper.class ); Target sourceToTarget(Source source); diff --git a/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/UnmappedTargetTest.java b/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/UnmappedTargetTest.java index 3cfc10003..778a8106d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/UnmappedTargetTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/unmappedtarget/UnmappedTargetTest.java @@ -68,15 +68,15 @@ public class UnmappedTargetTest { } @Test - @WithClasses({ Source.class, Target.class, StrictSourceTargetMapper.class }) + @WithClasses({ Source.class, Target.class, ErroneousStrictSourceTargetMapper.class }) @ExpectedCompilationOutcome( value = CompilationResult.FAILED, diagnostics = { - @Diagnostic(type = StrictSourceTargetMapper.class, + @Diagnostic(type = ErroneousStrictSourceTargetMapper.class, kind = Kind.ERROR, line = 30, messageRegExp = "Unmapped target property: \"bar\""), - @Diagnostic(type = StrictSourceTargetMapper.class, + @Diagnostic(type = ErroneousStrictSourceTargetMapper.class, kind = Kind.ERROR, line = 32, messageRegExp = "Unmapped target property: \"qux\"")