public void shouldMap() { SourceParent source = new SourceParent(); source.children = Arrays.asList(new SourceChild("abc"), new SourceChild("def")); DestParent1 dest = modelMapper.map(source, DestParent1.class); assertEquals(dest.children.get(0).name, "abc"); assertEquals(dest.children.get(1).name, "def"); }
public void shouldMapWithPropertyMap() { SourceParent source = new SourceParent(); source.children = Arrays.asList(new SourceChild("abc"), new SourceChild("def")); modelMapper.addMappings( new PropertyMap<SourceParent, DestParent2>() { protected void configure() { map(source.getChildren()).setKids(null); } }); DestParent2 dest = modelMapper.map(source, DestParent2.class); assertEquals(dest.kids.get(0).name, "abc"); assertEquals(dest.kids.get(1).name, "def"); }