Search in sources :

Example 41 with Filter

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());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 42 with Filter

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());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 43 with Filter

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());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 44 with Filter

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());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Example 45 with Filter

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());
}
Also used : Filter(com.artezio.arttime.filter.Filter) Test(org.junit.Test)

Aggregations

Filter (com.artezio.arttime.filter.Filter)126 Test (org.junit.Test)110 Project (com.artezio.arttime.datamodel.Project)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Employee (com.artezio.arttime.datamodel.Employee)24 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)16 Date (java.util.Date)9 BigDecimal (java.math.BigDecimal)8 Hours (com.artezio.arttime.datamodel.Hours)7 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)7 HourType (com.artezio.arttime.datamodel.HourType)5 Efforts (com.artezio.arttime.services.WorkTimeService.Efforts)5 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)5 ArrayList (java.util.ArrayList)4 Collections.emptyList (java.util.Collections.emptyList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Period (com.artezio.arttime.datamodel.Period)3 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)3