#1014 do not generate FQN for extends/super bound Types

This commit is contained in:
Filip Hrisafov 2016-12-22 23:07:49 +01:00 committed by Gunnar Morling
parent 78db48f7cb
commit 00b8ae01a1
2 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,4 @@
<#-- @ftlvariable name="" type="org.mapstruct.ap.internal.model.common.Type" -->
<#-- <#--
Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/)
@ -18,4 +19,19 @@
limitations under the License. limitations under the License.
--> -->
<#if imported>${name}<#else>${fullyQualifiedName}</#if><#if (!ext.raw?? && typeParameters?size > 0) ><<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>></#if> <@compress single_line=true>
<#if wildCardExtendsBound>
? extends <@includeModel object=typeBound />
<#elseif wildCardSuperBound>
? super <@includeModel object=typeBound />
<#else>
<#if imported>
${name}
<#else>
${fullyQualifiedName}
</#if>
</#if>
<#if (!ext.raw?? && typeParameters?size > 0) >
<<#list typeParameters as typeParameter><@includeModel object=typeParameter /><#if typeParameter_has_next>, </#if></#list>>
</#if>
</@compress>

View File

@ -25,6 +25,7 @@ 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 org.junit.Rule;
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;
@ -33,6 +34,7 @@ import org.mapstruct.ap.testutil.compilation.annotation.CompilationResult;
import org.mapstruct.ap.testutil.compilation.annotation.Diagnostic; 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 org.mapstruct.ap.testutil.runner.GeneratedSource;
/** /**
* Reproducer for https://github.com/mapstruct/mapstruct/issues/527. * Reproducer for https://github.com/mapstruct/mapstruct/issues/527.
@ -43,6 +45,9 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
@RunWith(AnnotationProcessorTestRunner.class) @RunWith(AnnotationProcessorTestRunner.class)
public class WildCardTest { public class WildCardTest {
@Rule
public final GeneratedSource generatedSource = new GeneratedSource();
@Test @Test
@WithClasses({ @WithClasses({
ExtendsBoundSourceTargetMapper.class, ExtendsBoundSourceTargetMapper.class,
@ -59,7 +64,10 @@ public class WildCardTest {
assertThat( target ).isNotNull(); assertThat( target ).isNotNull();
assertThat( target.getElements() ).isNull(); assertThat( target.getElements() ).isNull();
generatedSource.forMapper( ExtendsBoundSourceTargetMapper.class )
.content()
.as( "Should not contain FQN after extends" )
.doesNotContain( "? extends org.mapstruct.ap.test.collection.wildcard.Idea" );
} }
@Test @Test
@ -78,7 +86,10 @@ public class WildCardTest {
assertThat( target ).isNotNull(); assertThat( target ).isNotNull();
assertThat( target.getElements() ).isNull(); assertThat( target.getElements() ).isNull();
generatedSource.forMapper( SourceSuperBoundTargetMapper.class )
.content()
.as( "Should not contain FQN after super" )
.doesNotContain( "? super org.mapstruct.ap.test.collection.wildcard.Idea" );
} }
@Test @Test