final Integer id = a1.getId();
a1.setName("History 2");
contactDao.update(a1);
HistoryEntry[] historyEntries = contactDao.getHistoryEntries(a1);
assertEquals(2, historyEntries.length);
HistoryEntry entry = historyEntries[0];
log.debug(entry);
assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "name", String.class, "History test", "History 2");
entry = historyEntries[1];
log.debug(entry);
assertHistoryEntry(entry, id, user, HistoryEntryType.INSERT, null, null, null, null);
a1.setTask(getTask("1.2"));
contactDao.update(a1);
historyEntries = contactDao.getHistoryEntries(a1);
assertEquals(3, historyEntries.length);
entry = historyEntries[0];
log.debug(entry);
assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, "task", TaskDO.class, getTask("1.1").getId(), getTask("1.2").getId());
a1.setTask(getTask("1.1"));
a1.setName("History test");
contactDao.update(a1);
historyEntries = contactDao.getHistoryEntries(a1);
assertEquals(4, historyEntries.length);
entry = historyEntries[0];
log.debug(entry);
assertHistoryEntry(entry, id, user, HistoryEntryType.UPDATE, null, null, null, null);
final List<PropertyDelta> delta = entry.getDelta();
assertEquals(2, delta.size());
for (int i = 0; i < 2; i++) {
final PropertyDelta prop = delta.get(0);
if ("name".equals(prop.getPropertyName()) == true) {
assertPropertyDelta(prop, "name", String.class, "History 2", "History test");