ContactMapperEx extends ContactMapper { @Override public void mapContactInclHistory(Contact source, ContactDto target) { super.mapContactInclHistory(source, target); Iterator<HistoryDto> targetHistoryIterator = target.getHistory().iterator(); boolean didAdd = false; for (History history : source.getHistory()) { HistoryDto targetHistoryDto; if ((!didAdd) && targetHistoryIterator.hasNext()) { targetHistoryDto = targetHistoryIterator.next(); } else { targetHistoryDto = createHistoryDto(); target.getHistory().add(targetHistoryDto); didAdd = true; } createHistoryMapper().mapContactInclHistory(history, targetHistoryDto); } } ContactMapperEx(); @Override void mapContactInclHistory(Contact source, ContactDto target);  }
@Test public void testMapContactInclHistory() { ContactDto dto = new ContactDto(); mapper.mapContactInclHistory(contactRef, dto); assertEquals(3, dto.getId()); assertEquals("Hans Hummel", dto.getName()); assertEquals(2, dto.getRevision()); assertEquals(1, dto.getHistory().size()); assertEquals(33, dto.getHistory().get(0).getId()); assertEquals("mors, mors", dto.getHistory().get(0).getText()); assertEquals(dateRef, dto.getHistory().get(0).getTimestamp()); }