use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class HoursRepositoryTest method testGetActualHours_ifEmployeesIsEmpty.
@Test
public void testGetActualHours_ifEmployeesIsEmpty() throws NoSuchFieldException {
Date start = new Date();
Date finish = getOffsetDate(2);
Period period = new Period(start, finish);
Employee employee = new Employee("employee");
Project project = new Project();
HourType actualType = new HourType("actual type");
actualType.setActualTime(true);
BigDecimal quantity = new BigDecimal(8);
Hours hours1 = createHours(project, employee, getOffsetDate(1), actualType, quantity);
entityManager.persist(employee);
entityManager.persist(project);
entityManager.persist(actualType);
entityManager.persist(hours1);
List<Hours> actuals = hoursRepository.getActualHours(Collections.emptyList(), period, false);
assertTrue(actuals.isEmpty());
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyPmAboutTimeProblems.
@Test
public void testNotifyPmAboutTimeProblems() throws NoSuchFieldException {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("getProjects", List.class).addMockedMethod("getProjectManagers", Collection.class).createMock();
setMockServices(notificationManager);
Employee sender = new Employee("sender", "sender", "sender", "sender");
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<>();
timeProblems.put(employee, new HashMap<>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
EasyMock.expect(notificationManager.getProjects(employees)).andReturn(projects);
EasyMock.expect(notificationManager.getProjectManagers(projects)).andReturn(Lists.newArrayList(pm));
EasyMock.expect(hourTypeService.findActualTime()).andReturn(new HourType());
EasyMock.expect(workTimeService.getWorkTimeDeviations(period, employees)).andReturn(timeProblems);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY_FOR_PM.getFileName()), anyObject(Map.class))).andReturn(body);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_SUBJECT.getFileName()), anyObject(Map.class))).andReturn(subject);
EasyMock.expect(settings.getSmtpUsername()).andReturn("testSmtpUsername");
EasyMock.expect(settings.getSmtpSender()).andReturn("sender");
EasyMock.expect(settings.getApplicationBaseUrl()).andReturn("appHost");
mailingEngine.send(new Mail(subject, body, sender.getEmail(), pm.getEmail()));
EasyMock.replay(notificationManager, hourTypeService, workTimeService, mailTemplateManager, mailingEngine, settings);
notificationManager.notifyProjectManagers(employees, period, comment);
EasyMock.verify(notificationManager, hourTypeService, workTimeService, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutWorkTimeProblem.
@Test
public void testNotifyAboutWorkTimeProblem() {
notificationManager = createMockBuilder(NotificationManager.class).addMockedMethod("notifyEmployees", List.class, Period.class, String.class).addMockedMethod("notifyProjectManagers", List.class, Period.class, String.class).createMock();
List<Employee> employees = new ArrayList<>();
Period period = new Period();
String comment = "";
notificationManager.notifyEmployees(employees, period, comment);
notificationManager.notifyProjectManagers(employees, period, comment);
replay(notificationManager);
notificationManager.notifyAboutWorkTimeProblems(employees, period, comment);
verify(notificationManager);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutUnapprovedHours_oneEmployee.
@Test
public void testNotifyAboutUnapprovedHours_oneEmployee() throws Exception {
setMockServices(notificationManager);
Employee employee = new Employee("user_name");
String employeeEmail = "user_name@mail.com";
employee.setEmail(employeeEmail);
Period period = mock(Period.class);
String senderEmail = "sender@mail.com";
String body = "mail_body";
String subject = "mail_subject";
Mail mail = new Mail(subject, body, senderEmail, employeeEmail);
String applicationBaseUrl = "url";
Map<String, Object> mailParameters = new HashMap<>();
mailParameters.put("period", period);
mailParameters.put("appHost", applicationBaseUrl);
expect(settings.getSmtpSender()).andReturn(senderEmail);
expect(settings.getApplicationBaseUrl()).andReturn(applicationBaseUrl);
expect(mailTemplateManager.getTemplateText(MailTemplate.UNAPPROVED_HOURS_BODY.getFileName(), mailParameters)).andReturn(body);
expect(mailTemplateManager.getTemplateText(MailTemplate.UNAPPROVED_HOURS_SUBJECT.getFileName(), mailParameters)).andReturn(subject);
mailingEngine.send(mail);
replay(settings, mailTemplateManager, mailingEngine);
notificationManager.notifyAboutUnapprovedHours(employee, period);
verify(settings, mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.datamodel.Period in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutIncorrectTimesheet_oneEmployee.
@Test
public void testNotifyAboutIncorrectTimesheet_oneEmployee() throws Exception {
setMockServices(notificationManager);
Employee employee = new Employee("user_name");
String employeeEmail = "user_name@mail.com";
employee.setEmail(employeeEmail);
Period period = mock(Period.class);
HourType actualTime = new HourType("actual");
String senderEmail = "sender@mail.com";
String body = "mail_body";
String subject = "mail_subject";
Mail mail = new Mail(subject, body, senderEmail, employeeEmail);
String applicationBaseUrl = "url";
Map<String, Object> mailParameters = new HashMap<>();
mailParameters.put("hourType", actualTime);
mailParameters.put("period", period);
mailParameters.put("appHost", applicationBaseUrl);
expect(hourTypeService.findActualTime()).andReturn(actualTime);
expect(settings.getSmtpSender()).andReturn(senderEmail);
expect(settings.getApplicationBaseUrl()).andReturn(applicationBaseUrl);
expect(mailTemplateManager.getTemplateText(MailTemplate.INCORRECT_TIMESHEET_BODY.getFileName(), mailParameters)).andReturn(body);
expect(mailTemplateManager.getTemplateText(MailTemplate.INCORRECT_TIMESHEET_SUBJECT.getFileName(), mailParameters)).andReturn(subject);
mailingEngine.send(mail);
replay(hourTypeService, settings, mailTemplateManager, mailingEngine);
notificationManager.notifyAboutIncorrectTimesheet(employee, period);
verify(hourTypeService, settings, mailTemplateManager, mailingEngine);
}
Aggregations