use of com.artezio.arttime.datamodel.HourType 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;
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows.
@Test
public void testBuildSpreadSheetRows() throws ParseException, NoSuchFieldException {
Employee employee1 = filter.getEmployees().get(0);
Employee employee2 = filter.getEmployees().get(1);
Project project1 = filter.getProjects().get(0);
Project project2 = filter.getProjects().get(1);
HourType hourType1 = filter.getHourTypes().get(0);
HourType hourType2 = filter.getHourTypes().get(1);
List<Hours> hours = getHours();
expect(hoursRepository.getHours(filter)).andReturn(hours);
Map<Project, List<Project>> subprojects = createSubprojects();
expect(projectService.getHighlevelOnly(filter.getProjects())).andReturn(filter.getProjects());
expect(projectRepository.getSubprojectsMap(filter.getProjects())).andReturn(subprojects);
expect(workTimeService.getEmployees(filter)).andReturn(Arrays.asList(employee1, employee2)).anyTimes();
replay(hoursRepository, projectRepository, workTimeService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows(new Employee());
verify(hoursRepository, projectRepository);
assertEquals(15, actual.size());
// master project head
assertRowMatch(actual.get(0), project1, null, null, emptyList());
assertRowMatch(actual.get(1), project1, employee1, hourType1, findHours(hours, project1, employee1, hourType1));
assertRowMatch(actual.get(2), project1, employee1, hourType2, findHours(hours, project1, employee1, hourType2));
// master project total1
assertRowMatch(actual.get(3), project1, null, hourType1, emptyList());
// master project total2
assertRowMatch(actual.get(4), project1, null, hourType2, emptyList());
Project subproject = subprojects.get(project1).get(0);
// subproject head
assertRowMatch(actual.get(5), subproject, null, null, emptyList());
assertRowMatch(actual.get(6), subproject, employee1, hourType1, findHours(hours, subproject, employee1, hourType1));
// subproject total
assertRowMatch(actual.get(7), subproject, null, hourType1, emptyList());
// space row
assertRowMatch(actual.get(8), null, null, null, emptyList());
// master project total1
assertRowMatch(actual.get(9), project1, null, hourType1, emptyList());
// master project total2
assertRowMatch(actual.get(10), project1, null, hourType2, emptyList());
// project 2
assertRowMatch(actual.get(11), project2, null, null, emptyList());
assertRowMatch(actual.get(12), project2, employee1, hourType1, findHours(hours, project2, employee1, hourType1));
assertRowMatch(actual.get(13), project2, employee2, hourType1, findHours(hours, project2, employee2, hourType1));
assertRowMatch(actual.get(14), project2, null, hourType1, emptyList());
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class SpreadSheetTest method testGetSortedHourTypes_FilterHasNoHourTypes.
@Test
public void testGetSortedHourTypes_FilterHasNoHourTypes() throws NoSuchFieldException {
List<Employee> employees = new ArrayList<>();
List<HourType> hourTypes = buildHourTypeList(2);
HourType hourType = new HourType("1");
Project project = createProject("1", hourTypes, employees);
List<Hours> hours = buildHourList(project, employees, hourType, null);
setField(filter, "hourTypes", new ArrayList<>());
setField(spreadSheet, "filter", filter);
setField(spreadSheet, "hourTypeRepository", hourTypeRepository);
expect(hourTypeRepository.getAll()).andReturn(hourTypes);
replay(hourTypeRepository);
SortedSet<HourType> expected = new TreeSet<>(HourType.ACTUALTIME_TYPE_COMPARATOR);
expected.addAll(hourTypes);
SortedSet<HourType> actual = spreadSheet.getSortedHourTypes(project, hours);
assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.HourType 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.HourType 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);
}
Aggregations