Browse Source

nested bean mapper test

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2071 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Keith Donald 17 years ago
parent
commit
cc0959b59d
  1. 25
      org.springframework.context/src/test/java/org/springframework/mapping/support/SpelMapperTests.java

25
org.springframework.context/src/test/java/org/springframework/mapping/support/SpelMapperTests.java

@ -146,6 +146,31 @@ public class SpelMapperTests { @@ -146,6 +146,31 @@ public class SpelMapperTests {
assertEquals("bar", target.nested.foo);
}
@Test
public void mapBeanNestedCustomMapper() {
PersonDto source = new PersonDto();
NestedDto nested = new NestedDto();
nested.foo = "bar";
source.setNested(nested);
Person target = new Person();
SpelMapper nestedMapper = new SpelMapper();
nestedMapper.setAutoMappingEnabled(false);
nestedMapper.addMapping("foo").setConverter(new Converter<String, String>() {
public String convert(String source) {
return source + " and baz";
}
});
mapper.addNestedMapper(NestedDto.class, Nested.class, nestedMapper);
mapper.setAutoMappingEnabled(false);
mapper.addMapping("nested");
mapper.map(source, target);
assertEquals("bar and baz", target.nested.foo);
}
@Test
public void mapList() {
PersonDto source = new PersonDto();

Loading…
Cancel
Save