Search in sources :

Example 56 with Notification

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

the class IssueChangesEmailTemplateTest method notification_contains_user_login_when_user_is_removed.

@Test
public void notification_contains_user_login_when_user_is_removed() {
    db.users().insertUser(newUserDto().setLogin("simon").setName("Simon").setActive(false));
    Notification notification = new IssueChangeNotification().setChangeAuthorLogin("simon").setProject("Struts", "org.apache:struts");
    EmailMessage message = underTest.format(notification);
    assertThat(message.getFrom()).isEqualTo("simon");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 57 with Notification

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

the class IssueChangesEmailTemplateTest method notification_sender_should_be_the_author_of_change.

@Test
public void notification_sender_should_be_the_author_of_change() {
    db.users().insertUser(newUserDto().setLogin("simon").setName("Simon"));
    Notification notification = new IssueChangeNotification().setChangeAuthorLogin("simon").setProject("Struts", "org.apache:struts");
    EmailMessage message = underTest.format(notification);
    assertThat(message.getFrom()).isEqualTo("Simon");
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 58 with Notification

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

the class IssueChangesEmailTemplateTest method should_ignore_non_issue_changes.

@Test
public void should_ignore_non_issue_changes() {
    Notification notification = new Notification("other");
    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 59 with Notification

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

the class MyNewIssuesNotificationDispatcherTest method do_not_dispatch_if_no_new_notification.

@Test
public void do_not_dispatch_if_no_new_notification() {
    Notification notification = new Notification("other-notif");
    underTest.performDispatch(notification, context);
    verify(context, never()).addUser(any(String.class), any(NotificationChannel.class));
}
Also used : NotificationChannel(org.sonar.api.notifications.NotificationChannel) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 60 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.

@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'));
}
Also used : EmailMessage(org.sonar.plugins.emailnotifications.api.EmailMessage) Matchers.anyString(org.mockito.Matchers.anyString) 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