Search in sources :

Example 1 with NotificationQueueDto

use of org.sonar.db.notification.NotificationQueueDto in project sonarqube by SonarSource.

the class DefaultNotificationManagerTest method shouldGetFromQueueAndDelete.

@Test
public void shouldGetFromQueueAndDelete() {
    Notification notification = new Notification("test");
    NotificationQueueDto dto = NotificationQueueDto.toNotificationQueueDto(notification);
    List<NotificationQueueDto> dtos = Arrays.asList(dto);
    when(notificationQueueDao.selectOldest(1)).thenReturn(dtos);
    assertThat(manager.getFromQueue()).isNotNull();
    InOrder inOrder = inOrder(notificationQueueDao);
    inOrder.verify(notificationQueueDao).selectOldest(1);
    inOrder.verify(notificationQueueDao).delete(dtos);
}
Also used : NotificationQueueDto(org.sonar.db.notification.NotificationQueueDto) InOrder(org.mockito.InOrder) Notification(org.sonar.api.notifications.Notification) Test(org.junit.Test)

Example 2 with NotificationQueueDto

use of org.sonar.db.notification.NotificationQueueDto in project sonarqube by SonarSource.

the class DefaultNotificationManager method scheduleForSending.

/**
   * {@inheritDoc}
   */
@Override
public void scheduleForSending(Notification notification) {
    NotificationQueueDto dto = NotificationQueueDto.toNotificationQueueDto(notification);
    notificationQueueDao.insert(Arrays.asList(dto));
}
Also used : NotificationQueueDto(org.sonar.db.notification.NotificationQueueDto)

Example 3 with NotificationQueueDto

use of org.sonar.db.notification.NotificationQueueDto 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);
    manager = spy(manager);
    assertThat(manager.getFromQueue()).isNull();
    assertThat(manager.getFromQueue()).isNull();
    verify(manager, times(1)).logDeserializationIssue();
}
Also used : NotificationQueueDto(org.sonar.db.notification.NotificationQueueDto) InvalidClassException(java.io.InvalidClassException) Test(org.junit.Test)

Aggregations

NotificationQueueDto (org.sonar.db.notification.NotificationQueueDto)3 Test (org.junit.Test)2 InvalidClassException (java.io.InvalidClassException)1 InOrder (org.mockito.InOrder)1 Notification (org.sonar.api.notifications.Notification)1