use of com.synopsys.integration.alert.api.event.NotificationReceivedEvent in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandler method processNotifications.
private void processNotifications() {
AlertPagedModel<AlertNotificationModel> pageOfAlertNotificationModels = notificationAccessor.getFirstPageOfNotificationsNotProcessed(PAGE_SIZE);
if (!CollectionUtils.isEmpty(pageOfAlertNotificationModels.getModels())) {
List<AlertNotificationModel> notifications = pageOfAlertNotificationModels.getModels();
logger.info("Starting to process {} notifications.", notifications.size());
notificationProcessor.processNotifications(notifications, List.of(FrequencyType.REAL_TIME));
boolean hasMoreNotificationsToProcess = notificationAccessor.hasMoreNotificationsToProcess();
if (hasMoreNotificationsToProcess) {
eventManager.sendEvent(new NotificationReceivedEvent());
}
}
logger.info("Finished processing event for notifications.");
}
use of com.synopsys.integration.alert.api.event.NotificationReceivedEvent in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTest method handleEventProcessingExceptionTest.
@Test
void handleEventProcessingExceptionTest() throws IOException {
NotificationAccessor notificationAccessor = Mockito.mock(NotificationAccessor.class);
Mockito.doAnswer((invocation) -> {
throw new ExecutionException(new RuntimeException("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.NotificationReceivedEvent in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testHandleEventProcessedNotifications.
@Test
void testHandleEventProcessedNotifications() {
List<AlertNotificationModel> notificationContent = new ArrayList<>();
notificationContent.add(createAlertNotificationModel(true));
notificationContent.add(createAlertNotificationModel(true));
List<AlertNotificationModel> savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
assertNotNull(savedModels);
assertEquals(0, defaultNotificationAccessor.getFirstPageOfNotificationsNotProcessed(pageSize).getModels().size());
NotificationProcessor notificationProcessor = createNotificationProcessor();
NotificationReceivedEventHandler notificationReceivedEventHandler = new NotificationReceivedEventHandler(defaultNotificationAccessor, notificationProcessor, eventManager);
notificationReceivedEventHandler.handle(new NotificationReceivedEvent());
testAlertNotificationModels(savedModels);
}
use of com.synopsys.integration.alert.api.event.NotificationReceivedEvent in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTestIT method testHandleEventMixedProcessedNotifications.
@Test
void testHandleEventMixedProcessedNotifications() {
List<AlertNotificationModel> notificationContent = new ArrayList<>();
notificationContent.add(createAlertNotificationModel(true));
notificationContent.add(createAlertNotificationModel(false));
List<AlertNotificationModel> savedModels = defaultNotificationAccessor.saveAllNotifications(notificationContent);
assertNotNull(savedModels);
NotificationProcessor notificationProcessor = createNotificationProcessor();
NotificationReceivedEventHandler notificationReceivedEventHandler = new NotificationReceivedEventHandler(defaultNotificationAccessor, notificationProcessor, eventManager);
notificationReceivedEventHandler.handle(new NotificationReceivedEvent());
testAlertNotificationModels(savedModels);
}
use of com.synopsys.integration.alert.api.event.NotificationReceivedEvent in project hub-alert by blackducksoftware.
the class JmsNotificationReceiverTestIT method testJms.
@Test
@Disabled
void testJms() throws InterruptedException {
// Set breakpoints throughout this test, there is nothing to assert against here. Suggestions for breakpoints:
// Registering listeners: EventListenerConfigurer
// Sending events: EventManager
// Receiving events: NotificationReceiver or DistributionChannel
// Processing notifications: NotificationReceiver
NotificationReceivedEvent notificationReceivedEvent = new NotificationReceivedEvent();
eventManager.sendEvent(notificationReceivedEvent);
Thread.sleep(120000);
}
Aggregations