Search in sources :

Example 11 with Mail

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);
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) Mail(com.artezio.arttime.services.mailing.Mail) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Example 12 with Mail

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);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) HourType(com.artezio.arttime.datamodel.HourType) Mail(com.artezio.arttime.services.mailing.Mail) HashMap(java.util.HashMap) Period(com.artezio.arttime.datamodel.Period) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Principal(java.security.Principal) Test(org.junit.Test)

Aggregations

Mail (com.artezio.arttime.services.mailing.Mail)12 HashMap (java.util.HashMap)12 Employee (com.artezio.arttime.datamodel.Employee)11 Map (java.util.Map)8 Test (org.junit.Test)8 HourType (com.artezio.arttime.datamodel.HourType)7 Period (com.artezio.arttime.datamodel.Period)7 AbstractMap (java.util.AbstractMap)6 TreeMap (java.util.TreeMap)6 Project (com.artezio.arttime.datamodel.Project)4 BigDecimal (java.math.BigDecimal)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Principal (java.security.Principal)2 List (java.util.List)2