use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class ReportAnalysisFailureNotificationExecutionListenerTest method onEnd_ignores_null_CeTaskResult_argument.
@Test
public void onEnd_ignores_null_CeTaskResult_argument() {
String taskUuid = randomAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), (long) random.nextInt(999_999));
Notification notificationMock = mockSerializer();
underTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, randomDuration(), null, null);
verify(notificationService).deliver(same(notificationMock));
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class ReportAnalysisFailureNotificationExecutionListenerTest method onEnd_creates_notification_with_null_error_message_if_Throwable_is_null.
@Test
public void onEnd_creates_notification_with_null_error_message_if_Throwable_is_null() {
String taskUuid = randomAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), (long) random.nextInt(999_999));
Notification notificationMock = mockSerializer();
underTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, randomDuration(), ceTaskResultMock, null);
verify(notificationService).deliver(same(notificationMock));
ArgumentCaptor<ReportAnalysisFailureNotificationBuilder> notificationCaptor = verifyAndCaptureSerializedNotification();
ReportAnalysisFailureNotificationBuilder reportAnalysisFailureNotificationBuilder = notificationCaptor.getValue();
assertThat(reportAnalysisFailureNotificationBuilder.getErrorMessage()).isNull();
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class ReportAnalysisFailureNotificationExecutionListenerTest method onEnd_uses_system_data_as_failedAt_if_task_has_no_executedAt.
@Test
public void onEnd_uses_system_data_as_failedAt_if_task_has_no_executedAt() {
String taskUuid = randomAlphanumeric(12);
initMocksToPassConditions(taskUuid, random.nextInt(999_999), null);
long now = random.nextInt(999_999);
when(system2.now()).thenReturn(now);
Notification notificationMock = mockSerializer();
underTest.onEnd(ceTaskMock, CeActivityDto.Status.FAILED, randomDuration(), ceTaskResultMock, null);
verify(notificationService).deliver(same(notificationMock));
ArgumentCaptor<ReportAnalysisFailureNotificationBuilder> notificationCaptor = verifyAndCaptureSerializedNotification();
assertThat(notificationCaptor.getValue().getTask().getFailedAt()).isEqualTo(now);
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NotificationQueueDaoTest method should_insert_new_notification_queue.
@Test
public void should_insert_new_notification_queue() throws Exception {
NotificationQueueDto notificationQueueDto = toNotificationQueueDto(new Notification("email"));
dao.insert(Arrays.asList(notificationQueueDto));
assertThat(dao.count()).isOne();
assertThat(dao.selectOldest(1).get(0).toNotification().getType()).isEqualTo("email");
}
use of org.sonar.api.notifications.Notification in project sonarqube by SonarSource.
the class NotificationQueueDaoTest method should_delete_notification.
@Test
public void should_delete_notification() {
List<NotificationQueueDto> notifs = IntStream.range(0, 30).mapToObj(i -> toNotificationQueueDto(new Notification("foo_" + i))).collect(toList());
dao.insert(notifs);
db.commit();
List<String> uuids = selectAllUuid();
dao.delete(uuids.stream().limit(10).map(uuid -> new NotificationQueueDto().setUuid(uuid)).collect(toList()));
assertThat(selectAllUuid()).containsOnly(uuids.stream().skip(10).toArray(String[]::new));
}
Aggregations