use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows_NoHours_ProjectsAreClosed.
@Test
public void testBuildSpreadSheetRows_NoHours_ProjectsAreClosed() throws NoSuchFieldException {
List<Employee> teamMembers = asList(employee1);
HourType hourType1 = new HourType("hourType1");
HourType hourType2 = new HourType("hourType2");
Project project1 = buildProject(1L, teamMembers, asList(hourType1, hourType2), Project.Status.CLOSED, null);
Project project2 = buildProject(2L, teamMembers, asList(hourType1), Project.Status.CLOSED, null);
Filter filter = new Filter();
setField(spreadSheet, "filter", filter);
expect(hoursService.getHours(filter)).andReturn(emptyList());
List<Project> managedProjects = asList(project1, project2);
expect(projectService.getEffortsProjects(filter)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(managedProjects)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(emptyList())).andReturn(emptyList());
replay(hoursService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows();
verify(hoursService, projectService);
assertTrue(actual.isEmpty());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows_NoHours_FilterByHourTypes_HourTypesInProjectsEqualToHourTypesInFilter.
@Test
public void testBuildSpreadSheetRows_NoHours_FilterByHourTypes_HourTypesInProjectsEqualToHourTypesInFilter() throws NoSuchFieldException {
List<Employee> teamMembers = asList(employee1);
HourType hourType1 = new HourType("hourType1");
HourType hourType2 = new HourType("hourType2");
Project project1 = buildProject(1L, teamMembers, asList(hourType1, hourType2), ACTIVE, null);
Project project2 = buildProject(2L, teamMembers, asList(hourType1), ACTIVE, null);
Project subproject = buildProject(3L, teamMembers, asList(hourType1), ACTIVE, project1);
SpreadSheet.HoursIndexedBundle indexedHours = spreadSheet.new HoursIndexedBundle(emptyList());
Filter filter = new Filter();
filter.setHourTypes(asList(hourType1, hourType2));
setField(spreadSheet, "filter", filter);
expect(hoursService.getHours(filter)).andReturn(emptyList());
List<Project> managedProjects = asList(project1, project2, subproject);
expect(projectService.getEffortsProjects(filter)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(managedProjects)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(emptyList())).andReturn(emptyList());
replay(hoursService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows();
verify(hoursService, projectService);
assertEquals(13, actual.size());
assertRowMatch(actual.get(0), project1, null, null, emptyList());
assertRowMatch(actual.get(1), project1, employee1, hourType1, emptyList());
assertRowMatch(actual.get(2), project1, employee1, hourType2, emptyList());
assertRowMatch(actual.get(3), project1, null, hourType1, emptyList());
assertRowMatch(actual.get(4), project1, null, hourType2, emptyList());
assertRowMatch(actual.get(5), subproject, null, null, emptyList());
assertRowMatch(actual.get(6), subproject, employee1, hourType1, emptyList());
assertRowMatch(actual.get(7), subproject, null, hourType1, emptyList());
assertRowMatch(actual.get(8), project1, null, hourType1, emptyList());
assertRowMatch(actual.get(9), project1, null, hourType2, emptyList());
assertRowMatch(actual.get(10), project2, null, null, emptyList());
assertRowMatch(actual.get(11), project2, employee1, hourType1, emptyList());
assertRowMatch(actual.get(12), project2, null, hourType1, emptyList());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows_NoHours_FilterByHourTypes_HourTypesInProjectsNotEqualToHourTypesInFilter.
@Test
public void testBuildSpreadSheetRows_NoHours_FilterByHourTypes_HourTypesInProjectsNotEqualToHourTypesInFilter() throws NoSuchFieldException {
List<Employee> teamMembers = asList(employee1);
HourType hourType1 = new HourType("hourType1");
HourType hourType2 = new HourType("hourType2");
Project project1 = buildProject(1L, teamMembers, asList(hourType1, hourType2), ACTIVE, null);
Project project2 = buildProject(2L, teamMembers, asList(hourType1), ACTIVE, null);
Project subproject = buildProject(3L, teamMembers, asList(hourType1), ACTIVE, project1);
SpreadSheet.HoursIndexedBundle indexedHours = spreadSheet.new HoursIndexedBundle(emptyList());
Filter filter = new Filter();
filter.setHourTypes(asList(hourType2));
setField(spreadSheet, "filter", filter);
expect(hoursService.getHours(filter)).andReturn(emptyList());
List<Project> managedProjects = asList(project1, project2, subproject);
expect(projectService.getEffortsProjects(filter)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(managedProjects)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(emptyList())).andReturn(emptyList());
replay(hoursService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows();
verify(hoursService, projectService);
assertEquals(8, actual.size());
assertRowMatch(actual.get(0), project1, null, null, emptyList());
assertRowMatch(actual.get(1), project1, employee1, hourType2, emptyList());
assertRowMatch(actual.get(2), project1, null, hourType2, emptyList());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows_TeamMembersNotSorted.
@Test
public void testBuildSpreadSheetRows_TeamMembersNotSorted() throws NoSuchFieldException {
HourType hourType = filter.getHourTypes().get(0);
Project project = buildProject(1L, asList(employee1, employee2, employee3), asList(hourType), ACTIVE, null);
Filter overrideFilter = new Filter();
overrideFilter.setHourTypes(asList(hourType));
overrideFilter.setEmployees(asList(employee1, employee2, employee3));
overrideFilter.setProjects(asList(project));
setField(spreadSheet, "filter", overrideFilter);
project.addManager(employee1);
List<Hours> hours = getHours(asList(project));
List<Employee> availableEmployees = asList(employee1, employee2, employee3);
expect(hoursService.getHours(overrideFilter)).andReturn(hours);
List<Project> managedProjects = asList(project);
expect(projectService.getEffortsProjects(overrideFilter)).andReturn(managedProjects);
EasyMock.expect(projectService.fetchComplete(managedProjects)).andReturn(managedProjects).anyTimes();
replay(hoursService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows();
verify(hoursService, projectService);
assertEquals(5, actual.size());
assertRowMatch(actual.get(0), project, null, null, emptyList());
assertRowMatch(actual.get(1), project, employee1, hourType, findHours(hours, project, employee1, hourType));
assertRowMatch(actual.get(2), project, employee2, hourType, findHours(hours, project, employee2, hourType));
assertRowMatch(actual.get(3), project, employee3, hourType, findHours(hours, project, employee3, hourType));
assertRowMatch(actual.get(4), project, null, hourType, emptyList());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class ProjectEffortsSpreadSheetTest method testBuildSpreadSheetRows_NoHours_FilterByEmployees_EmployeesInProjectsNotEqualToEmployeesInFilter.
@Test
public void testBuildSpreadSheetRows_NoHours_FilterByEmployees_EmployeesInProjectsNotEqualToEmployeesInFilter() throws NoSuchFieldException {
List<Employee> teamMembers = asList(employee1);
HourType hourType1 = new HourType("hourType1");
HourType hourType2 = new HourType("hourType2");
Project project1 = buildProject(1L, teamMembers, asList(hourType1, hourType2), ACTIVE, null);
Project project2 = buildProject(2L, teamMembers, asList(hourType1), ACTIVE, null);
Project subproject = buildProject(3L, teamMembers, asList(hourType1), ACTIVE, project1);
Filter filter = new Filter();
setField(spreadSheet, "filter", filter);
expect(hoursService.getHours(filter)).andReturn(emptyList());
expect(projectService.getEffortsProjects(filter)).andReturn(emptyList());
EasyMock.expect(projectService.fetchComplete(eq(emptyList()))).andReturn(emptyList()).anyTimes();
replay(hoursService, projectService);
List<SpreadSheetRow<?>> actual = spreadSheet.buildSpreadSheetRows();
verify(hoursService, projectService);
assertEquals(0, actual.size());
}
Aggregations