Search in sources :

Example 21 with EmailMessage

use of org.sonar.server.issue.notification.EmailMessage in project sonarqube by SonarSource.

the class QGChangeEmailTemplateTest method shouldFormatNewAlertWithSeveralMessages.

@Test
public void shouldFormatNewAlertWithSeveralMessages() {
    Notification notification = createNotification("Failed", "violations > 4, coverage < 75%", "ERROR", "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" + "Version: V1-SNAP\n" + "Quality gate status: Failed\n" + "\n" + "New quality gate thresholds:\n" + "  - violations > 4\n" + "  - coverage < 75%\n" + "\n" + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo"));
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 22 with EmailMessage

use of org.sonar.server.issue.notification.EmailMessage in project sonarqube by SonarSource.

the class QGChangeEmailTemplateTest method shouldNotFormatIfNotCorrectNotification.

@Test
public void shouldNotFormatIfNotCorrectNotification() {
    Notification notification = new Notification("other-notif");
    EmailMessage message = template.format(notification);
    assertThat(message, nullValue());
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 23 with EmailMessage

use of org.sonar.server.issue.notification.EmailMessage in project sonarqube by SonarSource.

the class QGChangeEmailTemplateTest method shouldFormatAlertWithSeveralMessagesOnBranch.

@Test
public void shouldFormatAlertWithSeveralMessagesOnBranch() {
    Notification notification = createNotification("Failed", "violations > 4, coverage < 75%", "ERROR", "false").setFieldValue("branch", "feature");
    EmailMessage message = template.format(notification);
    assertThat(message.getMessageId(), is("alerts/45"));
    assertThat(message.getSubject(), is("Quality gate status changed on \"Foo (feature)\""));
    assertThat(message.getMessage(), is("" + "Project: Foo\n" + "Branch: feature\n" + "Version: V1-SNAP\n" + "Quality gate status: Failed\n" + "\n" + "Quality gate thresholds:\n" + "  - violations > 4\n" + "  - coverage < 75%\n" + "\n" + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature"));
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 24 with EmailMessage

use of org.sonar.server.issue.notification.EmailMessage in project sonarqube by SonarSource.

the class QGChangeEmailTemplateTest method shouldFormatBackToGreenMessage.

@Test
public void shouldFormatBackToGreenMessage() {
    Notification notification = createNotification("Passed", "", "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" + "Version: V1-SNAP\n" + "Quality gate status: Passed\n" + "\n" + "\n" + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo"));
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 25 with EmailMessage

use of org.sonar.server.issue.notification.EmailMessage in project sonarqube by SonarSource.

the class QGChangeEmailTemplateTest method shouldFormatNewAlertWithOneMessageOnBranch.

@Test
public void shouldFormatNewAlertWithOneMessageOnBranch() {
    Notification notification = createNotification("Failed", "violations > 4", "ERROR", "true").setFieldValue("branch", "feature");
    EmailMessage message = template.format(notification);
    assertThat(message.getMessageId(), is("alerts/45"));
    assertThat(message.getSubject(), is("New quality gate threshold reached on \"Foo (feature)\""));
    assertThat(message.getMessage(), is("" + "Project: Foo\n" + "Branch: feature\n" + "Version: V1-SNAP\n" + "Quality gate status: Failed\n" + "\n" + "New quality gate threshold: violations > 4\n" + "\n" + "More details at: http://nemo.sonarsource.org/dashboard?id=org.sonar.foo:foo&branch=feature"));
}
Also used : EmailMessage(org.sonar.server.issue.notification.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Aggregations

EmailMessage (org.sonar.server.issue.notification.EmailMessage)32 Test (org.junit.Test)27 Notification (org.sonar.api.notifications.Notification)13 CheckForNull (javax.annotation.CheckForNull)3 MimeMessage (javax.mail.internet.MimeMessage)3 WiserMessage (org.subethamail.wiser.WiserMessage)3 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)2 Date (java.util.Date)2 EmailException (org.apache.commons.mail.EmailException)2 DateUtils.formatDate (org.sonar.api.utils.DateUtils.formatDate)2 EmailTemplate (org.sonar.server.issue.notification.EmailTemplate)2 EmailDeliveryRequest (org.sonar.server.notification.email.EmailNotificationChannel.EmailDeliveryRequest)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1 DataProviderRunner (com.tngtech.java.junit.dataprovider.DataProviderRunner)1 IOException (java.io.IOException)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Random (java.util.Random)1 Set (java.util.Set)1