Search in sources :

Example 56 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendTestEmail.

@Test
public void shouldSendTestEmail() throws Exception {
    configure();
    underTest.sendTestEmail("user@nowhere", "Test Message from SonarQube", "This is a test message from SonarQube.");
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("From", ",")).isEqualTo("SonarQube from NoWhere <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Test Message from SonarQube");
    assertThat((String) email.getContent()).startsWith("This is a test message from SonarQube.\r\n\r\nMail sent from: http://nemo.sonarsource.org");
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Example 57 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendNonThreadedEmail.

@Test
public void shouldSendNonThreadedEmail() throws Exception {
    configure();
    EmailMessage emailMessage = new EmailMessage().setTo("user@nowhere").setSubject("Foo").setPlainTextMessage("Bar");
    boolean delivered = underTest.deliver(emailMessage);
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("In-Reply-To", null)).isNull();
    assertThat(email.getHeader("References", null)).isNull();
    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
    assertThat(email.getHeader("From", null)).isEqualTo("SonarQube from NoWhere <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo");
    assertThat((String) email.getContent()).startsWith("Bar");
    assertThat(delivered).isTrue();
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Example 58 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.

the class EmailNotificationChannelTest method shouldSendThreadedEmail.

@Test
public void shouldSendThreadedEmail() throws Exception {
    configure();
    EmailMessage emailMessage = new EmailMessage().setMessageId("reviews/view/1").setFrom("Full Username").setTo("user@nowhere").setSubject("Review #3").setPlainTextMessage("I'll take care of this violation.");
    boolean delivered = underTest.deliver(emailMessage);
    List<WiserMessage> messages = smtpServer.getMessages();
    assertThat(messages).hasSize(1);
    MimeMessage email = messages.get(0).getMimeMessage();
    assertThat(email.getHeader("Content-Type", null)).isEqualTo("text/plain; charset=UTF-8");
    assertThat(email.getHeader("In-Reply-To", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
    assertThat(email.getHeader("References", null)).isEqualTo("<reviews/view/1@nemo.sonarsource.org>");
    assertThat(email.getHeader("List-ID", null)).isEqualTo("SonarQube <sonar.nemo.sonarsource.org>");
    assertThat(email.getHeader("List-Archive", null)).isEqualTo("http://nemo.sonarsource.org");
    assertThat(email.getHeader("From", ",")).isEqualTo("\"Full Username (SonarQube from NoWhere)\" <server@nowhere>");
    assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
    assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Review #3");
    assertThat((String) email.getContent()).startsWith("I'll take care of this violation.");
    assertThat(delivered).isTrue();
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Test(org.junit.Test)

Example 59 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project jbpm by kiegroup.

the class TaskReminderBaseTest method testTaskReminderWithNotificationByTaskNoCompleted.

@Test(timeout = 10000)
public void testTaskReminderWithNotificationByTaskNoCompleted() throws Exception {
    CountDownTaskEventListener countDownListener = new CountDownTaskEventListener(1, false, true);
    addCountDownListner(countDownListener);
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("now", new Date());
    Reader reader = new InputStreamReader(getClass().getResourceAsStream(MvelFilePath.ReminderWithNotificationInProgress));
    InternalTask task = (InternalTask) TaskFactory.evalTask(reader, vars);
    System.out.println("testTaskReminderWithNotificationByTaskNoCompleted " + task.getTaskData().getStatus());
    assertEquals(1, task.getDeadlines().getEndDeadlines().size());
    assertEquals(1, task.getDeadlines().getStartDeadlines().size());
    long taskId = taskService.addTask(task, new HashMap<String, Object>());
    taskService.executeReminderForTask(taskId, "Luke Cage");
    countDownListener.waitTillCompleted();
    assertEquals(2, wiser.getMessages().size());
    List<String> list = new ArrayList<String>(2);
    list.add(wiser.getMessages().get(0).getEnvelopeReceiver());
    list.add(wiser.getMessages().get(1).getEnvelopeReceiver());
    assertTrue(list.contains("tony@domain.com"));
    assertTrue(list.contains("darth@domain.com"));
    MimeMessage msg = ((WiserMessage) wiser.getMessages().get(0)).getMimeMessage();
    assertEquals("ReminderWithNotificationInProgress:you have new task to be completed", msg.getSubject());
    assertEquals("task is not completed", msg.getContent());
    msg = ((WiserMessage) wiser.getMessages().get(1)).getMimeMessage();
    assertEquals("ReminderWithNotificationInProgress:you have new task to be completed", msg.getSubject());
    assertEquals("task is not completed", msg.getContent());
}
Also used : CountDownTaskEventListener(org.jbpm.services.task.util.CountDownTaskEventListener) InputStreamReader(java.io.InputStreamReader) HashMap(java.util.HashMap) InternalTask(org.kie.internal.task.api.model.InternalTask) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) WiserMessage(org.subethamail.wiser.WiserMessage) Date(java.util.Date) MimeMessage(javax.mail.internet.MimeMessage) Test(org.junit.Test)

Example 60 with WiserMessage

use of org.subethamail.wiser.WiserMessage in project simple-java-mail by bbottema.

the class SmtpServerRule method getOnlyMessage.

@Nonnull
public MimeMessage getOnlyMessage(String envelopeReceiver) throws MessagingException {
    checkState("getMessages()");
    List<WiserMessage> messages = getMessages();
    assertThat(messages).hasSize(1);
    Iterator<WiserMessage> iterator = messages.iterator();
    WiserMessage wiserMessage = iterator.next();
    assertThat(wiserMessage.getEnvelopeReceiver()).isEqualTo(envelopeReceiver);
    MimeMessage mimeMessage = wiserMessage.getMimeMessage();
    iterator.remove();
    return mimeMessage;
}
Also used : MimeMessage(javax.mail.internet.MimeMessage) WiserMessage(org.subethamail.wiser.WiserMessage) Nonnull(javax.annotation.Nonnull)

Aggregations

WiserMessage (org.subethamail.wiser.WiserMessage)67 MimeMessage (javax.mail.internet.MimeMessage)34 Test (org.junit.Test)27 HashMap (java.util.HashMap)26 Deployment (org.activiti.engine.test.Deployment)22 ArrayList (java.util.ArrayList)12 MimeMultipart (javax.mail.internet.MimeMultipart)12 Deployment (org.camunda.bpm.engine.test.Deployment)10 Date (java.util.Date)9 WorkItemImpl (org.drools.core.process.instance.impl.WorkItemImpl)6 AbstractBaseTest (org.jbpm.test.AbstractBaseTest)6 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 DefaultWorkItemManager (org.drools.core.process.instance.impl.DefaultWorkItemManager)5 CountDownTaskEventListener (org.jbpm.services.task.util.CountDownTaskEventListener)5 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)5 InternalTask (org.kie.internal.task.api.model.InternalTask)5 File (java.io.File)4 LinkedHashSet (java.util.LinkedHashSet)4 OrganizationalEntity (org.kie.api.task.model.OrganizationalEntity)4