use of com.artezio.arttime.services.WorkTimeService.Efforts in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testEfforts_GetWaitingApprovalBy.
@Test
public void testEfforts_GetWaitingApprovalBy() {
Employee manager1 = new Employee("manager1");
Employee manager2 = new Employee("manager2");
Project project1 = new Project();
project1.addManager(manager1);
Project project2 = new Project();
project2.addManager(manager1);
project2.addManager(manager2);
List<Project> projects = Arrays.asList(project1, project2);
Employee employee = new Employee("employee");
HourType actualTime = new HourType("actual");
BigDecimal quantity = new BigDecimal(8);
Hours hours1 = createHours(project1, employee, new Date(), actualTime, quantity);
Hours hours2 = createHours(project2, employee, new Date(), actualTime, quantity);
List<Hours> hours = Arrays.asList(hours1, hours2);
WorkTimeService.Efforts efforts = new WorkTimeService.Efforts(employee, Collections.emptyMap(), Collections.singletonMap(employee, hours), Collections.singletonMap(employee, projects));
List<Employee> actuals = efforts.getWaitingApprovalBy(hours);
List<Employee> expected = Arrays.asList(manager1, manager2);
ListAssert.assertEquals(expected, actuals);
}
use of com.artezio.arttime.services.WorkTimeService.Efforts in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testCheckListAllManagers_ifEmployeeRemoveFromProject.
@Test
public void testCheckListAllManagers_ifEmployeeRemoveFromProject() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(1);
Period period = new Period(start, finish);
Employee employee = new Employee("employee");
WorkdaysCalendar calendar = new WorkdaysCalendar("calendar");
employee.setCalendar(calendar);
Employee managerActiveProject = new Employee("manager1");
Employee managerRemoveEmployee = new Employee("manager2");
List<Employee> employees = Arrays.asList(employee);
Project project1 = new Project();
project1.addTeamMember(employee);
project1.addManager(managerActiveProject);
Project project2 = new Project();
project2.addTeamMember(employee);
project2.addManager(managerRemoveEmployee);
project2.removeTeamMember(employee);
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity1 = new BigDecimal(3);
BigDecimal quantity2 = new BigDecimal(10);
Hours hours1 = createHours(project1, employee, new Date(), actualType, quantity1);
Hours hours2 = createHours(project2, employee, getOffsetDate(1), actualType, quantity2);
Hours hours3 = createHours(project2, employee, new Date(), actualType, quantity2);
hours1.setApproved(true);
hours2.setApproved(false);
hours3.setApproved(true);
Filter filter = new Filter();
filter.setEmployees(employees);
filter.setCustomPeriod(period);
entityManager.persist(employee);
entityManager.persist(managerActiveProject);
entityManager.persist(managerRemoveEmployee);
entityManager.persist(calendar);
entityManager.persist(actualType);
entityManager.persist(project1);
entityManager.persist(project2);
entityManager.persist(hours1);
entityManager.persist(hours2);
entityManager.persist(hours3);
entityManager.flush();
entityManager.clear();
setField(workTimeService, "employeeRepository", employeeRepository);
expect(employeeRepository.getEmployeesByDepartments(filter)).andReturn(employees);
replay(employeeRepository);
List<Efforts> actual = workTimeService.getEmployeesTimeProblems(filter);
assertEquals(actual.get(0).getAllManagers().size(), 2);
}
use of com.artezio.arttime.services.WorkTimeService.Efforts in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testEfforts_GetWaitingApprovalBy_NoUnapprovedHours.
@Test
public void testEfforts_GetWaitingApprovalBy_NoUnapprovedHours() {
Employee manager = new Employee("manager");
Project project = new Project();
project.addManager(manager);
List<Project> projects = Arrays.asList(project);
Employee employee = new Employee("employee");
HourType actualTime = new HourType("actual");
Hours hours = createHours(project, employee, new Date(), actualTime, new BigDecimal(8));
hours.setApproved(true);
List<Hours> hoursList = Arrays.asList(hours);
WorkTimeService.Efforts efforts = new WorkTimeService.Efforts(employee, Collections.emptyMap(), Collections.singletonMap(employee, hoursList), Collections.singletonMap(employee, projects));
List<Employee> actuals = efforts.getWaitingApprovalBy(hoursList);
assertTrue(actuals.isEmpty());
}
use of com.artezio.arttime.services.WorkTimeService.Efforts in project ART-TIME by Artezio.
the class WorkTimeServiceTest method testEfforts_GetManagers.
@Test
public void testEfforts_GetManagers() {
Employee manager1 = new Employee("manager1");
Employee manager2 = new Employee("manager2");
Project project1 = new Project();
project1.addManager(manager1);
Project project2 = new Project();
project2.addManager(manager1);
project2.addManager(manager2);
List<Project> projects = Arrays.asList(project1, project2);
Employee employee = new Employee("employee");
WorkTimeService.Efforts efforts = new WorkTimeService.Efforts(employee, Collections.emptyMap(), Collections.singletonMap(employee, new ArrayList<>()), Collections.singletonMap(employee, projects));
List<Employee> actual = efforts.getManagers(projects);
List<Employee> expected = Arrays.asList(manager1, manager2);
ListAssert.assertEquals(expected, actual);
}
Aggregations