Search in sources :

Example 16 with Notification

use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method subject_on_branch.

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

Example 17 with Notification

use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method format_supports_null_version.

@Test
public void format_supports_null_version() {
    Notification notification = newNotification(32).setFieldValue("branch", "feature1");
    EmailMessage message = underTest.format(notification);
    // TODO datetime to be completed when test is isolated from JVM timezone
    assertThat(message.getMessage()).startsWith("Project: Struts\n" + "Branch: feature1\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + "    Type\n" + "        Bug: 1    Vulnerability: 3    Code Smell: 0\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&assignees=lo.gin&branch=feature1&createdAt=2010-05-18");
}
Also used : Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 18 with Notification

use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.

the class MyNewIssuesEmailTemplateTest method message_id.

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

Example 19 with Notification

use of org.sonar.api.notifications.Notification 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 : Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 20 with Notification

use of org.sonar.api.notifications.Notification 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(RULE_TYPE + ".count", "32").setFieldValue("projectName", "Struts");
    EmailMessage message = underTest.format(notification);
    assertThat(message.getMessage()).doesNotContain("See it");
}
Also used : Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Aggregations

Notification (org.sonar.api.notifications.Notification)90 Test (org.junit.Test)83 EmailMessage (org.sonar.plugins.emailnotifications.api.EmailMessage)14 EmailMessage (org.sonar.server.issue.notification.EmailMessage)13 NotificationChannel (org.sonar.api.notifications.NotificationChannel)12 List (java.util.List)7 IntStream (java.util.stream.IntStream)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)5 Mockito.mock (org.mockito.Mockito.mock)5 Mockito.when (org.mockito.Mockito.when)5 ReportAnalysisFailureNotification (org.sonar.ce.task.projectanalysis.notification.ReportAnalysisFailureNotification)5 Tuple (org.assertj.core.groups.Tuple)4 Languages (org.sonar.api.resources.Languages)4 ActiveRuleChange (org.sonar.server.qualityprofile.ActiveRuleChange)4 Collections (java.util.Collections)3 Random (java.util.Random)3 Before (org.junit.Before)3 Mockito.verify (org.mockito.Mockito.verify)3 Mockito.verifyNoMoreInteractions (org.mockito.Mockito.verifyNoMoreInteractions)3 Mockito.verifyZeroInteractions (org.mockito.Mockito.verifyZeroInteractions)3