Search in sources :

Example 21 with Employee

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());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) Test(org.junit.Test)

Example 22 with Employee

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

Example 23 with Employee

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Test(org.junit.Test)

Example 24 with Employee

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;
}
Also used : Employee(com.artezio.arttime.datamodel.Employee)

Example 25 with Employee

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Hours(com.artezio.arttime.datamodel.Hours) Test(org.junit.Test)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)339 Test (org.junit.Test)300 Project (com.artezio.arttime.datamodel.Project)196 HourType (com.artezio.arttime.datamodel.HourType)115 Hours (com.artezio.arttime.datamodel.Hours)101 Date (java.util.Date)67 Period (com.artezio.arttime.datamodel.Period)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)52 BigDecimal (java.math.BigDecimal)45 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)27 Filter (com.artezio.arttime.filter.Filter)26 ArrayList (java.util.ArrayList)24 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)22 HashMap (java.util.HashMap)21 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)21 WorkdaysCalendar (com.artezio.arttime.datamodel.WorkdaysCalendar)16 Arrays.asList (java.util.Arrays.asList)15 List (java.util.List)15 Map (java.util.Map)15 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13