mapping exclusions

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2073 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
Keith Donald
2009-10-07 19:28:39 +00:00
parent 5bd6b04d37
commit cabf63b8b1
4 changed files with 44 additions and 10 deletions
@@ -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);