use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class DefaultNotificationManagerTest method shouldPersist.
@Test
public void shouldPersist() {
Notification notification = new Notification("test");
underTest.scheduleForSending(notification);
verify(notificationQueueDao, only()).insert(any(List.class));
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class DefaultNotificationManagerTest method shouldNotFailWhenUnableToDeserialize.
// SONAR-4739
@Test
public void shouldNotFailWhenUnableToDeserialize() throws Exception {
NotificationQueueDto dto1 = mock(NotificationQueueDto.class);
when(dto1.toNotification()).thenThrow(new InvalidClassException("Pouet"));
List<NotificationQueueDto> dtos = Arrays.asList(dto1);
when(notificationQueueDao.selectOldest(1)).thenReturn(dtos);
underTest = spy(underTest);
assertThat(underTest.<Notification>getFromQueue()).isNull();
assertThat(underTest.<Notification>getFromQueue()).isNull();
verify(underTest, times(1)).logDeserializationIssue();
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NotificationServiceTest method deliverEmails_collection_has_no_effect_if_no_handler_nor_dispatcher.
@Test
public void deliverEmails_collection_has_no_effect_if_no_handler_nor_dispatcher() {
List<Notification> notifications = IntStream.range(0, 1 + new Random().nextInt(20)).mapToObj(i -> mock(Notification.class)).collect(Collectors.toList());
NotificationService underTest = new NotificationService(dbClient);
assertThat(underTest.deliverEmails(notifications)).isZero();
verifyZeroInteractions(dbClient);
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NotificationServiceTest method deliverEmails_fails_with_IAE_if_type_of_collection_is_Notification.
@Test
public void deliverEmails_fails_with_IAE_if_type_of_collection_is_Notification() {
NotificationHandler handler = mock(NotificationHandler1.class);
List<Notification> notifications = IntStream.range(0, 1 + new Random().nextInt(20)).mapToObj(i -> new Notification("i")).collect(Collectors.toList());
NotificationService underTest = new NotificationService(dbClient, new NotificationHandler[] { handler });
assertThatThrownBy(() -> underTest.deliverEmails(notifications)).isInstanceOf(IllegalArgumentException.class).hasMessage("Type of notification objects must be a subtype of Notification");
}
use of org.sonar.api.notifications.Notification 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"));
}
Aggregations