use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll.
@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_allNew_expectAddAll() throws NoSuchFieldException {
Map<Employee, List<Project>> participations = new HashMap<>();
Employee employee = new Employee();
Project newProject = new Project();
setField(bean, "participations", participations);
setField(bean, "projects", Arrays.asList(newProject));
List<Project> expectedParticipations = Arrays.asList(newProject);
bean.changeRecordWithArrayValueToListValueInParticipations(employee, expectedParticipations);
assertTrue(bean.getParticipations().containsKey(employee));
List<Project> actualParticipations = bean.getParticipations().get(employee);
assertTrue(actualParticipations.contains(newProject));
assertTrue(newProject.isTeamMember(employee));
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ProjectBeanTest method testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove.
@Test
public void testChangeRecordWithArrayValueToListValueInParticipations_someNew_someRemoved_expectAddAndRemove() throws NoSuchFieldException {
Map<Employee, Project[]> participations = new HashMap<>();
Employee employee = new Employee("empl");
Project newProject = new Project();
setField(newProject, "id", 22L);
Project oldProject = new Project();
oldProject.addTeamMember(employee);
setField(oldProject, "id", 33L);
Project oldProject2 = new Project();
oldProject2.addTeamMember(employee);
setField(oldProject2, "id", 44L);
participations.put(employee, new Project[] { newProject, oldProject2 });
setField(bean, "participations", participations);
setField(bean, "projects", Arrays.asList(newProject, oldProject, oldProject2));
List<Project> newParticipations = Arrays.asList(newProject, oldProject2);
bean.changeRecordWithArrayValueToListValueInParticipations(employee, newParticipations);
assertTrue(bean.getParticipations().containsKey(employee));
List<Project> actualParticipations = bean.getParticipations().get(employee);
assertTrue(actualParticipations.contains(newProject));
assertTrue(actualParticipations.contains(oldProject2));
assertFalse(actualParticipations.contains(oldProject));
assertTrue(newProject.isTeamMember(employee));
assertTrue(oldProject2.isTeamMember(employee));
assertFalse(oldProject.isTeamMember(employee));
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ProjectsBeanTest method testGetProjects_ifProjectsNull_andUserInRolePM.
@Test
public void testGetProjects_ifProjectsNull_andUserInRolePM() throws NoSuchFieldException {
List<Project> expected = new ArrayList<Project>();
Employee loggedEmployee = new Employee();
setField(projectBean, "projects", null);
setField(projectBean, "loggedEmployee", loggedEmployee);
setField(projectBean, "externalContext", externalContext);
setField(projectBean, "projectRepository", projectRepository);
expect(externalContext.isUserInRole("exec")).andReturn(false);
expect(projectRepository.getManagedProjects(loggedEmployee)).andReturn(expected);
replay(externalContext, projectRepository);
List<Project> actual = projectBean.getProjects();
verify(externalContext, projectRepository);
assertSame(expected, actual);
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class TimeProblemsNotificationBeanTest method testGetProblematicEmployees_ifNotNull.
@Test
public void testGetProblematicEmployees_ifNotNull() throws Exception {
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
List<WorkTimeService.Efforts> employeesProblemTime = new ArrayList<>();
employeesProblemTime.add(new WorkTimeService.Efforts(employee1));
employeesProblemTime.add(new WorkTimeService.Efforts(employee2));
bean.setEmployeesProblemTime(employeesProblemTime);
List<WorkTimeService.Efforts> actual = bean.getProblematicEmployees();
assertSame(employeesProblemTime, actual);
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method createSubprojects.
private Map<Project, List<Project>> createSubprojects() throws NoSuchFieldException {
HourType hourType = filter.getHourTypes().get(0);
Employee employee = filter.getEmployees().get(0);
Project master = filter.getProjects().get(0);
Project subproject = createProject("subproject", asList(hourType), asList(employee));
setField(subproject, "id", 3L);
setField(subproject, "master", master);
Map<Project, List<Project>> result = filter.getProjects().stream().collect(Collectors.toMap(p -> p, p -> new ArrayList<Project>()));
result.get(master).add(subproject);
return result;
}
Aggregations