LogUtil.info(getClass().getName(), "testOrganizationChart: assign user to dept");
addEmployment(TEST_USER, TEST_DEPARTMENT_CHILD, TEST_ORGANIZATION);
Collection<User> userHodList = directoryManager.getUserHod(TEST_USER);
String usernameHod = null;
if (userHodList != null && !userHodList.isEmpty()) {
User userHod = userHodList.iterator().next();
usernameHod = userHod.getUsername();
}
Assert.isTrue(TEST_DEPARTMENT_CHILD_HOD.equals(usernameHod));
// unassign dept HOD
LogUtil.info(getClass().getName(), "testOrganizationChart: unassign dept HOD");
employmentDao.unassignUserAsDepartmentHOD(TEST_DEPARTMENT_CHILD_HOD, TEST_DEPARTMENT_CHILD);
userHodList = directoryManager.getUserHod(TEST_USER);
usernameHod = null;
if (userHodList != null && !userHodList.isEmpty()) {
User userHod = userHodList.iterator().next();
usernameHod = userHod.getUsername();
}
Assert.isTrue(TEST_DEPARTMENT_PARENT_HOD.equals(usernameHod));
// set user direct report to HOD
LogUtil.info(getClass().getName(), "testOrganizationChart: set user direct report to HOD");
addEmployment(TEST_USER_HOD, TEST_DEPARTMENT_CHILD, TEST_ORGANIZATION);
employmentDao.assignUserReportTo(TEST_USER, TEST_USER_HOD);
userHodList = directoryManager.getUserHod(TEST_USER);
User userHod = userHodList.iterator().next();
Assert.isTrue(TEST_USER_HOD.equals(userHod.getUsername()));
}