use of com.artezio.arttime.datamodel.Employee 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);
}
use of com.artezio.arttime.datamodel.Employee 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);
}
use of com.artezio.arttime.datamodel.Employee 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());
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class FilterServiceTest method testCreatePersonalTimesheetFilter.
@Test
public void testCreatePersonalTimesheetFilter() throws NoSuchFieldException {
setField(filterService, "hourTypeRepository", hourTypeRepository);
setField(filterService, "projectRepository", projectRepository);
setField(filterService, "departmentRepository", departmentRepository);
Filter currentFilter = new Filter();
RangePeriodSelector currentPeriodSelector = new RangePeriodSelector(new Period(new Date(1), new Date(2)));
currentFilter.setRangePeriodSelector(currentPeriodSelector);
Employee employee = new Employee("user");
expect(departmentRepository.getDepartments()).andReturn(Collections.emptyList());
expect(hourTypeRepository.getAll()).andReturn(Collections.emptyList());
expect(projectRepository.getActiveAndReportedProjects(employee, currentFilter.getPeriod())).andReturn(Collections.emptyList());
replay(departmentRepository, hourTypeRepository, projectRepository);
Filter actual = filterService.createPersonalTimesheetFilter(currentFilter, employee);
verify(departmentRepository, hourTypeRepository, projectRepository);
assertEquals(currentFilter.getPeriod(), actual.getPeriod());
assertEquals(1, actual.getEmployees().size());
assertEquals(employee, actual.getEmployees().get(0));
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class ManageProjectPermissionFilterTest method testIsAccessAllowed_ifPM_andProjectNotManagedTheEmployee.
@Test
public void testIsAccessAllowed_ifPM_andProjectNotManagedTheEmployee() throws Exception {
Project project = new Project();
Employee employee = new Employee("employee");
mockStatic(SecurityUtils.class);
expect(SecurityUtils.getSubject()).andReturn(subject);
expect(subject.hasRole(UserRoles.EXEC_ROLE)).andReturn(false);
expect(subject.hasRole(UserRoles.PM_ROLE)).andReturn(true);
expect(servletRequest.getParameter("project")).andReturn("1");
expect(subject.getPrincipal()).andReturn("employee");
expect(projectRepository.findProject(1L)).andReturn(project);
expect(employeeRepository.find("employee")).andReturn(employee);
replayAll(SecurityUtils.class);
replay(subject, servletRequest, projectRepository, employeeRepository);
boolean actual = filter.isAccessAllowed(servletRequest, servletResponse, null);
verifyAll();
assertFalse(actual);
}
Aggregations