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");
}
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();
}
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();
}
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());
}
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;
}
Aggregations