use of com.artezio.arttime.services.mailing.Mail in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutTeamChanges.
@Test
public void testNotifyAboutTeamChanges() throws NoSuchFieldException {
setMockServices(notificationManager);
Project project = new Project();
Employee manager = new Employee();
manager.setEmail("manager@email");
String senderEmail = "sender@se.nder";
project.addManager(manager);
List<Employee> newEmployees = new ArrayList<>();
List<Employee> closedEmployees = new ArrayList<>();
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TEAM_SYNCHRONIZATION_BODY.getFileName()), anyObject(Map.class))).andReturn("body");
expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TEAM_SYNCHRONIZATION_SUBJECT.getFileName()), anyObject(Map.class))).andReturn("subject");
expect(settings.getSmtpSender()).andReturn(senderEmail);
expect(settings.getApplicationBaseUrl()).andReturn("appHost");
mailingEngine.send(new Mail("subject", "body", senderEmail, manager.getEmail()));
replay(mailTemplateManager, mailingEngine, settings);
notificationManager.notifyAboutTeamChanges(project, closedEmployees, newEmployees);
verify(mailTemplateManager, mailingEngine);
}
use of com.artezio.arttime.services.mailing.Mail in project ART-TIME by Artezio.
the class NotificationManagerTest method testNotifyAboutOwnTimeProblems.
@Test
public void testNotifyAboutOwnTimeProblems() throws 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<>();
timeProblems.put(employee, new HashMap<>());
Period period = new Period();
String comment = "comment";
String subject = "subject";
String body = "body";
EasyMock.expect(hourTypeService.findActualTime()).andReturn(new HourType());
EasyMock.expect(workTimeService.getWorkTimeDeviations(period, employees)).andReturn(timeProblems);
EasyMock.expect(mailTemplateManager.getTemplateText(eq(MailTemplate.TIME_PROBLEM_BODY.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("username");
EasyMock.expect(settings.getSmtpSender()).andReturn("sender");
EasyMock.expect(settings.getApplicationBaseUrl()).andReturn("appHost");
mailingEngine.send(new Mail(subject, body, "sender", "iivanov@mail.com"));
String principalName = "someuser";
Principal principal = Mockito.mock(Principal.class);
Mockito.when(principal.getName()).thenReturn(principalName);
EasyMock.expect(employeeRepository.get(principalName)).andReturn(employee);
EasyMock.replay(hourTypeService, workTimeService, mailTemplateManager, mailingEngine, settings, employeeRepository, sessionContext);
notificationManager.notifyEmployees(employees, period, comment);
EasyMock.verify(hourTypeService, workTimeService, mailTemplateManager, mailingEngine);
}
Aggregations