forked from mapstruct/mapstruct
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mapstruct#1790 Use mapperPrism.values.nullValuePropertyMappingStrateg…
…y when retrieving NullValuePropertyMappingStrategy
- Loading branch information
Showing
6 changed files
with
123 additions
and
1 deletion.
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
16 changes: 16 additions & 0 deletions
16
processor/src/test/java/org/mapstruct/ap/test/bugs/_1790/Issue1790Config.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,16 @@ | ||
/* | ||
* 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._1790; | ||
|
||
import org.mapstruct.MapperConfig; | ||
import org.mapstruct.NullValueCheckStrategy; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@MapperConfig(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) | ||
public interface Issue1790Config { | ||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/org/mapstruct/ap/test/bugs/_1790/Issue1790Mapper.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,22 @@ | ||
/* | ||
* 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._1790; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.MappingTarget; | ||
import org.mapstruct.NullValuePropertyMappingStrategy; | ||
import org.mapstruct.factory.Mappers; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
@Mapper(config = Issue1790Config.class, nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE) | ||
public interface Issue1790Mapper { | ||
|
||
Issue1790Mapper INSTANCE = Mappers.getMapper( Issue1790Mapper.class ); | ||
|
||
void toExistingCar(@MappingTarget Target target, Source source); | ||
} |
40 changes: 40 additions & 0 deletions
40
processor/src/test/java/org/mapstruct/ap/test/bugs/_1790/Issue1790Test.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,40 @@ | ||
/* | ||
* 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._1790; | ||
|
||
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 | ||
*/ | ||
@IssueKey("1790") | ||
@RunWith(AnnotationProcessorTestRunner.class) | ||
@WithClasses({ | ||
Issue1790Config.class, | ||
Issue1790Mapper.class, | ||
Source.class, | ||
Target.class, | ||
}) | ||
public class Issue1790Test { | ||
|
||
@Test | ||
public void shouldProperlyApplyNullValuePropertyMappingStrategyWhenInheriting() { | ||
Target target = new Target(); | ||
target.setName( "My name is set" ); | ||
|
||
Source source = new Source(); | ||
|
||
Issue1790Mapper.INSTANCE.toExistingCar( target, source ); | ||
|
||
assertThat( target.getName() ).isEqualTo( "My name is set" ); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/org/mapstruct/ap/test/bugs/_1790/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,22 @@ | ||
/* | ||
* 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._1790; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
public class Source { | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
processor/src/test/java/org/mapstruct/ap/test/bugs/_1790/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,22 @@ | ||
/* | ||
* 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._1790; | ||
|
||
/** | ||
* @author Filip Hrisafov | ||
*/ | ||
public class Target { | ||
|
||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |