Search in sources :

Example 31 with Project

use of com.artezio.arttime.datamodel.Project 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)

Example 32 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

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

Example 33 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class SpreadSheetTest method testGetSortedProjects_FilterHasNoProjects.

@Test
public void testGetSortedProjects_FilterHasNoProjects() throws NoSuchFieldException {
    List<Employee> employees = new ArrayList<>();
    List<HourType> hourTypes = new ArrayList<>();
    List<Project> expected = buildProjectList(2, hourTypes, employees);
    setField(filter, "projects", new ArrayList<>());
    setField(spreadSheet, "filter", filter);
    setField(spreadSheet, "projectRepository", projectRepository);
    setField(spreadSheet, "projectService", projectService);
    expect(projectRepository.fetchComplete(expected)).andReturn(expected);
    expect(projectService.getAvailableProjects(anyObject())).andReturn(expected);
    replay(projectRepository, projectService);
    List<Project> actual = spreadSheet.getSortedProjects(new Employee());
    assertEquals(expected, actual);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Test(org.junit.Test)

Example 34 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class SpreadSheetTest method testGetSortedTeamMembers_FilterHasEmployeesAndDepartments.

@Test
public void testGetSortedTeamMembers_FilterHasEmployeesAndDepartments() throws NoSuchFieldException {
    List<Employee> employees = buildEmployeeList(2);
    List<String> departments = employees.stream().map(Employee::getDepartment).collect(Collectors.toList());
    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", departments);
    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)

Example 35 with Project

use of com.artezio.arttime.datamodel.Project in project ART-TIME by Artezio.

the class SpreadSheetTest method testGetSortedTeamMembers_FilterHasEmployeesNotCorrespondingToDepartments.

@Test
public void testGetSortedTeamMembers_FilterHasEmployeesNotCorrespondingToDepartments() throws NoSuchFieldException {
    List<Employee> employees = buildEmployeeList(2);
    List<String> departments = asList("dep1", "dep2");
    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", departments);
    setField(spreadSheet, "filter", filter);
    setField(spreadSheet, "employeeRepository", employeeRepository);
    setField(spreadSheet, "workTimeService", workTimeService);
    expect(workTimeService.getEmployees(filter)).andReturn(Collections.emptyList());
    replay(workTimeService);
    SortedSet<Employee> actual = spreadSheet.getSortedTeamMembers(project, hours);
    assertTrue(actual.isEmpty());
}
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

Project (com.artezio.arttime.datamodel.Project)310 Test (org.junit.Test)278 Employee (com.artezio.arttime.datamodel.Employee)195 HourType (com.artezio.arttime.datamodel.HourType)119 Hours (com.artezio.arttime.datamodel.Hours)108 Date (java.util.Date)61 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)56 Period (com.artezio.arttime.datamodel.Period)43 BigDecimal (java.math.BigDecimal)39 Filter (com.artezio.arttime.filter.Filter)33 TeamFilter (com.artezio.arttime.datamodel.TeamFilter)26 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 CalendarUtils.createPeriod (com.artezio.arttime.test.utils.CalendarUtils.createPeriod)21 ArrayList (java.util.ArrayList)18 Arrays.asList (java.util.Arrays.asList)18 ProjectRepository (com.artezio.arttime.repositories.ProjectRepository)17 List (java.util.List)17 HoursRepository (com.artezio.arttime.repositories.HoursRepository)13 HashMap (java.util.HashMap)13 Map (java.util.Map)11