eMap.getItems().put(eItem1, "itm1");
eMap.getItems().put(eItem2, "itm2");
final DtoMapByKeyIterface dMap = new DtoMapToMapByKeyClass();
final Assembler assembler = DTOAssembler.newAssembler(dMap.getClass(), eMap.getClass());
assembler.assembleDto(dMap, eMap, null, new BeanFactory() {
public Class getClazz(final String entityBeanKey) {
if ("dtoItem".equals(entityBeanKey)) {
return DtoItemClass.class;
}
return null;
}
public Object get(final String entityBeanKey) {
if ("dtoItem".equals(entityBeanKey)) {
return new DtoItemClass();
}
return null;
}
});
assertNotNull(dMap.getItems());
assertEquals(2, dMap.getItems().size());
final Set<DtoItemIterface> keys = dMap.getItems().keySet();
DtoItemIterface dItem1 = null;
DtoItemIterface dItem2 = null;
for (DtoItemIterface key : keys) {
if ("itm1".equals(key.getName())) {
assertEquals("itm1", dMap.getItems().get(key));
dItem1 = key;
} else if ("itm2".equals(key.getName())) {
assertEquals("itm2", dMap.getItems().get(key));
dItem2 = key;
} else {
fail("Unknown key");
}
}
final DtoItemClass dto3 = new DtoItemClass();
dto3.setName("itm3");
dMap.getItems().put(dto3, "itm3");
dMap.getItems().put(dItem2, "itm no 2");
dMap.getItems().remove(dItem1); // first
assembler.assembleEntity(dMap, eMap, null, new BeanFactory() {
public Class getClazz(final String entityBeanKey) {
if ("entityItem".equals(entityBeanKey)) {
return EntityItemInterface.class;
}