use of com.artezio.arttime.services.mailing.Mail in project ART-TIME by Artezio.
the class TeamSynchronizer method notifyPM.
protected void notifyPM(Project project, List<Employee> closedEmployees, List<Employee> newEmployees) throws MessagingException {
Map<String, Object> params = new HashMap<>();
params.put("managedProject", project);
params.put("newEmployees", newEmployees);
params.put("closedEmployees", closedEmployees);
params.put("appUrl", settings.getApplicationBaseUrl());
String body = mailTemplateManager.getTemplateText(MailTemplate.TEAM_SYNCHRONIZATION_BODY.getFileName(), params);
String subject = mailTemplateManager.getTemplateText(MailTemplate.TEAM_SYNCHRONIZATION_SUBJECT.getFileName(), params);
Mail mail = new Mail(subject, body);
for (Employee manager : project.getManagers()) {
mailingEngine.send(manager.getEmail(), mail);
}
}
use of com.artezio.arttime.services.mailing.Mail 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.services.mailing.Mail 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.services.mailing.Mail 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.services.mailing.Mail 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);
}
Aggregations