forked from mapstruct/mapstruct
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mapstruct#1799 Fluent setters starting with set should work properly
- Loading branch information
Showing
5 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
processor/src/test/java/org/mapstruct/ap/test/bugs/_1799/Issue1799Mapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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._1799; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@Mapper | ||
public interface Issue1799Mapper { | ||
|
||
Issue1799Mapper INSTANCE = Mappers.getMapper( Issue1799Mapper.class ); | ||
|
||
Target map(Source source); | ||
} |
37 changes: 37 additions & 0 deletions
37
processor/src/test/java/org/mapstruct/ap/test/bugs/_1799/Issue1799Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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._1799; | ||
|
||
import java.util.Date; | ||
|
||
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; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@WithClasses({ | ||
Issue1799Mapper.class, | ||
Source.class, | ||
Target.class, | ||
}) | ||
@IssueKey("1799") | ||
@RunWith(AnnotationProcessorTestRunner.class) | ||
public class Issue1799Test { | ||
|
||
@Test | ||
public void fluentJavaBeanStyleSettersShouldWork() { | ||
Target target = Issue1799Mapper.INSTANCE.map( new Source( new Date( 150 ), "Switzerland" ) ); | ||
|
||
assertThat( target.getSettlementDate() ).isEqualTo( new Date( 150 ) ); | ||
assertThat( target.getGetawayLocation() ).isEqualTo( "Switzerland" ); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
processor/src/test/java/org/mapstruct/ap/test/bugs/_1799/Source.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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._1799; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
public class Source { | ||
|
||
private final Date settlementDate; | ||
private final String getawayLocation; | ||
|
||
public Source(Date settlementDate, String getawayLocation) { | ||
this.settlementDate = settlementDate; | ||
this.getawayLocation = getawayLocation; | ||
} | ||
|
||
public Date getSettlementDate() { | ||
return settlementDate; | ||
} | ||
|
||
public String getGetawayLocation() { | ||
return getawayLocation; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
processor/src/test/java/org/mapstruct/ap/test/bugs/_1799/Target.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* 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._1799; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
public class Target { | ||
|
||
private final Date settlementDate; | ||
private final String getawayLocation; | ||
|
||
public Target(Builder builder) { | ||
this.settlementDate = builder.settlementDate; | ||
this.getawayLocation = builder.getawayLocation; | ||
} | ||
|
||
public Date getSettlementDate() { | ||
return settlementDate; | ||
} | ||
|
||
public String getGetawayLocation() { | ||
return getawayLocation; | ||
} | ||
|
||
public static Target.Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder { | ||
|
||
private Date settlementDate; | ||
private String getawayLocation; | ||
|
||
public Builder settlementDate(Date settlementDate) { | ||
this.settlementDate = settlementDate; | ||
return this; | ||
} | ||
|
||
public Builder getawayLocation(String getawayLocation) { | ||
this.getawayLocation = getawayLocation; | ||
return this; | ||
} | ||
|
||
public Target build() { | ||
return new Target( this ); | ||
} | ||
} | ||
} |