@Rollback(true)
public void testOrganizationChart() {
// assign parent department to organization
LogUtil.info(getClass().getName(), "testOrganizationChart: assign parent department to organization");
Department dept = directoryManager.getDepartmentById(TEST_DEPARTMENT_PARENT);
Organization organization = organizationDao.getOrganization(TEST_ORGANIZATION);
dept.setOrganization(organization);
departmentDao.updateDepartment(dept);
Department loadedDept = directoryManager.getDepartmentById(dept.getId());
Assert.isTrue(loadedDept.getOrganization().getId().equals(organization.getId()));
// assign sub-department to parent and organization
LogUtil.info(getClass().getName(), "testOrganizationChart: assign sub-department to parent and organization");
Department child = directoryManager.getDepartmentById(TEST_DEPARTMENT_CHILD);
child.setOrganization(organization);
child.setParent(loadedDept);
departmentDao.updateDepartment(child);
Collection<Department> subDepartments = departmentDao.getDepartmentsByParentId(null, TEST_DEPARTMENT_PARENT, null, null, null, null);
Assert.isTrue(((Department) subDepartments.iterator().next()).getId().equals(child.getId()));
// assign dept HOD
LogUtil.info(getClass().getName(), "testOrganizationChart: assign dept HOD");
addEmployment(TEST_DEPARTMENT_PARENT_HOD, TEST_DEPARTMENT_PARENT, TEST_ORGANIZATION);
employmentDao.assignUserAsDepartmentHOD(TEST_DEPARTMENT_PARENT_HOD, TEST_DEPARTMENT_PARENT);