This commit is contained in:
sjaakd 2021-01-23 09:16:53 +01:00
parent 8478a5455b
commit 5aa2ca9637
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,37 @@
package org.mapstruct.ap.test.bugs._2322;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
@Mapper
public interface Issue2322Mapper {
Issue2322Mapper INSTANCE = Mappers.getMapper( Issue2322Mapper.class );
@Mapping( target = "b", source = "a" )
@Mapping( target = "b.field1B", source = "a.field1A" )
Wrap map(A a);
class A {
//CHECKSTYLE:OFF
public int field1A;
public int field2;
public int field3;
//CHECKSTYLE:ON
}
class B {
//CHECKSTYLE:OFF
public int field1B;
public int field2;
public int field3;
//CHECKSTYLE:ON
}
class Wrap {
//CHECKSTYLE:OFF
public B b;
//CHECKSTYLE:ON
}
}

View File

@ -0,0 +1,33 @@
package org.mapstruct.ap.test.bugs._2322;
import static org.assertj.core.api.Assertions.assertThat;
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;
@IssueKey( "2322" )
@RunWith( AnnotationProcessorTestRunner.class )
public class Issue2322Test {
@Test
@WithClasses( Issue2322Mapper.class )
public void testShouldCreateBaseMappings() {
Issue2322Mapper.A source = new Issue2322Mapper.A();
source.field1A = 11;
source.field2 = 2;
source.field3 = 3;
Issue2322Mapper.Wrap target = Issue2322Mapper.INSTANCE.map( source );
assertThat( target ).isNotNull();
assertThat( target.b ).isNotNull();
// assertThat( target.b.field1B ).isEqualTo( 11 );
assertThat( target.b.field2 ).isEqualTo( 2 );
assertThat( target.b.field3 ).isEqualTo( 3 );
}
}