mapping exclusions

This commit is contained in:
Keith Donald
2009-10-07 19:28:39 +00:00
parent a73324bc24
commit 8fe055b0e0
4 changed files with 44 additions and 10 deletions

View File

@@ -81,6 +81,23 @@ public class SpelMapperTests {
assertEquals(31, target.age);
}
@Test
public void mapAutomaticWithExclusions() {
Map<String, Object> source = new HashMap<String, Object>();
source.put("name", "Keith");
source.put("test", "3");
source.put("favoriteSport", "FOOTBALL");
Person target = new Person();
mapper.addMapping("test").setExclude();
mapper.map(source, target);
assertEquals("Keith", target.name);
assertEquals(0, target.age);
assertEquals(Sport.FOOTBALL, target.favoriteSport);
}
@Test
public void mapSameSourceFieldToMultipleTargets() {
Map<String, Object> source = new HashMap<String, Object>();
@@ -270,7 +287,6 @@ public class SpelMapperTests {
return names[0] + " P. " + names[1];
}
});
mapper.map(source, target);
assertEquals("Keith P. Donald", target.name);