use of org.sonar.server.notification.email.EmailNotificationChannel in project sonarqube by SonarSource.
the class ChangesOnMyIssueNotificationHandlerTest method deliver_has_no_effect_if_emailNotificationChannel_is_disabled.
@Test
public void deliver_has_no_effect_if_emailNotificationChannel_is_disabled() {
when(emailNotificationChannel.isActivated()).thenReturn(false);
Set<IssuesChangesNotification> notifications = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> mock(IssuesChangesNotification.class)).collect(toSet());
int deliver = underTest.deliver(notifications);
assertThat(deliver).isZero();
verifyZeroInteractions(notificationManager);
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
notifications.forEach(Mockito::verifyZeroInteractions);
}
use of org.sonar.server.notification.email.EmailNotificationChannel in project sonarqube by SonarSource.
the class QGChangeNotificationHandlerTest method deliver_has_no_effect_if_no_notification_has_projectKey.
@Test
public void deliver_has_no_effect_if_no_notification_has_projectKey() {
when(emailNotificationChannel.isActivated()).thenReturn(true);
Set<QGChangeNotification> notifications = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> newNotification(null)).collect(toSet());
int deliver = underTest.deliver(notifications);
assertThat(deliver).isZero();
verifyZeroInteractions(notificationManager);
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
notifications.forEach(notification -> {
verify(notification).getProjectKey();
verifyNoMoreInteractions(notification);
});
}
use of org.sonar.server.notification.email.EmailNotificationChannel in project sonarqube by SonarSource.
the class BuiltInQPChangeNotificationHandlerTest method deliver_has_no_effect_if_emailNotificationChannel_is_disabled.
@Test
public void deliver_has_no_effect_if_emailNotificationChannel_is_disabled() {
when(emailNotificationChannel.isActivated()).thenReturn(false);
Set<BuiltInQPChangeNotification> notifications = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> mock(BuiltInQPChangeNotification.class)).collect(toSet());
int deliver = underTest.deliver(notifications);
assertThat(deliver).isZero();
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
verifyZeroInteractions(dbClient);
notifications.forEach(Mockito::verifyZeroInteractions);
}
use of org.sonar.server.notification.email.EmailNotificationChannel in project sonarqube by SonarSource.
the class BuiltInQPChangeNotificationHandlerTest method deliver_has_no_effect_if_there_is_no_global_administer_email_subscriber.
@Test
public void deliver_has_no_effect_if_there_is_no_global_administer_email_subscriber() {
when(emailNotificationChannel.isActivated()).thenReturn(true);
Set<BuiltInQPChangeNotification> notifications = IntStream.range(0, 1 + new Random().nextInt(10)).mapToObj(i -> mock(BuiltInQPChangeNotification.class)).collect(toSet());
when(authorizationDao.selectQualityProfileAdministratorLogins(dbSession)).thenReturn(emptySet());
int deliver = underTest.deliver(notifications);
assertThat(deliver).isZero();
verify(emailNotificationChannel).isActivated();
verifyNoMoreInteractions(emailNotificationChannel);
verify(dbClient).openSession(false);
verify(dbClient).authorizationDao();
verifyNoMoreInteractions(dbClient);
verify(authorizationDao).selectQualityProfileAdministratorLogins(dbSession);
verifyNoMoreInteractions(authorizationDao);
notifications.forEach(Mockito::verifyZeroInteractions);
}
Aggregations