use of com.artezio.arttime.datamodel.HourType 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.HourType 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.HourType in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotificatePmAboutTimeProblems.
@Test
public void testNotificatePmAboutTimeProblems() throws MessagingException, NoSuchFieldException {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("getProjects", List.class).addMockedMethod("getProjectManagers", Collection.class).createMock();
setMockServices(notificationManager);
Employee employee = new Employee("iivanov");
Employee pm = new Employee("ppetrov");
pm.setEmail("ppetrov@mail.com");
Project project = createProject(1L, employee);
List<Employee> employees = Arrays.asList(employee);
List<Project> projects = Arrays.asList(project);
Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
timeProblems.put(employee, new HashMap<Date, BigDecimal>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
expect(notificationManager.getProjects(employees)).andReturn(projects);
expect(notificationManager.getProjectManagers(projects)).andReturn(Sets.newHashSet(pm));
expect(hourTypeRepository.findActual()).andReturn(new HourType());
expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName()), anyObject(Map.class))).andReturn(body);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
mailingEngine.sendAsync("ppetrov@mail.com", new Mail(subject, body));
replay(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
notificationManager.notificatePmAboutTimeProblems(employees, period, comment);
verify(notificationManager, hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotificateAboutOwnTimeProblems.
@Test
public void testNotificateAboutOwnTimeProblems() throws MessagingException, NoSuchFieldException {
setMockServices(notificationManager);
Employee employee = new Employee("iivanov");
employee.setEmail("iivanov@mail.com");
List<Employee> employees = Arrays.asList(employee);
Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<Employee, Map<Date, BigDecimal>>();
timeProblems.put(employee, new HashMap<Date, BigDecimal>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
expect(hourTypeRepository.findActual()).andReturn(new HourType());
expect(workTimeService.getApprovedWorkTimeProblems(period, employees)).andReturn(timeProblems);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY.getFileName()), anyObject(Map.class))).andReturn(body);
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
mailingEngine.sendAsync("iivanov@mail.com", new Mail(subject, body));
replay(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
notificationManager.notificateAboutOwnTimeProblems(employees, period, comment);
verify(hourTypeRepository, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.HourType in project ART-TIME by Artezio.
the class HourTypeRepositoryTest method testRemoveHourType_RemoveForbidden.
@Test(expected = PersistenceException.class)
public void testRemoveHourType_RemoveForbidden() throws ActualTimeRemovalException {
HourType hourType = new HourType();
Project project = new Project();
project.addAccountableHours(hourType);
entityManager.persist(hourType);
entityManager.persist(project);
hourTypeRepository.remove(hourType);
}
Aggregations