#691 Create an integration test that compiles all test mappers from the processor module with JDK 6/7/8/9, Eclipse JDT on language levels 1.6/1.7/1.8.

This commit is contained in:
Andreas Gudian 2015-11-16 22:26:48 +01:00
parent 8b35c63e9a
commit c0b005429a
43 changed files with 449 additions and 101 deletions

View File

@ -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:
* <ul>
* <li>{@code /erronerous/}</li>
* <li>{@code *Erroneous*}</li>
* <li>{@code *Test.java}</li>
* <li>{@code /testutil/}</li>
* <li>possibly more, depending on the processor type - see {@link CompilationExclusionCliEnhancer}</li>
* </ul>
*
* @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<String> getAdditionalCommandLineArguments(ProcessorType processorType) {
List<String> 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<String> result = new ArrayList<String>( additionalExcludes.size() );
for ( int i = 0; i < additionalExcludes.size(); i++ ) {
result.add( "-DadditionalExclude" + i + "=" + additionalExcludes.get( i ) );
}
return result;
}
}
}

View File

@ -23,6 +23,9 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.util.Collection;
import org.apache.maven.it.Verifier;
/** /**
* Declares the content of the integration test. * 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" ), 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 * Use the eclipse compiler with 1.7 source/target level from tycho-compiler-jdt to perform the build and
* processing * processing
@ -90,8 +99,8 @@ public @interface ProcessorSuite {
/** /**
* Use all available processing variants * 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, ALL( ORACLE_JAVA_6, ORACLE_JAVA_7, ORACLE_JAVA_8, ORACLE_JAVA_9, ECLIPSE_JDT_JAVA_6, ECLIPSE_JDT_JAVA_7,
PROCESSOR_PLUGIN_JAVA_8 ), ECLIPSE_JDT_JAVA_8, PROCESSOR_PLUGIN_JAVA_8 ),
/** /**
* Use all JDK8 compatible processing variants * 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<String> getAdditionalCommandLineArguments(ProcessorType processorType);
}
/** /**
* @return a path in the classpath that contains the maven module to run as integration test: {@code mvn clean test} * @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}. * @return the variants to execute the integration tests with. See {@link ProcessorType}.
*/ */
ProcessorType[] processorTypes() default { ProcessorType.ALL }; ProcessorType[] processorTypes() default { ProcessorType.ALL };
/**
* @return the {@link CommandLineEnhancer} implementation. Must have a default constructor.
*/
Class<? extends CommandLineEnhancer> commandLineEnhancer() default CommandLineEnhancer.class;
} }

View File

@ -18,13 +18,10 @@
*/ */
package org.mapstruct.itest.testutil.runner; 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.File;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -43,11 +40,16 @@ import org.junit.runner.notification.RunNotifier;
import org.junit.runner.notification.StoppedByUserException; import org.junit.runner.notification.StoppedByUserException;
import org.junit.runners.ParentRunner; import org.junit.runners.ParentRunner;
import org.junit.runners.model.InitializationError; 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.ProcessorSuite.ProcessorType;
import org.mapstruct.itest.testutil.runner.ProcessorSuiteRunner.ProcessorTestCase; import org.mapstruct.itest.testutil.runner.ProcessorSuiteRunner.ProcessorTestCase;
import org.mapstruct.itest.testutil.runner.xml.Toolchains; import org.mapstruct.itest.testutil.runner.xml.Toolchains;
import org.mapstruct.itest.testutil.runner.xml.Toolchains.ProviderDescription; 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. * Runner for processor integration tests. Requires the annotation {@link ProcessorSuite} on the test class.
* *
@ -73,10 +75,13 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
private final String baseDir; private final String baseDir;
private final ProcessorType processor; private final ProcessorType processor;
private final boolean ignored; private final boolean ignored;
private final Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor;
public ProcessorTestCase(String baseDir, ProcessorType processor) { public ProcessorTestCase(String baseDir, ProcessorType processor,
Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor) {
this.baseDir = baseDir; this.baseDir = baseDir;
this.processor = processor; this.processor = processor;
this.cliEnhancerConstructor = cliEnhancerConstructor;
this.ignored = !ENABLED_PROCESSOR_TYPES.contains( processor ); this.ignored = !ENABLED_PROCESSOR_TYPES.contains( processor );
} }
} }
@ -100,10 +105,25 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
throw new InitializationError( "ProcessorSuite#processorTypes must not be empty" ); throw new InitializationError( "ProcessorSuite#processorTypes must not be empty" );
} }
methods = initializeTestCases( suite ); Constructor<? extends CommandLineEnhancer> 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<ProcessorTestCase> initializeTestCases(ProcessorSuite suite) { private List<ProcessorTestCase> initializeTestCases(ProcessorSuite suite,
Constructor<? extends CommandLineEnhancer> cliEnhancerConstructor) {
List<ProcessorType> types = new ArrayList<ProcessorType>(); List<ProcessorType> types = new ArrayList<ProcessorType>();
for ( ProcessorType compiler : suite.processorTypes() ) { for ( ProcessorType compiler : suite.processorTypes() ) {
@ -118,7 +138,7 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
List<ProcessorTestCase> result = new ArrayList<ProcessorTestCase>( types.size() ); List<ProcessorTestCase> result = new ArrayList<ProcessorTestCase>( types.size() );
for ( ProcessorType type : types ) { for ( ProcessorType type : types ) {
result.add( new ProcessorTestCase( suite.baseDir(), type ) ); result.add( new ProcessorTestCase( suite.baseDir(), type, cliEnhancerConstructor ) );
} }
return result; return result;
@ -208,6 +228,8 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
goals.add( "test" ); goals.add( "test" );
addAdditionalCliArguments( child, verifier );
originalOut.println( "executing " + child.processor.name().toLowerCase() ); originalOut.println( "executing " + child.processor.name().toLowerCase() );
verifier.executeGoals( goals ); verifier.executeGoals( goals );
@ -218,6 +240,19 @@ public class ProcessorSuiteRunner extends ParentRunner<ProcessorTestCase> {
} }
} }
private void addAdditionalCliArguments(ProcessorTestCase child, final Verifier verifier) throws Exception {
if ( child.cliEnhancerConstructor != null ) {
CommandLineEnhancer enhancer = child.cliEnhancerConstructor.newInstance();
Collection<String> additionalArgs = enhancer.getAdditionalCommandLineArguments( child.processor );
if ( additionalArgs != null ) {
for ( String arg : additionalArgs ) {
verifier.addCliOption( arg );
}
}
}
}
private void configureProcessor(ProcessorTestCase child, Verifier verifier) { private void configureProcessor(ProcessorTestCase child, Verifier verifier) {
if ( child.processor.getCompilerId() != null ) { if ( child.processor.getCompilerId() != null ) {
verifier.addCliOption( "-Pgenerate-via-compiler-plugin" ); verifier.addCliOption( "-Pgenerate-via-compiler-plugin" );

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-it-parent</artifactId>
<version>1.0.0</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>fullFeatureTest</artifactId>
<packaging>jar</packaging>
<properties>
<additionalExclude0>x</additionalExclude0>
<additionalExclude1>x</additionalExclude1>
<additionalExclude2>x</additionalExclude2>
<additionalExclude3>x</additionalExclude3>
</properties>
<build>
<sourceDirectory>../../../../../processor/src/test/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/erroneous/**/*.java</exclude>
<exclude>**/*Erroneous*.java</exclude>
<exclude>**/*Test.java</exclude>
<exclude>**/testutil/**/*.java</exclude>
<exclude>${additionalExclude0}</exclude>
<exclude>${additionalExclude1}</exclude>
<exclude>${additionalExclude2}</exclude>
<exclude>${additionalExclude3}</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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();
}
}

View File

@ -27,10 +27,10 @@ import org.mapstruct.factory.Mappers;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
public abstract class AbstractSourceTargetMapperPrivate extends SourceTargetmapperPrivateBase { public abstract class ErroneousAbstractSourceTargetMapperPrivate extends SourceTargetmapperPrivateBase {
public static final AbstractSourceTargetMapperPrivate INSTANCE = public static final ErroneousAbstractSourceTargetMapperPrivate INSTANCE =
Mappers.getMapper( AbstractSourceTargetMapperPrivate.class ); Mappers.getMapper( ErroneousAbstractSourceTargetMapperPrivate.class );
@Mapping(source = "referencedSource", target = "referencedTarget") @Mapping(source = "referencedSource", target = "referencedTarget")
public abstract Target toTarget(Source source); public abstract Target toTarget(Source source);

View File

@ -28,9 +28,10 @@ import org.mapstruct.factory.Mappers;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper(uses = ReferencedMapperDefaultOther.class) @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") @Mapping(source = "referencedSource", target = "referencedTarget")
Target toTarget(Source source); Target toTarget(Source source);

View File

@ -27,9 +27,9 @@ import org.mapstruct.factory.Mappers;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper(uses = ReferencedMapperPrivate.class) @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") @Mapping(source = "referencedSource", target = "referencedTarget")
Target toTarget(Source source); Target toTarget(Source source);

View File

@ -39,11 +39,11 @@ public class ReferencedAccessibilityTest {
@Test @Test
@IssueKey( "206" ) @IssueKey( "206" )
@WithClasses( { SourceTargetMapperPrivate.class, ReferencedMapperPrivate.class } ) @WithClasses( { ErroneousSourceTargetMapperPrivate.class, ReferencedMapperPrivate.class } )
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = SourceTargetMapperPrivate.class, @Diagnostic( type = ErroneousSourceTargetMapperPrivate.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 35, line = 35,
messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\."
@ -65,13 +65,13 @@ public class ReferencedAccessibilityTest {
@Test @Test
@IssueKey( "206" ) @IssueKey( "206" )
@WithClasses( { SourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } ) @WithClasses( { ErroneousSourceTargetMapperDefaultOther.class, ReferencedMapperDefaultOther.class } )
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = SourceTargetMapperDefaultOther.class, @Diagnostic( type = ErroneousSourceTargetMapperDefaultOther.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 36, line = 37,
messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\."
+ "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\." + "referenced\\.ReferencedSource referencedSource\" to \"org\\.mapstruct\\."
+ "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" ) + "ap\\.test\\.accessibility\\.referenced\\.ReferencedTarget referencedTarget\"" )
@ -86,11 +86,11 @@ public class ReferencedAccessibilityTest {
@Test @Test
@IssueKey( "206" ) @IssueKey( "206" )
@WithClasses( { AbstractSourceTargetMapperPrivate.class, SourceTargetmapperPrivateBase.class } ) @WithClasses( { ErroneousAbstractSourceTargetMapperPrivate.class, SourceTargetmapperPrivateBase.class } )
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = AbstractSourceTargetMapperPrivate.class, @Diagnostic( type = ErroneousAbstractSourceTargetMapperPrivate.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 36, line = 36,
messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\." messageRegExp = "Can't map property \"org\\.mapstruct\\.ap\\.test\\.accessibility\\."

View File

@ -26,6 +26,9 @@ import javax.xml.datatype.XMLGregorianCalendar;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.IssueKey;
import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.bugs._580; package org.mapstruct.ap.test.bugs._580.java8;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;

View File

@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.bugs._580; package org.mapstruct.ap.test.bugs._580.java8;
import java.time.LocalDate; import java.time.LocalDate;

View File

@ -30,8 +30,8 @@ import org.mapstruct.factory.Mappers;
* @author Andreas Gudian * @author Andreas Gudian
*/ */
@Mapper(unmappedTargetPolicy = ReportingPolicy.WARN) @Mapper(unmappedTargetPolicy = ReportingPolicy.WARN)
public abstract class SourceTargetMapper { public abstract class ErroneousSourceTargetMapper {
public static final SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); public static final ErroneousSourceTargetMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper.class );
public abstract void sourceToTarget(@MappingTarget Target target, Source source); public abstract void sourceToTarget(@MappingTarget Target target, Source source);

View File

@ -32,12 +32,12 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
* @author Andreas Gudian * @author Andreas Gudian
*/ */
@RunWith(AnnotationProcessorTestRunner.class) @RunWith(AnnotationProcessorTestRunner.class)
@WithClasses(SourceTargetMapper.class) @WithClasses(ErroneousSourceTargetMapper.class)
public class Issue590Test { public class Issue590Test {
@Test @Test
@ExpectedCompilationOutcome(value = CompilationResult.FAILED, @ExpectedCompilationOutcome(value = CompilationResult.FAILED,
diagnostics = { @Diagnostic(type = SourceTargetMapper.class, diagnostics = { @Diagnostic(type = ErroneousSourceTargetMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
messageRegExp = "Can't map property \"java\\.lang\\.String prop\" to \"[^ ]+ prop\"") }) messageRegExp = "Can't map property \"java\\.lang\\.String prop\" to \"[^ ]+ prop\"") })
public void showsCantMapPropertyError() { public void showsCantMapPropertyError() {

View File

@ -28,9 +28,9 @@ import org.mapstruct.factory.Mappers;
* @param <Y> * @param <Y>
*/ */
@Mapper @Mapper
public interface SourceTargetMapper<X extends Base1, Y extends Base2> { public interface ErroneousSourceTargetMapper<X extends Base1, Y extends Base2> {
SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); ErroneousSourceTargetMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetMapper.class );
X mapIntegerToBase1(Integer obj); X mapIntegerToBase1(Integer obj);

View File

@ -40,17 +40,17 @@ public class Issue631Test {
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapper.class, @Diagnostic(type = ErroneousSourceTargetMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 35, line = 35,
messageRegExp = "Can't generate mapping method for a generic type variable target."), messageRegExp = "Can't generate mapping method for a generic type variable target."),
@Diagnostic(type = SourceTargetMapper.class, @Diagnostic(type = ErroneousSourceTargetMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 37, line = 37,
messageRegExp = "Can't generate mapping method for a generic type variable source.") 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() { public void showsCantMapPropertyError() {
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.mapstruct.ap.test.builtin; 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.DateFormat;
import java.text.ParseException; import java.text.ParseException;
@ -320,11 +320,11 @@ public class BuiltInTest {
@Test @Test
@IssueKey( "277" ) @IssueKey( "277" )
@WithClasses( { SourceWithDate.class, TargetWithSqlDate.class, SourceTargetWithSqlDateMapper.class } ) @WithClasses( { SourceWithDate.class, TargetWithSqlDate.class, ErroneousSourceTargetWithSqlDateMapper.class } )
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = SourceTargetWithSqlDateMapper.class, @Diagnostic( type = ErroneousSourceTargetWithSqlDateMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 35, line = 35,
messageRegExp = "Can't map property \"java\\.util\\.Date date\" to " messageRegExp = "Can't map property \"java\\.util\\.Date date\" to "

View File

@ -28,9 +28,9 @@ import org.mapstruct.factory.Mappers;
* *
*/ */
@Mapper @Mapper
public interface SourceTargetWithSqlDateMapper { public interface ErroneousSourceTargetWithSqlDateMapper {
SourceTargetWithSqlDateMapper INSTANCE = Mappers.getMapper( SourceTargetWithSqlDateMapper.class ); ErroneousSourceTargetWithSqlDateMapper INSTANCE = Mappers.getMapper( ErroneousSourceTargetWithSqlDateMapper.class );
TargetWithSqlDate toTargetWithSqlDate(SourceWithDate source); TargetWithSqlDate toTargetWithSqlDate(SourceWithDate source);

View File

@ -27,7 +27,7 @@ import org.mapstruct.Mapper;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
public interface IterableExtendsBoundTargetMapper { public interface ErroneousIterableExtendsBoundTargetMapper {
List<? extends BigDecimal> map(List<BigDecimal> in); List<? extends BigDecimal> map(List<BigDecimal> in);
} }

View File

@ -27,7 +27,7 @@ import org.mapstruct.Mapper;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
public interface IterableSuperBoundSourceMapper { public interface ErroneousIterableSuperBoundSourceMapper {
List<BigDecimal> map(List<? super BigDecimal> in); List<BigDecimal> map(List<? super BigDecimal> in);
} }

View File

@ -27,7 +27,7 @@ import org.mapstruct.Mapper;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
public interface IterableTypeVarBoundMapperOnMapper<T extends BigDecimal> { public interface ErroneousIterableTypeVarBoundMapperOnMapper<T extends BigDecimal> {
List<BigDecimal> map(List<T> in); List<BigDecimal> map(List<T> in);
} }

View File

@ -27,7 +27,7 @@ import org.mapstruct.Mapper;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper @Mapper
public interface IterableTypeVarBoundMapperOnMethod { public interface ErroneousIterableTypeVarBoundMapperOnMethod {
<T extends BigDecimal> List<T> map(List<BigDecimal> in); <T extends BigDecimal> List<T> map(List<BigDecimal> in);
} }

View File

@ -19,9 +19,10 @@
package org.mapstruct.ap.test.collection.wildcard; package org.mapstruct.ap.test.collection.wildcard;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
import static org.fest.assertions.Assertions.assertThat;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.IssueKey; 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.compilation.annotation.ExpectedCompilationOutcome;
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
import static org.fest.assertions.Assertions.assertThat;
/** /**
* Reproducer for https://github.com/mapstruct/mapstruct/issues/527. * Reproducer for https://github.com/mapstruct/mapstruct/issues/527.
* *
@ -79,11 +82,11 @@ public class WildCardTest {
} }
@Test @Test
@WithClasses({ IterableSuperBoundSourceMapper.class }) @WithClasses({ ErroneousIterableSuperBoundSourceMapper.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = IterableSuperBoundSourceMapper.class, @Diagnostic( type = ErroneousIterableSuperBoundSourceMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 32, line = 32,
messageRegExp = "Can't generate mapping method for a wildcard super bound source." ) messageRegExp = "Can't generate mapping method for a wildcard super bound source." )
@ -93,11 +96,11 @@ public class WildCardTest {
} }
@Test @Test
@WithClasses({ IterableExtendsBoundTargetMapper.class }) @WithClasses({ ErroneousIterableExtendsBoundTargetMapper.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = IterableExtendsBoundTargetMapper.class, @Diagnostic( type = ErroneousIterableExtendsBoundTargetMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 32, line = 32,
messageRegExp = "Can't generate mapping method for a wildcard extends bound result." ) messageRegExp = "Can't generate mapping method for a wildcard extends bound result." )
@ -107,11 +110,11 @@ public class WildCardTest {
} }
@Test @Test
@WithClasses({ IterableTypeVarBoundMapperOnMethod.class }) @WithClasses({ ErroneousIterableTypeVarBoundMapperOnMethod.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = IterableTypeVarBoundMapperOnMethod.class, @Diagnostic(type = ErroneousIterableTypeVarBoundMapperOnMethod.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 32, line = 32,
messageRegExp = "Can't generate mapping method for a generic type variable target." ) messageRegExp = "Can't generate mapping method for a generic type variable target." )
@ -121,11 +124,11 @@ public class WildCardTest {
} }
@Test @Test
@WithClasses({ IterableTypeVarBoundMapperOnMapper.class }) @WithClasses({ ErroneousIterableTypeVarBoundMapperOnMapper.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic( type = IterableTypeVarBoundMapperOnMapper.class, @Diagnostic( type = ErroneousIterableTypeVarBoundMapperOnMapper.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 32, line = 32,
messageRegExp = "Can't generate mapping method for a generic type variable source." ) messageRegExp = "Can't generate mapping method for a generic type variable source." )

View File

@ -24,9 +24,10 @@ import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper @Mapper
public interface AddressMapperWithCyclicDependency { public interface ErroneousAddressMapperWithCyclicDependency {
AddressMapperWithCyclicDependency INSTANCE = Mappers.getMapper( AddressMapperWithCyclicDependency.class ); ErroneousAddressMapperWithCyclicDependency INSTANCE =
Mappers.getMapper( ErroneousAddressMapperWithCyclicDependency.class );
@Mappings({ @Mappings({
@Mapping(target = "lastName", dependsOn = "middleName"), @Mapping(target = "lastName", dependsOn = "middleName"),

View File

@ -23,10 +23,10 @@ import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper @Mapper
public interface AddressMapperWithUnknownPropertyInDependsOn { public interface ErroneousAddressMapperWithUnknownPropertyInDependsOn {
AddressMapperWithUnknownPropertyInDependsOn INSTANCE = Mappers.getMapper( ErroneousAddressMapperWithUnknownPropertyInDependsOn INSTANCE = Mappers.getMapper(
AddressMapperWithUnknownPropertyInDependsOn.class ErroneousAddressMapperWithUnknownPropertyInDependsOn.class
); );
@Mapping(target = "lastName", dependsOn = "doesnotexist") @Mapping(target = "lastName", dependsOn = "doesnotexist")

View File

@ -69,13 +69,13 @@ public class OrderingTest {
@Test @Test
@IssueKey("304") @IssueKey("304")
@WithClasses(AddressMapperWithCyclicDependency.class) @WithClasses(ErroneousAddressMapperWithCyclicDependency.class)
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic(type = AddressMapperWithCyclicDependency.class, @Diagnostic(type = ErroneousAddressMapperWithCyclicDependency.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 36, line = 37,
messageRegExp = "Cycle\\(s\\) between properties given via dependsOn\\(\\): firstName -> lastName -> " messageRegExp = "Cycle\\(s\\) between properties given via dependsOn\\(\\): firstName -> lastName -> "
+ "middleName -> firstName" + "middleName -> firstName"
) )
@ -86,11 +86,11 @@ public class OrderingTest {
@Test @Test
@IssueKey("304") @IssueKey("304")
@WithClasses(AddressMapperWithUnknownPropertyInDependsOn.class) @WithClasses(ErroneousAddressMapperWithUnknownPropertyInDependsOn.class)
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic(type = AddressMapperWithUnknownPropertyInDependsOn.class, @Diagnostic(type = ErroneousAddressMapperWithUnknownPropertyInDependsOn.class,
kind = javax.tools.Diagnostic.Kind.ERROR, kind = javax.tools.Diagnostic.Kind.ERROR,
line = 32, line = 32,
messageRegExp = "\"doesnotexist\" is no property of the method return type" messageRegExp = "\"doesnotexist\" is no property of the method return type"

View File

@ -50,11 +50,11 @@ public class AttributeInheritanceTest {
} }
@Test @Test
@WithClasses({ Source.class, Target.class, TargetSourceMapper.class }) @WithClasses({ Source.class, Target.class, ErroneousTargetSourceMapper.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = @Diagnostic( diagnostics = @Diagnostic(
type = TargetSourceMapper.class, type = ErroneousTargetSourceMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 29, line = 29,
messageRegExp = "Can't map property \"java.lang.CharSequence foo\" to \"java.lang.String foo\"" messageRegExp = "Can't map property \"java.lang.CharSequence foo\" to \"java.lang.String foo\""

View File

@ -22,9 +22,9 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper @Mapper
public interface TargetSourceMapper { public interface ErroneousTargetSourceMapper {
TargetSourceMapper INSTANCE = Mappers.getMapper( TargetSourceMapper.class ); ErroneousTargetSourceMapper INSTANCE = Mappers.getMapper( ErroneousTargetSourceMapper.class );
Source targetToSource(Target target); Source targetToSource(Target target);
} }

View File

@ -77,10 +77,10 @@ public class ConfigTest {
} }
@Test @Test
@WithClasses( { TargetNoFoo.class, SourceTargetMapperError.class } ) @WithClasses( { TargetNoFoo.class, SourceTargetMapperErroneous.class } )
@ExpectedCompilationOutcome(value = CompilationResult.FAILED, @ExpectedCompilationOutcome(value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperError.class, @Diagnostic(type = SourceTargetMapperErroneous.class,
kind = javax.tools.Diagnostic.Kind.ERROR, line = 33, kind = javax.tools.Diagnostic.Kind.ERROR, line = 33,
messageRegExp = "Unmapped target property: \"noFoo\"") messageRegExp = "Unmapped target property: \"noFoo\"")
}) })

View File

@ -26,9 +26,9 @@ import org.mapstruct.factory.Mappers;
* @author Sjaak Derksen * @author Sjaak Derksen
*/ */
@Mapper(uses = { CustomMapperViaMapper.class }, config = CentralConfig.class ) @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 ); TargetNoFoo toTarget( Source source );
} }

View File

@ -22,6 +22,10 @@ import javax.tools.Diagnostic.Kind;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.IssueKey;
import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
@ -69,12 +73,12 @@ public class InheritInverseConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous1.class, @Diagnostic(type = SourceTargetMapperAmbiguous1.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 49, line = 51,
messageRegExp = "Several matching inverse methods exist: forward\\(\\), " messageRegExp = "Several matching inverse methods exist: forward\\(\\), "
+ "forwardNotToReverse\\(\\). Specify a name explicitly."), + "forwardNotToReverse\\(\\). Specify a name explicitly."),
@Diagnostic(type = SourceTargetMapperAmbiguous1.class, @Diagnostic(type = SourceTargetMapperAmbiguous1.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 54, line = 56,
messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"")
} }
) )
@ -88,12 +92,12 @@ public class InheritInverseConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous2.class, @Diagnostic(type = SourceTargetMapperAmbiguous2.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 49, line = 51,
messageRegExp = "None of the candidates forward\\(\\), forwardNotToReverse\\(\\) matches given " messageRegExp = "None of the candidates forward\\(\\), forwardNotToReverse\\(\\) matches given "
+ "name: \"blah\"."), + "name: \"blah\"."),
@Diagnostic(type = SourceTargetMapperAmbiguous2.class, @Diagnostic(type = SourceTargetMapperAmbiguous2.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 54, line = 56,
messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"")
} }
) )
@ -107,12 +111,12 @@ public class InheritInverseConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous3.class, @Diagnostic(type = SourceTargetMapperAmbiguous3.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 50, line = 52,
messageRegExp = "Given name \"forward\" matches several candidate methods: .*forward\\(.+\\), " messageRegExp = "Given name \"forward\" matches several candidate methods: .*forward\\(.+\\), "
+ ".*forward\\(.+\\)"), + ".*forward\\(.+\\)"),
@Diagnostic(type = SourceTargetMapperAmbiguous3.class, @Diagnostic(type = SourceTargetMapperAmbiguous3.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 55, line = 57,
messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"")
} }
) )
@ -126,12 +130,12 @@ public class InheritInverseConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperNonMatchingName.class, @Diagnostic(type = SourceTargetMapperNonMatchingName.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 42, line = 44,
messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: "
+ "\"forward\"."), + "\"forward\"."),
@Diagnostic(type = SourceTargetMapperNonMatchingName.class, @Diagnostic(type = SourceTargetMapperNonMatchingName.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 47, line = 49,
messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"") messageRegExp = "Unmapped target properties: \"stringPropX, integerPropX\"")
} }
) )

View File

@ -16,12 +16,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.reverse; package org.mapstruct.ap.test.reverse.erroneous;
import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.reverse.Source;
import org.mapstruct.ap.test.reverse.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,12 +16,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.reverse; package org.mapstruct.ap.test.reverse.erroneous;
import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.reverse.Source;
import org.mapstruct.ap.test.reverse.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,13 +16,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.reverse; package org.mapstruct.ap.test.reverse.erroneous;
import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.reverse.Source;
import org.mapstruct.ap.test.reverse.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,12 +16,14 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.reverse; package org.mapstruct.ap.test.reverse.erroneous;
import org.mapstruct.InheritInverseConfiguration; import org.mapstruct.InheritInverseConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.reverse.Source;
import org.mapstruct.ap.test.reverse.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -23,6 +23,10 @@ import javax.tools.Diagnostic.Kind;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; 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.IssueKey;
import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.WithClasses;
import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult; import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
@ -130,12 +134,12 @@ public class InheritConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous1.class, @Diagnostic(type = SourceTargetMapperAmbiguous1.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 54, line = 56,
messageRegExp = "Several matching methods exist: forwardCreate\\(\\), " messageRegExp = "Several matching methods exist: forwardCreate\\(\\), "
+ "forwardCreate1\\(\\). Specify a name explicitly."), + "forwardCreate1\\(\\). Specify a name explicitly."),
@Diagnostic(type = SourceTargetMapperAmbiguous1.class, @Diagnostic(type = SourceTargetMapperAmbiguous1.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 55, line = 57,
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
+ "expressionProp, nestedResultProp\"") + "expressionProp, nestedResultProp\"")
} }
@ -150,12 +154,12 @@ public class InheritConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous2.class, @Diagnostic(type = SourceTargetMapperAmbiguous2.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 54, line = 56,
messageRegExp = "None of the candidates forwardCreate\\(\\), forwardCreate1\\(\\) matches given " messageRegExp = "None of the candidates forwardCreate\\(\\), forwardCreate1\\(\\) matches given "
+ "name: \"blah\"."), + "name: \"blah\"."),
@Diagnostic(type = SourceTargetMapperAmbiguous2.class, @Diagnostic(type = SourceTargetMapperAmbiguous2.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 55, line = 57,
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
+ "expressionProp, nestedResultProp\"") + "expressionProp, nestedResultProp\"")
} }
@ -170,12 +174,12 @@ public class InheritConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperAmbiguous3.class, @Diagnostic(type = SourceTargetMapperAmbiguous3.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 54, line = 56,
messageRegExp = "Given name \"forwardCreate\" matches several candidate methods: " messageRegExp = "Given name \"forwardCreate\" matches several candidate methods: "
+ ".*forwardCreate.*, .*forwardCreate.*"), + ".*forwardCreate.*, .*forwardCreate.*"),
@Diagnostic(type = SourceTargetMapperAmbiguous3.class, @Diagnostic(type = SourceTargetMapperAmbiguous3.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 55, line = 57,
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
+ "expressionProp, nestedResultProp\"") } + "expressionProp, nestedResultProp\"") }
) )
@ -189,12 +193,12 @@ public class InheritConfigurationTest {
diagnostics = { diagnostics = {
@Diagnostic(type = SourceTargetMapperNonMatchingName.class, @Diagnostic(type = SourceTargetMapperNonMatchingName.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 45, line = 47,
messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: " messageRegExp = "Given name \"blah\" does not match the only candidate. Did you mean: "
+ "\"forwardCreate\"."), + "\"forwardCreate\"."),
@Diagnostic(type = SourceTargetMapperNonMatchingName.class, @Diagnostic(type = SourceTargetMapperNonMatchingName.class,
kind = Kind.WARNING, kind = Kind.WARNING,
line = 46, line = 48,
messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, " messageRegExp = "Unmapped target properties: \"stringPropY, integerPropY, constantProp, "
+ "expressionProp, nestedResultProp\"") + "expressionProp, nestedResultProp\"")
} }

View File

@ -16,13 +16,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.template; package org.mapstruct.ap.test.template.erroneous;
import org.mapstruct.InheritConfiguration; import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.template.Source;
import org.mapstruct.ap.test.template.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,13 +16,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.template; package org.mapstruct.ap.test.template.erroneous;
import org.mapstruct.InheritConfiguration; import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.template.Source;
import org.mapstruct.ap.test.template.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,13 +16,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.template; package org.mapstruct.ap.test.template.erroneous;
import org.mapstruct.InheritConfiguration; import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.template.Source;
import org.mapstruct.ap.test.template.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -16,13 +16,15 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.mapstruct.ap.test.template; package org.mapstruct.ap.test.template.erroneous;
import org.mapstruct.InheritConfiguration; import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget; import org.mapstruct.MappingTarget;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
import org.mapstruct.ap.test.template.Source;
import org.mapstruct.ap.test.template.Target;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
/** /**

View File

@ -23,9 +23,9 @@ import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper(unmappedTargetPolicy = ReportingPolicy.ERROR) @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); Target sourceToTarget(Source source);

View File

@ -68,15 +68,15 @@ public class UnmappedTargetTest {
} }
@Test @Test
@WithClasses({ Source.class, Target.class, StrictSourceTargetMapper.class }) @WithClasses({ Source.class, Target.class, ErroneousStrictSourceTargetMapper.class })
@ExpectedCompilationOutcome( @ExpectedCompilationOutcome(
value = CompilationResult.FAILED, value = CompilationResult.FAILED,
diagnostics = { diagnostics = {
@Diagnostic(type = StrictSourceTargetMapper.class, @Diagnostic(type = ErroneousStrictSourceTargetMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 30, line = 30,
messageRegExp = "Unmapped target property: \"bar\""), messageRegExp = "Unmapped target property: \"bar\""),
@Diagnostic(type = StrictSourceTargetMapper.class, @Diagnostic(type = ErroneousStrictSourceTargetMapper.class,
kind = Kind.ERROR, kind = Kind.ERROR,
line = 32, line = 32,
messageRegExp = "Unmapped target property: \"qux\"") messageRegExp = "Unmapped target property: \"qux\"")