use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testCalculateTotalKeysFor_subproject.
@Test
public void testCalculateTotalKeysFor_subproject() throws NoSuchFieldException {
Project master = new Project();
Project subproject = new Project(master);
setField(master, "id", 1L);
setField(subproject, "id", 2L);
// master head row
HeadSpreadSheetRow row1 = new HeadSpreadSheetRow(master);
// master hours
HoursSpreadSheetRow row2 = new HoursSpreadSheetRow(master, null, null, new ArrayList<>());
// master totals
TotalsSpreadSheetRow row3 = new TotalsSpreadSheetRow(master, null, Arrays.asList(row2));
// subproject head row
HeadSpreadSheetRow row4 = new HeadSpreadSheetRow(subproject);
// subproject hours
HoursSpreadSheetRow row5 = new HoursSpreadSheetRow(subproject, null, null, new ArrayList<>());
// subproject totals
TotalsSpreadSheetRow row6 = new TotalsSpreadSheetRow(subproject, null, Arrays.asList(row5));
// master and subproject totals
TotalsSpreadSheetRow row7 = new TotalsSpreadSheetRow(subproject, null, Arrays.asList(row2, row5));
List<SpreadSheetRow<?>> rows = Arrays.asList(row1, row2, row3, row4, row5, row6, row7);
setField(spreadSheet, "rows", rows);
List<Integer> expected = Arrays.asList(rows.get(5).getKey(), rows.get(6).getKey());
List<Integer> actual = spreadSheet.calculateKeysOfTotalsRows(row5);
assertEquals(2, actual.size());
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.datamodel.Project 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.Project 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.Project in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest 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 ProjectEffortsSpreadSheetTest method testHasTeam.
@Test
public void testHasTeam() throws NoSuchFieldException {
Employee employee = new Employee("employee");
spreadSheet.getFilter().setEmployees(asList(employee));
Project master = createProject("master", emptyList(), asList(employee));
Project subproject = createProject("subproject", emptyList(), asList(employee));
setField(subproject, "master", master);
assertTrue(spreadSheet.hasTeam(master, asList(subproject)));
master.setTeam(emptyList());
assertTrue(spreadSheet.hasTeam(master, asList(subproject)));
subproject.setTeam(emptyList());
assertFalse(spreadSheet.hasTeam(master, asList(subproject)));
}
Aggregations