use of com.synopsys.integration.alert.api.event.EventManager in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method distributeMissingDestinationKeyTest.
@Test
public void distributeMissingDestinationKeyTest() {
MockProcessingAuditAccessor processingAuditAccessor = new MockProcessingAuditAccessor();
EventManager eventManager = Mockito.mock(EventManager.class);
ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(uuid, "bad channel key", "JobName");
ProcessedProviderMessageHolder processedMessageHolder = createProcessedProviderMessageHolder(1, 0);
ProviderMessageDistributor providerMessageDistributor = new ProviderMessageDistributor(processingAuditAccessor, eventManager);
providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
Mockito.verify(eventManager, Mockito.times(0)).sendEvent(Mockito.any());
}
use of com.synopsys.integration.alert.api.event.EventManager in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTest method handleEventTest.
@Test
void handleEventTest() throws IOException {
AlertNotificationModel alertNotificationModel = createAlertNotificationModel(1L, false);
List<AlertNotificationModel> alertNotificationModels = List.of(alertNotificationModel);
NotificationAccessor notificationAccessor = new MockNotificationAccessor(alertNotificationModels);
NotificationProcessor notificationProcessor = mockNotificationProcessor(notificationAccessor);
EventManager eventManager = mockEventManager();
NotificationReceivedEventHandler eventHandler = new NotificationReceivedEventHandler(notificationAccessor, notificationProcessor, eventManager);
try {
eventHandler.handle(new NotificationReceivedEvent());
} catch (RuntimeException e) {
fail("Unable to handle event", e);
}
}
use of com.synopsys.integration.alert.api.event.EventManager in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTest method handleEventProcessingInterruptedTest.
@Test
void handleEventProcessingInterruptedTest() throws IOException {
NotificationAccessor notificationAccessor = Mockito.mock(NotificationAccessor.class);
Mockito.doAnswer(invocation -> {
throw new InterruptedException("Test: exception for thread");
}).when(notificationAccessor).getFirstPageOfNotificationsNotProcessed(Mockito.anyInt());
NotificationProcessor notificationProcessor = mockNotificationProcessor(notificationAccessor);
EventManager eventManager = mockEventManager();
NotificationReceivedEventHandler eventHandler = new NotificationReceivedEventHandler(notificationAccessor, notificationProcessor, eventManager);
try {
eventHandler.handle(new NotificationReceivedEvent());
} catch (RuntimeException e) {
fail("Unable to handle event", e);
}
}
use of com.synopsys.integration.alert.api.event.EventManager in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testHandleEventProcessedNotificationsWithPages.
@Test
void testHandleEventProcessedNotificationsWithPages() {
EventManager eventManagerSpy = Mockito.spy(eventManager);
int totalNotifications = 200;
List<AlertNotificationModel> notificationContent = new ArrayList<>();
for (int index = 0; index < totalNotifications; index++) {
notificationContent.add(createAlertNotificationModel(false));
}
List<AlertNotificationModel> savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
assertNotNull(savedModels);
NotificationProcessor notificationProcessor = createNotificationProcessor();
NotificationReceivedEventHandler notificationReceivedEventHandler = new NotificationReceivedEventHandler(defaultNotificationAccessor, notificationProcessor, eventManagerSpy);
notificationReceivedEventHandler.handle(new NotificationReceivedEvent());
Mockito.verify(eventManagerSpy, Mockito.atLeastOnce()).sendEvent(Mockito.any());
assertEquals(100, defaultNotificationAccessor.getFirstPageOfNotificationsNotProcessed(100).getModels().size());
}
use of com.synopsys.integration.alert.api.event.EventManager in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method distributeTest.
@Test
public void distributeTest() {
MockProcessingAuditAccessor processingAuditAccessor = new MockProcessingAuditAccessor();
EventManager eventManager = Mockito.mock(EventManager.class);
ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(uuid, slackChannelKey.getUniversalKey(), "JobName");
ProcessedProviderMessageHolder processedMessageHolder = createProcessedProviderMessageHolder(2, 2);
ProviderMessageDistributor providerMessageDistributor = new ProviderMessageDistributor(processingAuditAccessor, eventManager);
providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
Mockito.verify(eventManager, Mockito.times(4)).sendEvent(Mockito.any());
}
Aggregations