Search in sources :

Example 11 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method no_format_if_not_the_correct_notif.

@Test
public void no_format_if_not_the_correct_notif() {
    Notification notification = new Notification("new-issues");
    EmailMessage message = underTest.format(notification);
    assertThat(message).isNull();
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 12 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method message_id.

@Test
public void message_id() {
    Notification notification = newNotification();
    EmailMessage message = underTest.format(notification);
    assertThat(message.getMessageId()).isEqualTo("my-new-issues/org.apache:struts");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 13 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method subject.

@Test
public void subject() {
    Notification notification = newNotification();
    EmailMessage message = underTest.format(notification);
    assertThat(message.getSubject()).isEqualTo("You have 32 new issues on project Struts");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 14 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method do_not_add_footer_when_properties_missing.

@Test
public void do_not_add_footer_when_properties_missing() {
    Notification notification = new Notification(MyNewIssuesNotification.MY_NEW_ISSUES_NOTIF_TYPE).setFieldValue(SEVERITY + ".count", "32").setFieldValue("projectName", "Struts");
    EmailMessage message = underTest.format(notification);
    assertThat(message.getMessage()).doesNotContain("See it");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 15 with EmailMessage

use of org.sonar.plugins.emailnotifications.api.EmailMessage in project sonarqube by SonarSource.

the class AlertsEmailTemplateTest method shouldFormatNewAlertWithSeveralMessages.

@Test
public void shouldFormatNewAlertWithSeveralMessages() {
    Notification notification = createNotification("Orange (was Red)", "violations > 4, coverage < 75%", "WARN", "true");
    EmailMessage message = template.format(notification);
    assertThat(message.getMessageId(), is("alerts/45"));
    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo\""));
    assertThat(message.getMessage(), is("" + "Project: Foo\n" + "Quality gate status: Orange (was Red)\n" + "\n" + "New quality gate thresholds:\n" + "  - violations > 4\n" + "  - coverage < 75%\n" + "\n" + "See it in SonarQube: http://nemo.sonarsource.org/dashboard/index/org.sonar.foo:foo"));
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Aggregations

EmailMessage (org.sonar.plugins.emailnotifications.api.EmailMessage)34 Test (org.junit.Test)29 Notification (org.sonar.api.notifications.Notification)25 MimeMessage (javax.mail.internet.MimeMessage)2 Matchers.anyString (org.mockito.Matchers.anyString)2 WiserMessage (org.subethamail.wiser.WiserMessage)2 EmailException (org.apache.commons.mail.EmailException)1 User (org.sonar.api.user.User)1