File tree Expand file tree Collapse file tree 5 files changed +104
-0
lines changed
main/java/org/mapstruct/ap/internal/model
test/java/org/mapstruct/ap/test/bugs/_2251 Expand file tree Collapse file tree 5 files changed +104
-0
lines changed Original file line number Diff line number Diff line change @@ -1315,6 +1315,7 @@ private void applyParameterNameBasedMapping() {
13151315 sourceParameters .remove ();
13161316 unprocessedDefinedTargets .remove ( targetProperty .getKey () );
13171317 unprocessedSourceProperties .remove ( targetProperty .getKey () );
1318+ unprocessedConstructorProperties .remove ( targetProperty .getKey () );
13181319 }
13191320 }
13201321 }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2251 ;
7+
8+ import org .mapstruct .Mapper ;
9+ import org .mapstruct .Mapping ;
10+ import org .mapstruct .factory .Mappers ;
11+
12+ @ Mapper
13+ public interface Issue2251Mapper {
14+
15+ Issue2251Mapper INSTANCE = Mappers .getMapper ( Issue2251Mapper .class );
16+
17+ @ Mapping (target = "value1" , source = "source.value" )
18+ Target map (Source source , String value2 );
19+
20+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2251 ;
7+
8+ import org .junit .Test ;
9+ import org .junit .runner .RunWith ;
10+ import org .mapstruct .ap .testutil .IssueKey ;
11+ import org .mapstruct .ap .testutil .WithClasses ;
12+ import org .mapstruct .ap .testutil .runner .AnnotationProcessorTestRunner ;
13+
14+ import static org .assertj .core .api .Assertions .assertThat ;
15+
16+ /**
17+ * @author Filip Hrisafov
18+ */
19+ @ IssueKey ("2251" )
20+ @ RunWith (AnnotationProcessorTestRunner .class )
21+ @ WithClasses ({
22+ Issue2251Mapper .class ,
23+ Source .class ,
24+ Target .class ,
25+ })
26+ public class Issue2251Test {
27+
28+ @ Test
29+ public void shouldGenerateCorrectCode () {
30+
31+ Target target = Issue2251Mapper .INSTANCE .map ( new Source ( "source" ), "test" );
32+
33+ assertThat ( target ).isNotNull ();
34+ assertThat ( target .getValue1 () ).isEqualTo ( "source" );
35+ assertThat ( target .getValue2 () ).isEqualTo ( "test" );
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2251 ;
7+
8+ /**
9+ * @author Filip Hrisafov
10+ */
11+ public class Source {
12+
13+ private final String value ;
14+
15+ public Source (String value ) {
16+ this .value = value ;
17+ }
18+
19+ public String getValue () {
20+ return value ;
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright MapStruct Authors.
3+ *
4+ * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
5+ */
6+ package org .mapstruct .ap .test .bugs ._2251 ;
7+
8+ public class Target {
9+ private final String value1 ;
10+ private final String value2 ;
11+
12+ public Target (String value1 , String value2 ) {
13+ this .value1 = value1 ;
14+ this .value2 = value2 ;
15+ }
16+
17+ public String getValue1 () {
18+ return value1 ;
19+ }
20+
21+ public String getValue2 () {
22+ return value2 ;
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments