use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetApprovedWorkTimeProblems_NoProblems.
@Test
public void testGetApprovedWorkTimeProblems_NoProblems() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(1);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Day day1 = new Day(start, calendar, true);
Day day2 = new Day(getOffsetDate(1), calendar, true);
Employee employee = new Employee("employee");
employee.setCalendar(calendar);
List<Employee> employees = Arrays.asList(employee);
Project project = new Project();
project.addTeamMember(employee);
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
Hours hours1 = createHours(project, employee, start, actualType, new BigDecimal(8));
Hours hours2 = createHours(project, employee, getOffsetDate(1), actualType, new BigDecimal(8));
hours1.setApproved(true);
hours2.setApproved(true);
Filter filter = new Filter();
filter.setCustomPeriod(period);
filter.setEmployees(employees);
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> actual = workTimeService.getEmployeesTimeProblems(filter);
assertTrue(actual.isEmpty());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testGetApprovedWorkTimeProblems_existUnapprovedTime.
@Test
public void testGetApprovedWorkTimeProblems_existUnapprovedTime() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(1);
Period period = new Period(start, finish);
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
Day day1 = new Day(new Date(), calendar, true);
Day day2 = new Day(getOffsetDate(1), calendar, true);
Employee employee = new Employee("employee");
employee.setCalendar(calendar);
Employee manager = new Employee("manager");
List<Employee> employees = Arrays.asList(employee);
Project project = new Project();
project.addTeamMember(employee);
project.addManager(manager);
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(false);
Filter filter = new Filter();
filter.setCustomPeriod(period);
filter.setEmployees(employees);
entityManager.persist(employee);
entityManager.persist(manager);
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("3.00"), actual.getApprovedTime());
assertEquals(new BigDecimal("10.00"), actual.getUnapprovedTime());
assertEquals(new BigDecimal("-13.00"), actual.getTimeDeviation());
assertEquals(Arrays.asList(manager), actual.getWaitingApprovalBy());
assertEquals(Arrays.asList(manager), actual.getAllManagers());
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments.
@Test
public void testGetEmployeesByDepartments() {
Employee employee1 = new Employee("employee1");
employee1.setDepartment("department1");
Employee employee2 = new Employee("employee2");
employee2.setDepartment("department2");
Employee employee3 = new Employee("employee3");
employee3.setDepartment("department3");
Project project1 = new Project();
project1.addTeamMember(employee1);
project1.addTeamMember(employee2);
Project project2 = new Project();
project2.addTeamMember(employee1);
project2.addTeamMember(employee3);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(employee3);
Filter filter = new Filter();
filter.setProjects(Arrays.asList(project1, project2));
filter.setEmployees(Arrays.asList(employee1, employee2, employee3));
filter.setDepartments(Arrays.asList("department1", "department2", "department3"));
List<Employee> expected = Arrays.asList(employee1, employee2, employee3);
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifEmployeesAreEmpty.
@Test
public void testGetEmployeesByDepartments_ifEmployeesAreEmpty() {
Employee employee1 = new Employee("employee1", "test1", "test1", "department1");
Employee employee2 = new Employee("employee2", "test2", "test2", "department2");
Filter filter = new Filter();
filter.setEmployees(Collections.emptyList());
filter.setDepartments(Arrays.asList("department1", "department2"));
entityManager.persist(employee1);
entityManager.persist(employee2);
List<Employee> expected = filter.getEmployees();
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.
the class EmployeeRepositoryTest method testGetEmployeesByDepartments_ifDepartmentsAreEmpty_FilterHasNotAllEmployees.
@Test
public void testGetEmployeesByDepartments_ifDepartmentsAreEmpty_FilterHasNotAllEmployees() {
Employee employee1 = new Employee("employee1");
Employee employee2 = new Employee("employee2");
Employee employee3 = new Employee("employee3");
Filter filter = new Filter();
filter.setEmployees(Arrays.asList(employee1, employee2));
filter.setDepartments(Collections.emptyList());
entityManager.persist(employee1);
entityManager.persist(employee2);
entityManager.persist(employee3);
List<Employee> expected = filter.getEmployees();
List<Employee> actual = employeeRepository.getEmployeesByDepartments(filter);
ListAssert.assertEquals(expected, actual);
}
Aggregations