use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetEmployees_FilterHasNoEmployeesAndHasNoDepartments.
@Test
public void testGetEmployees_FilterHasNoEmployeesAndHasNoDepartments() throws NoSuchFieldException {
Employee emp1 = new Employee();
emp1.setDepartment("dep1");
Employee emp2 = new Employee();
emp2.setDepartment("dep2");
List<Employee> employees = Arrays.asList(emp1, emp2);
Filter filter = new Filter();
filter.setEmployees(Collections.emptyList());
filter.setDepartments(Collections.emptyList());
setField(workTimeService, "employeeRepository", employeeRepository);
expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
replay(employeeRepository);
List<Employee> actual = workTimeService.getEmployees(filter);
ListAssert.assertEquals(employees, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetEmployees_FilterHasEmployeesCorrespondingToDepartments.
@Test
public void testGetEmployees_FilterHasEmployeesCorrespondingToDepartments() {
Employee emp1 = new Employee();
emp1.setDepartment("dep1");
Employee emp2 = new Employee();
emp2.setDepartment("dep2");
List<Employee> employees = Arrays.asList(emp1, emp2);
List<String> departments = Arrays.asList("dep1", "dep2");
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setDepartments(departments);
List<Employee> expected = filter.getEmployees();
List<Employee> actual = workTimeService.getEmployees(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetApprovedWorkTimeProblems_existProblems.
@Test
public void testGetApprovedWorkTimeProblems_existProblems() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(1);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Employee employee = new Employee("employee", "name", "lastname", "mail");
employee.setCalendar(calendar);
employee.setWorkLoad(100);
List<Employee> employees = Arrays.asList(employee);
Day day1 = new Day(new Date(), calendar, true);
Day day2 = new Day(getOffsetDate(1), calendar, true);
Project project = new Project();
project.addTeamMember(employee);
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity1 = new BigDecimal(3);
BigDecimal quantity2 = new BigDecimal(10);
Hours hours1 = createHours(project, employee, new Date(), actualType, quantity1);
Hours hours2 = createHours(project, employee, getOffsetDate(1), actualType, quantity2);
hours1.setApproved(true);
hours2.setApproved(true);
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setCustomPeriod(period);
entityManager.persist(employee);
entityManager.persist(calendar);
entityManager.persist(actualType);
entityManager.persist(project);
entityManager.persist(hours1);
entityManager.persist(hours2);
entityManager.persist(day1);
entityManager.persist(day2);
entityManager.flush();
entityManager.clear();
setField(workTimeService, "employeeRepository", employeeRepository);
expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
replay(employeeRepository);
List<WorkTimeService.Efforts> actuals = workTimeService.getEmployeesTimeProblems(filter);
WorkTimeService.Efforts actual = actuals.get(0);
assertEquals(1, actuals.size());
assertEquals(employee, actual.getEmployee());
assertEquals(new BigDecimal("16.00"), actual.getRequiredTime());
assertEquals(new BigDecimal("13.00"), actual.getApprovedTime());
assertEquals(new BigDecimal("-3.00"), actual.getTimeDeviation());
assertEquals(BigDecimal.ZERO, actual.getUnapprovedTime());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetEmployees_FilterHasNoEmployeesAndHasDepartments.
@Test
public void testGetEmployees_FilterHasNoEmployeesAndHasDepartments() throws NoSuchFieldException {
Employee emp1 = new Employee();
emp1.setDepartment("dep1");
Employee emp2 = new Employee();
emp2.setDepartment("dep2");
List<Employee> employees = Arrays.asList(emp1, emp2);
List<String> departments = Arrays.asList("dep1", "dep2");
Filter filter = new Filter();
filter.setEmployees(Collections.emptyList());
filter.setDepartments(departments);
setField(workTimeService, "employeeRepository", employeeRepository);
expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
replay(employeeRepository);
List<Employee> actual = workTimeService.getEmployees(filter);
ListAssert.assertEquals(employees, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetEmployees_FilterHasEmployeesNotCorrespondingToDepartments.
@Test
public void testGetEmployees_FilterHasEmployeesNotCorrespondingToDepartments() {
Employee emp1 = new Employee();
emp1.setDepartment("dep1");
Employee emp2 = new Employee();
emp2.setDepartment("dep2");
List<Employee> employees = Arrays.asList(emp1, emp2);
List<String> departments = Arrays.asList("dep3", "dep4");
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setDepartments(departments);
List<Employee> result = workTimeService.getEmployees(filter);
assertTrue(result.isEmpty());
}
Aggregations