Search in sources :

Example 21 with Notification

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

the class MyNewIssuesEmailTemplateTest method subject.

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

Example 22 with Notification

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

the class MyNewIssuesEmailTemplateTest method format_email_supports_single_issue.

@Test
public void format_email_supports_single_issue() {
    Notification notification = newNotification(1);
    EmailMessage message = underTest.format(notification);
    assertThat(message.getSubject()).isEqualTo("You have 1 new issue on project Struts");
    assertThat(message.getMessage()).contains("1 new issue (new debt: 1d3h)\n");
}
Also used : Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 23 with Notification

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

the class NewIssuesEmailTemplateTest method message_id.

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

Example 24 with Notification

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

the class NewIssuesEmailTemplateTest method format_email_with_no_assignees_tags_nor_components_nor_version.

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

Example 25 with Notification

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

the class NewIssuesEmailTemplateTest method format_email_with_all_fields_filled.

@Test
public void format_email_with_all_fields_filled() {
    Notification notification = newNotification(32).setFieldValue("projectVersion", "42.1.1");
    addAssignees(notification);
    addRules(notification);
    addTags(notification);
    addComponents(notification);
    EmailMessage message = template.format(notification);
    // TODO datetime to be completed when test is isolated from JVM timezone
    assertThat(message.getMessage()).startsWith("Project: Struts\n" + "Version: 42.1.1\n" + "\n" + "32 new issues (new debt: 1d3h)\n" + "\n" + "    Type\n" + "        Bug: 1    Vulnerability: 10    Code Smell: 3\n" + "\n" + "    Assignees\n" + "        robin.williams: 5\n" + "        al.pacino: 7\n" + "\n" + "    Rules\n" + "        Rule the Universe (Clojure): 42\n" + "        Rule the World (Java): 5\n" + "\n" + "    Tags\n" + "        oscar: 3\n" + "        cesar: 10\n" + "\n" + "    Most impacted files\n" + "        /path/to/file: 3\n" + "        /path/to/directory: 7\n" + "\n" + "More details at: http://nemo.sonarsource.org/project/issues?id=org.apache%3Astruts&createdAt=2010-05-1");
}
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