use of org.subethamail.wiser.WiserMessage in project sonarqube by SonarSource.
the class IssueNotificationsTest method notifications_for_bulk_change_ws.
/**
* SONAR-4606
*/
@Test
public void notifications_for_bulk_change_ws() throws Exception {
runProjectAnalysis(ORCHESTRATOR, "shared/xoo-sample", "sonar.projectDate", "2015-12-15");
Issues issues = issueClient.find(IssueQuery.create().componentRoots(PROJECT_KEY));
Issue issue = issues.list().get(0);
// bulk change without notification by default
issuesService.bulkChange(BulkChangeRequest.builder().setIssues(singletonList(issue.key())).setAssign(USER_LOGIN).setSetSeverity("MINOR").build());
// bulk change with notification
issuesService.bulkChange(BulkChangeRequest.builder().setIssues(singletonList(issue.key())).setSetSeverity("BLOCKER").setSendNotifications(true).build());
waitUntilAllNotificationsAreDelivered(2);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
emails.next();
MimeMessage 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("Severity: BLOCKER (was MINOR)");
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 EmailsTest method send_test_email.
@Test
public void send_test_email() throws Exception {
updateEmailSettings("localhost", Integer.toString(SMTP_SERVER.getServer().getPort()), null, null, null, null, null);
sendEmail("test@example.org", "Test Message from SonarQube", "This is a test message from SonarQube");
// We need to wait until all notifications will be delivered
waitUntilAllNotificationsAreDelivered();
Iterator<WiserMessage> emails = SMTP_SERVER.getMessages().iterator();
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<test@example.org>");
assertThat(message.getSubject()).contains("Test Message from SonarQube");
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 QualityGateNotificationTest method status_on_metric_variation_and_send_notifications.
@Test
public void status_on_metric_variation_and_send_notifications() throws Exception {
setServerProperty(orchestrator, "email.smtp_host.secured", "localhost");
setServerProperty(orchestrator, "email.smtp_port.secured", Integer.toString(smtpServer.getServer().getPort()));
// Create user, who will receive notifications for new violations
userRule.createUser("tester", "Tester", "tester@example.org", "tester");
// Send test email to the test user
newAdminWsClient(orchestrator).wsConnector().call(new PostRequest("api/emails/send").setParam("to", "test@example.org").setParam("message", "This is a test message from SonarQube")).failIfNotSuccessful();
// Add notifications to the test user
WsClient wsClient = newUserWsClient(orchestrator, "tester", "tester");
wsClient.wsConnector().call(new PostRequest("api/notifications/add").setParam("type", "NewAlerts").setParam("channel", "EmailNotificationChannel")).failIfNotSuccessful();
// Create quality gate with conditions on variations
QualityGate simple = qgClient().create("SimpleWithDifferential");
qgClient().setDefault(simple.id());
qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").period(1).operator("EQ").warningThreshold("0"));
SonarScanner analysis = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
orchestrator.executeBuild(analysis);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("OK");
orchestrator.executeBuild(analysis);
assertThat(getGateStatusMeasure().getValue()).isEqualTo("WARN");
qgClient().unsetDefault();
qgClient().destroy(simple.id());
waitUntilAllNotificationsAreDelivered(smtpServer);
Iterator<WiserMessage> emails = smtpServer.getMessages().iterator();
MimeMessage message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<test@example.org>");
assertThat((String) message.getContent()).contains("This is a test message from SonarQube");
assertThat(emails.hasNext()).isTrue();
message = emails.next().getMimeMessage();
assertThat(message.getHeader("To", null)).isEqualTo("<tester@example.org>");
assertThat((String) message.getContent()).contains("Quality gate status: Orange (was Green)");
assertThat((String) message.getContent()).contains("Quality gate threshold: Lines of Code variation = 0 since previous analysis");
assertThat((String) message.getContent()).contains("/dashboard/index/sample");
assertThat(emails.hasNext()).isFalse();
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailSendTaskTest method testSimpleTextMail.
@Deployment
public void testSimpleTextMail() throws Exception {
runtimeService.startProcessInstanceByKey("simpleTextOnly");
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
assertEmailSend(message, false, "Hello Kermit!", "This a text only e-mail.", "activiti@localhost", Arrays.asList("kermit@activiti.org"), null);
}
use of org.subethamail.wiser.WiserMessage in project Activiti by Activiti.
the class EmailSendTaskTest method testTextMailWithFileAttachmentsByPath.
@Deployment
public void testTextMailWithFileAttachmentsByPath() throws Exception {
HashMap<String, Object> vars = new HashMap<String, Object>();
vars.put("attachmentsBean", new AttachmentsBean());
runtimeService.startProcessInstanceByKey("textMailWithFileAttachmentsByPath", vars);
List<WiserMessage> messages = wiser.getMessages();
assertEquals(1, messages.size());
WiserMessage message = messages.get(0);
MimeMultipart mm = (MimeMultipart) message.getMimeMessage().getContent();
File[] files = new AttachmentsBean().getFiles();
assertEquals(1 + files.length, mm.getCount());
for (int i = 0; i < files.length; i++) {
String attachmentFileName = mm.getBodyPart(1 + i).getDataHandler().getName();
assertEquals(files[i].getName(), attachmentFileName);
}
}
Aggregations