mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
* #1650 reproducer * #1650 fix cannot-find-symbol * #1650 reproducer, extended
This commit is contained in:
parent
8edc6f82aa
commit
743361ca45
@ -9,7 +9,8 @@
|
||||
<#import '../macro/CommonMacros.ftl' as lib >
|
||||
<@lib.handleExceptions>
|
||||
<#if includeSourceNullCheck>
|
||||
if ( <#if sourcePresenceCheckerReference?? >${sourcePresenceCheckerReference}<#else>${sourceReference} != null</#if> ) {
|
||||
<@lib.sourceLocalVarAssignment/>
|
||||
if ( <#if sourcePresenceCheckerReference?? >${sourcePresenceCheckerReference}<#else><#if sourceLocalVarName??>${sourceLocalVarName}<#else>${sourceReference}</#if> != null</#if> ) {
|
||||
<@assignToExistingTarget/>
|
||||
<@lib.handleAssignment/>;
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
public class A {
|
||||
private B b;
|
||||
|
||||
public B getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(B b) {
|
||||
this.b = b;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AMapper {
|
||||
|
||||
AMapper INSTANCE = Mappers.getMapper( AMapper.class );
|
||||
|
||||
@Mapping(source = "b.c", target = "cPrime")
|
||||
APrime toAPrime(A a, @MappingTarget APrime mappingTarget);
|
||||
|
||||
CPrime toCPrime(C c, @MappingTarget CPrime mappingTarget);
|
||||
|
||||
@Mapping(source = "b.c", target = "cPrime")
|
||||
APrime toAPrime(A a);
|
||||
|
||||
CPrime toCPrime(C c);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
public class APrime {
|
||||
|
||||
private CPrime cPrime;
|
||||
|
||||
public CPrime getcPrime() {
|
||||
return cPrime;
|
||||
}
|
||||
|
||||
public void setcPrime(CPrime cPrime) {
|
||||
this.cPrime = cPrime;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
public class B {
|
||||
private C c;
|
||||
|
||||
public C getC() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public void setC(C c) {
|
||||
this.c = c;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
public class C {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
public class CPrime {
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._1650;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@IssueKey("1650")
|
||||
@RunWith(AnnotationProcessorTestRunner.class)
|
||||
@WithClasses({
|
||||
AMapper.class,
|
||||
A.class,
|
||||
B.class,
|
||||
C.class,
|
||||
APrime.class,
|
||||
CPrime.class
|
||||
})
|
||||
public class Issue1650Test {
|
||||
|
||||
@Test
|
||||
public void shouldCompile() {
|
||||
|
||||
A a = new A();
|
||||
a.setB( new B() );
|
||||
a.getB().setC( new C() );
|
||||
|
||||
APrime aPrime = new APrime();
|
||||
|
||||
// update mapping
|
||||
AMapper.INSTANCE.toAPrime( a, aPrime );
|
||||
assertThat( aPrime.getcPrime() ).isNotNull();
|
||||
|
||||
// create mapping
|
||||
APrime aPrime1 = AMapper.INSTANCE.toAPrime( a );
|
||||
assertThat( aPrime1.getcPrime() ).isNotNull();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user