*/
@Test
public void testDtoEntityClassGenericMapping() throws GeDAException {
final TestDto18Class dto = new TestDto18Class();
final TestEntity18Class entity = new TestEntity18Class();
final Assembler assembler = DTOAssembler.newCustomAssembler(dto.getClass(), entity.getClass(), synthesizer);
final TestDto18aClass<String> item = new TestDto18aClass<String>();
item.setMyProp("item");
dto.setMyProp("prop");
final List<TestDto18aClass<String>> coll = new ArrayList<TestDto18aClass<String>>();
coll.add(item);
dto.setMyColl(coll);
final Map<String, TestDto18aClass<String>> map = new HashMap<String, TestDto18aClass<String>>();
map.put("m1", item);
dto.setMyMap(map);
assembler.assembleEntity(dto, entity, null, new BeanFactory() {
public Class getClazz(final String entityBeanKey) {
return null;
}
public Object get(final String entityBeanKey) {
return new TestEntity18aClass<String>();
}
});
assertEquals("prop", entity.getMyProp());
assertNotNull(entity.getMyColl());
assertNotSame(dto.getMyColl(), entity.getMyColl());
assertEquals(1, entity.getMyColl().size());
assertEquals("item", entity.getMyColl().iterator().next().getMyProp());
assertNotNull(entity.getMyMap());
assertNotSame(dto.getMyMap(), entity.getMyMap());
assertEquals(1, entity.getMyMap().size());
assertEquals("item", entity.getMyMap().iterator().next().getMyProp());
entity.setMyProp("e1");
entity.getMyColl().iterator().next().setMyProp("ci1");
entity.getMyMap().iterator().next().setMyProp("mi1");
assembler.assembleDto(dto, entity, null, new BeanFactory() {
public Class getClazz(final String entityBeanKey) {
return null;
}
public Object get(final String entityBeanKey) {
return new TestDto18aClass<String>();
}
});
assertEquals("e1", dto.getMyProp());
assertNotNull(dto.getMyColl());
assertNotSame(dto.getMyColl(), entity.getMyColl());
assertEquals(1, dto.getMyColl().size());
assertEquals("ci1", dto.getMyColl().iterator().next().getMyProp());
assertNotNull(entity.getMyMap());
assertNotSame(dto.getMyMap(), entity.getMyMap());
assertEquals(1, dto.getMyMap().size());
assertTrue(dto.getMyMap().containsKey("mi1"));
assertEquals("mi1", dto.getMyMap().get("mi1").getMyProp());