use of com.artezio.arttime.datamodel.Employee 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.Employee 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)));
}
use of com.artezio.arttime.datamodel.Employee 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.Employee in project ART-TIME by Artezio.
the class SpreadSheetTest method buildEmployeeList.
private List<Employee> buildEmployeeList(int size) {
List<Employee> result = new LinkedList<>();
for (int i = 0; i < size; i++) {
String testValue = String.valueOf(i);
result.add(new Employee(testValue, testValue, testValue, testValue, testValue));
}
return result;
}
use of com.artezio.arttime.datamodel.Employee 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);
}
Aggregations