assertEquals(e1.getId(), e2.getId());
}
public void testMergeMaps() throws Exception {
OfficeImpl o1 = new OfficeImpl("o1", "Office 1");
ManagerImpl m1 = new ManagerImpl("m1");
EmployeeImpl e1 = new EmployeeImpl("e1");
o1.setId(new Long(1));
e1.setId(new Long(2));
e1.setOffice(o1);
m1.setId(new Long(1));
m1.addManagedEmployee(e1);
m1.setOffice(o1);
OfficeImpl o2 = new OfficeImpl("o1", "Office 1");
ManagerImpl m2 = new ManagerImpl("m1");
EmployeeImpl e2 = new EmployeeImpl("e1");
e2.setOffice(o2);
m2.addManagedEmployee(e2);
m2.setOffice(o2);
assertNull(o2.getId());
assertNull(m2.getId());
assertNull(e2.getId());
Map emps1 = new HashMap();
Map emps2 = new HashMap();
emps1.put(e1.getMatriculationCode(), e1);
emps1.put(m1.getMatriculationCode(), m1);
emps2.put(e2.getMatriculationCode(), e2);
emps2.put(m2.getMatriculationCode(), m2);
this.merger.merge(emps1, emps2);
assertNotNull(o2.getId());
assertNotNull(m2.getId());
assertNotNull(e2.getId());
}