forked from elaatifi/orika
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #315 from yupengj/master
Issue314TestCase and override exclude method
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 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
56 changes: 56 additions & 0 deletions
56
tests/src/main/java/ma/glasnost/orika/test/community/Issue314TestCase.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,56 @@ | ||
package ma.glasnost.orika.test.community; | ||
|
||
import static org.junit.Assert.assertNull; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
|
||
import ma.glasnost.orika.impl.DefaultMapperFactory; | ||
|
||
/** | ||
* ClassMapBuilderForMaps class exclude method Does not work | ||
* <p> | ||
* | ||
* @see <a href= | ||
* "https://github.com/orika-mapper/orika/issues/314">https://github.com/orika-mapper/orika/issues</a> | ||
*/ | ||
public class Issue314TestCase { | ||
|
||
@Test | ||
public void exclude_classMapBuilderForMaps() { | ||
|
||
DefaultMapperFactory mapperFactory = new DefaultMapperFactory.Builder().build(); | ||
mapperFactory.classMap(Map.class, B.class).exclude("b").byDefault().register(); | ||
|
||
Map<String, Object> map = new HashMap<String, Object>(); | ||
map.put("a", "a"); | ||
map.put("b", "b"); | ||
|
||
B b = mapperFactory.getMapperFacade().map(map, B.class); | ||
assertNull(b.getB()); | ||
} | ||
|
||
public static class B { | ||
private String a; | ||
private String b; | ||
|
||
public String getA() { | ||
return a; | ||
} | ||
|
||
public void setA(String a) { | ||
this.a = a; | ||
} | ||
|
||
public String getB() { | ||
return b; | ||
} | ||
|
||
public void setB(String b) { | ||
this.b = b; | ||
} | ||
} | ||
|
||
} |