use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class DepartmentServiceTest method getEmployeesInTrackingSystem.
private List<Employee> getEmployeesInTrackingSystem() {
Employee employee1 = new Employee();
Employee employee2 = new Employee();
Employee employee3 = new Employee();
employee1.setDepartment("Minsk");
employee2.setDepartment("Minsk");
employee3.setDepartment("Moscow");
return Arrays.asList(employee1, employee2, employee3);
}
use of com.artezio.arttime.datamodel.Employee in project ART-TIME by Artezio.
the class EmployeeSynchronizerTest method testSynchronizeEmployees_externalEmployeeNotFound.
@Test
public void testSynchronizeEmployees_externalEmployeeNotFound() throws Exception {
String userName = "ssmirnoff";
Employee externalEmployee = null;
Employee internalEmployee = new Employee(userName, "Oldfirst", "Oldlast", "Oldmail");
List<Employee> internalEmployeeList = Arrays.asList(internalEmployee);
expect(employeeRepository.getAll()).andReturn(internalEmployeeList);
expect(employeeService.findEmployee(userName)).andReturn(externalEmployee);
expect(employeeRepository.update(internalEmployee)).andReturn(internalEmployee);
replay(employeeRepository, employeeService);
employeeSynchronizer.synchronizeEmployees();
verify(employeeRepository, employeeService);
assertTrue(internalEmployee.isFormer());
}
use of com.artezio.arttime.datamodel.Employee 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.Employee 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.Employee in project ART-TIME by Artezio.
the class ProjectServiceTest method testGetAvailableProjects_userIsPM_expectManagedProjects.
@Test
public void testGetAvailableProjects_userIsPM_expectManagedProjects() throws NoSuchFieldException {
Employee currentEmployee = new Employee("curr", "fn", "ln", "mail");
Employee manager1 = new Employee("man1", "fn1", "ln1", "mail1");
Employee manager2 = new Employee("man2", "fn2", "ln2", "mail2");
Project project1 = createProject(1L, null);
Project project2 = createProject(2L, null);
Project project3 = createProject(3L, null);
project1.setManagers(Arrays.asList(manager1, currentEmployee));
project2.setManagers(Arrays.asList(manager2));
project3.setManagers(Arrays.asList(currentEmployee));
Subject subject = createMock(Subject.class);
PowerMock.mockStatic(SecurityUtils.class);
projectRepository = createMock(ProjectRepository.class);
setField(projectService, "projectRepository", projectRepository);
expect(SecurityUtils.getSubject()).andReturn(subject);
expect(subject.hasRole(UserRoles.EXEC_ROLE)).andReturn(false);
expect(subject.hasRole(UserRoles.PM_ROLE)).andReturn(true);
expect(projectRepository.getManagedProjects(currentEmployee)).andReturn(Arrays.asList(project1, project3));
List<Project> expected = Arrays.asList(project1, project3);
PowerMock.replayAll(projectRepository, subject, SecurityUtils.class);
List<Project> actual = projectService.getAvailableProjects(currentEmployee);
PowerMock.verifyAll();
ListAssert.assertEquals(expected, actual);
}
Aggregations