use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method format_email_with_no_assignees_tags_nor_components.
@Test
public void format_email_with_no_assignees_tags_nor_components() throws Exception {
Notification notification = newNotification();
EmailMessage message = template.format(notification);
// TODO datetime to be completed when test is isolated from JVM timezone
String expectedContent = IOUtils.toString(getClass().getResource("NewIssuesEmailTemplateTest/email_with_partial_details.txt"), StandardCharsets.UTF_8);
assertThat(message.getMessage()).startsWith(StringUtils.remove(expectedContent, '\r'));
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method do_not_add_footer_when_properties_missing.
@Test
public void do_not_add_footer_when_properties_missing() {
Notification notification = new Notification(NewIssuesNotification.TYPE).setFieldValue(SEVERITY + ".count", "32").setFieldValue("projectName", "Struts");
EmailMessage message = template.format(notification);
assertThat(message.getMessage()).doesNotContain("See it");
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class NewIssuesEmailTemplateTest method no_format_is_not_the_correct_notification.
@Test
public void no_format_is_not_the_correct_notification() {
Notification notification = new Notification("my-new-issues");
EmailMessage message = template.format(notification);
assertThat(message).isNull();
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.
the class AlertsEmailTemplateTest method shouldFormatBackToGreenMessage.
@Test
public void shouldFormatBackToGreenMessage() {
Notification notification = createNotification("Green (was Red)", "", "OK", "false");
EmailMessage message = template.format(notification);
assertThat(message.getMessageId(), is("alerts/45"));
assertThat(message.getSubject(), is("\"Foo\" is back to green"));
assertThat(message.getMessage(), is("" + "Project: Foo\n" + "Quality gate status: Green (was Red)\n" + "\n" + "\n" + "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
}
use of org.sonar.plugins.emailnotifications.api.EmailMessage 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").setMessage("Bar");
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 <server@nowhere>");
assertThat(email.getHeader("To", null)).isEqualTo("<user@nowhere>");
assertThat(email.getHeader("Subject", null)).isEqualTo("[SONARQUBE] Foo");
assertThat((String) email.getContent()).startsWith("Bar");
}
Aggregations