use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.
the class IssueNotificationsTest method notifications_for_new_issues_and_issue_changes.
@Test
public void notifications_for_new_issues_and_issue_changes() throws Exception {
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.projectDate", "2015-12-15");
// change assignee
Issues issues = issueClient.find(IssueQuery.create().componentRoots(PROJECT_KEY));
Issue issue = issues.list().get(0);
issueClient.assign(issue.key(), USER_LOGIN);
waitUntilAllNotificationsAreDelivered(2);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
assertThat(emails.hasNext()).isTrue();
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat((String) message.getContent()).contains("Sample");
assertThat((String) message.getContent()).contains("17 new issues (new debt: 17min)");
assertThat((String) message.getContent()).contains("Severity");
assertThat((String) message.getContent()).contains("One Issue Per Line (xoo): 17");
assertThat((String) message.getContent()).contains("See it in SonarQube: http://localhost:9000/component_issues?id=sample#createdAt=2015-12-15T00%3A00%3A00%2B");
assertThat(emails.hasNext()).isTrue();
message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat((String) message.getContent()).contains("sample/Sample.xoo");
assertThat((String) message.getContent()).contains("Assignee changed to Tester");
assertThat((String) message.getContent()).contains("See it in SonarQube: http://localhost:9000/issues/search#issues=" + issue.key());
assertThat(emails.hasNext()).isFalse();
}
use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.
the class IssueNotificationsTest method before.
@BeforeClass
public static void before() throws Exception {
smtpServer = new Wiser(0);
smtpServer.start();
System.out.println("SMTP Server port: " + smtpServer.getServer().getPort());
// Configure Sonar
resetEmailSettings(ORCHESTRATOR);
setServerProperty(ORCHESTRATOR, "email.smtp_host.secured", "localhost");
setServerProperty(ORCHESTRATOR, "email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort()));
// Send test email to the test user
newAdminWsClient(ORCHESTRATOR).wsConnector().call(new PostRequest("api/emails/send").setParam("to", USER_EMAIL).setParam("message", "This is a test message from SonarQube")).failIfNotSuccessful();
// We need to wait until all notifications will be delivered
waitUntilAllNotificationsAreDelivered(1);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<" + USER_EMAIL + ">");
assertThat((String) message.getContent()).contains("This is a test message from SonarQube");
assertThat(emails.hasNext()).isFalse();
}
use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.
the class IssueNotificationsTest method notifications_for_personalized_emails.
@Test
public void notifications_for_personalized_emails() throws Exception {
setServerProperty(ORCHESTRATOR, "sonar.issues.defaultAssigneeLogin", USER_LOGIN);
runProjectAnalysis(ORCHESTRATOR, "issue/xoo-with-scm", "sonar.scm.provider", "xoo", "sonar.scm.disabled", "false");
waitUntilAllNotificationsAreDelivered(2);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
emails.next();
// the second email sent is the personalized one
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat(message.getSubject()).contains("You have 13 new issues");
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class AsyncEmailTaskTest method testSimpleTextMail.
// copied from org.activiti.engine.test.bpmn.mail.EmailServiceTaskTest
@Deployment
public void testSimpleTextMail() throws Exception {
String procId = runtimeService.startProcessInstanceByKey("simpleTextOnly").getId();
List<WiserMessage> messages = wiser.getMessages();
assertEquals(0, messages.size());
waitForJobExecutorToProcessAllJobs(5000L, 25L);
messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
EmailServiceTaskTest.assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Arrays.asList("kermit@activiti.org"), null);
assertProcessEnded(procId);
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailServiceTaskTest method testTextMailWithNotExistingFileAttachment.
@Deployment
public void testTextMailWithNotExistingFileAttachment() throws Exception {
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("attachmentsBean", new AttachmentsBean());
runtimeService.startProcessInstanceByKey("textMailWithNotExistingFileAttachment", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
assertFalse(message.getMimeMessage().getContent() instanceof MimeMultipart);
}
Aggregations