use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class SpreadSheetTest method testGetSortedTeamMembers_FilterHasEmployeesAndHasNoDepartments.
@Test
public void testGetSortedTeamMembers_FilterHasEmployeesAndHasNoDepartments() throws NoSuchFieldException {
List<Employee> employees = buildEmployeeList(2);
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = createProject("1", hourTypes, employees);
List<Hours> hours = buildHourList(project, employees, hourType, new Date(2017, 1, 1));
setField(filter, "employees", employees);
setField(filter, "departments", new ArrayList<>());
setField(spreadSheet, "filter", filter);
setField(spreadSheet, "workTimeService", workTimeService);
expect(workTimeService.getEmployees(filter)).andReturn(employees);
replay(workTimeService);
SortedSet<Employee> expected = new TreeSet<>(Employee.NAME_COMPARATOR);
expected.addAll(employees);
SortedSet<Employee> actual = spreadSheet.getSortedTeamMembers(project, hours);
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class SpreadSheetTest method createProject.
private Project createProject(String code, List<HourType> hourTypes, List<Employee> employees) {
Project project = new Project();
project.setAccountableHours(hourTypes);
project.setCode(code);
project.getTeam().addAll(employees);
return project;
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class SpreadSheetTest method testGetSortedProjects_FilterHasNoProjects.
@Test
public void testGetSortedProjects_FilterHasNoProjects() throws NoSuchFieldException {
List<Employee> employees = new ArrayList<>();
List<HourType> hourTypes = new ArrayList<>();
List<Project> expected = buildProjectList(2, hourTypes, employees);
setField(filter, "projects", new ArrayList<>());
setField(spreadSheet, "filter", filter);
setField(spreadSheet, "projectRepository", projectRepository);
setField(spreadSheet, "projectService", projectService);
expect(projectRepository.fetchComplete(expected)).andReturn(expected);
expect(projectService.getAvailableProjects(anyObject())).andReturn(expected);
replay(projectRepository, projectService);
List<Project> actual = spreadSheet.getSortedProjects(new Employee());
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class SpreadSheetTest method testGetSortedTeamMembers_FilterHasEmployeesAndDepartments.
@Test
public void testGetSortedTeamMembers_FilterHasEmployeesAndDepartments() throws NoSuchFieldException {
List<Employee> employees = buildEmployeeList(2);
List<String> departments = employees.stream().map(Employee::getDepartment).collect(Collectors.toList());
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = createProject("1", hourTypes, employees);
List<Hours> hours = buildHourList(project, employees, hourType, new Date(2017, 1, 1));
setField(filter, "employees", employees);
setField(filter, "departments", departments);
setField(spreadSheet, "filter", filter);
setField(spreadSheet, "workTimeService", workTimeService);
expect(workTimeService.getEmployees(filter)).andReturn(employees);
replay(workTimeService);
SortedSet<Employee> expected = new TreeSet<>(Employee.NAME_COMPARATOR);
expected.addAll(employees);
SortedSet<Employee> actual = spreadSheet.getSortedTeamMembers(project, hours);
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class SpreadSheetTest method testGetSortedTeamMembers_FilterHasEmployeesNotCorrespondingToDepartments.
@Test
public void testGetSortedTeamMembers_FilterHasEmployeesNotCorrespondingToDepartments() throws NoSuchFieldException {
List<Employee> employees = buildEmployeeList(2);
List<String> departments = asList("dep1", "dep2");
HourType hourType = new HourType("1");
List<HourType> hourTypes = Collections.singletonList(hourType);
Project project = createProject("1", hourTypes, employees);
List<Hours> hours = buildHourList(project, employees, hourType, new Date(2017, 1, 1));
setField(filter, "employees", employees);
setField(filter, "departments", departments);
setField(spreadSheet, "filter", filter);
setField(spreadSheet, "employeeRepository", employeeRepository);
setField(spreadSheet, "workTimeService", workTimeService);
expect(workTimeService.getEmployees(filter)).andReturn(Collections.emptyList());
replay(workTimeService);
SortedSet<Employee> actual = spreadSheet.getSortedTeamMembers(project, hours);
assertTrue(actual.isEmpty());
}
Aggregations