File tree Expand file tree Collapse file tree
processor/src/test/java/org/mapstruct/ap/test/bugs/_2322 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .mapstruct .ap .test .bugs ._2322 ;
2+
3+ import org .mapstruct .Mapper ;
4+ import org .mapstruct .Mapping ;
5+ import org .mapstruct .factory .Mappers ;
6+
7+ @ Mapper
8+ public interface Issue2322Mapper {
9+
10+ Issue2322Mapper INSTANCE = Mappers .getMapper ( Issue2322Mapper .class );
11+
12+ @ Mapping ( target = "b" , source = "a" )
13+ @ Mapping ( target = "b.field1B" , source = "a.field1A" )
14+ Wrap map (A a );
15+
16+ class A {
17+ //CHECKSTYLE:OFF
18+ public int field1A ;
19+ public int field2 ;
20+ public int field3 ;
21+ //CHECKSTYLE:ON
22+ }
23+
24+ class B {
25+ //CHECKSTYLE:OFF
26+ public int field1B ;
27+ public int field2 ;
28+ public int field3 ;
29+ //CHECKSTYLE:ON
30+ }
31+
32+ class Wrap {
33+ //CHECKSTYLE:OFF
34+ public B b ;
35+ //CHECKSTYLE:ON
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ package org .mapstruct .ap .test .bugs ._2322 ;
2+
3+ import static org .assertj .core .api .Assertions .assertThat ;
4+
5+ import org .junit .Test ;
6+ import org .junit .runner .RunWith ;
7+ import org .mapstruct .ap .testutil .IssueKey ;
8+ import org .mapstruct .ap .testutil .WithClasses ;
9+ import org .mapstruct .ap .testutil .runner .AnnotationProcessorTestRunner ;
10+
11+ @ IssueKey ( "2322" )
12+ @ RunWith ( AnnotationProcessorTestRunner .class )
13+ public class Issue2322Test {
14+
15+ @ Test
16+ @ WithClasses ( Issue2322Mapper .class )
17+ public void testShouldCreateBaseMappings () {
18+
19+ Issue2322Mapper .A source = new Issue2322Mapper .A ();
20+ source .field1A = 11 ;
21+ source .field2 = 2 ;
22+ source .field3 = 3 ;
23+
24+ Issue2322Mapper .Wrap target = Issue2322Mapper .INSTANCE .map ( source );
25+
26+ assertThat ( target ).isNotNull ();
27+ assertThat ( target .b ).isNotNull ();
28+ // assertThat( target.b.field1B ).isEqualTo( 11 );
29+ assertThat ( target .b .field2 ).isEqualTo ( 2 );
30+ assertThat ( target .b .field3 ).isEqualTo ( 3 );
31+ }
32+
33+ }
You can’t perform that action at this time.
0 commit comments