Search in sources :

Example 91 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class NotificationReceivedEventHandlerTestIT method cleanUpDB.

@AfterEach
public void cleanUpDB() {
    PageRequest pageRequest = defaultNotificationAccessor.getPageRequestForNotifications(0, pageSize, null, null);
    Page<AlertNotificationModel> notifications = defaultNotificationAccessor.findAll(pageRequest, false);
    notifications.get().forEach(defaultNotificationAccessor::deleteNotification);
    defaultNotificationAccessor.findByCreatedAtBefore(OffsetDateTime.now().minusMinutes(2));
    defaultConfigurationAccessor.deleteConfiguration(blackDuckGlobalConfigId);
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) PageRequest(org.springframework.data.domain.PageRequest) AfterEach(org.junit.jupiter.api.AfterEach)

Example 92 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel 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);
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ArrayList(java.util.ArrayList) NotificationProcessor(com.synopsys.integration.alert.processor.api.NotificationProcessor) NotificationReceivedEvent(com.synopsys.integration.alert.api.event.NotificationReceivedEvent) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 93 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel 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);
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel) ArrayList(java.util.ArrayList) NotificationProcessor(com.synopsys.integration.alert.processor.api.NotificationProcessor) NotificationReceivedEvent(com.synopsys.integration.alert.api.event.NotificationReceivedEvent) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 94 with AlertNotificationModel

use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.

the class MockNotificationAccessor method setNotificationsProcessed.

@Override
public void setNotificationsProcessed(List<AlertNotificationModel> notifications) {
    for (AlertNotificationModel notification : notifications) {
        AlertNotificationModel updatedNotification = createProcessedAlertNotificationModel(notification);
        int index = alertNotificationModels.indexOf(notification);
        alertNotificationModels.set(index, updatedNotification);
    }
}
Also used : AlertNotificationModel(com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)

Aggregations

AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)94 Test (org.junit.jupiter.api.Test)62 DetailedNotificationContent (com.synopsys.integration.alert.processor.api.detail.DetailedNotificationContent)21 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)20 NotificationEntity (com.synopsys.integration.alert.database.notification.NotificationEntity)16 PageRequest (org.springframework.data.domain.PageRequest)16 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)14 NotificationContentRepository (com.synopsys.integration.alert.database.notification.NotificationContentRepository)14 OffsetDateTime (java.time.OffsetDateTime)13 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)11 ArrayList (java.util.ArrayList)10 NotificationProcessor (com.synopsys.integration.alert.processor.api.NotificationProcessor)9 NotificationReceivedEvent (com.synopsys.integration.alert.api.event.NotificationReceivedEvent)7 FilteredDistributionJobResponseModel (com.synopsys.integration.alert.common.persistence.model.job.FilteredDistributionJobResponseModel)7 DefaultNotificationAccessor (com.synopsys.integration.alert.database.api.DefaultNotificationAccessor)6 NotificationDetailExtractionDelegator (com.synopsys.integration.alert.processor.api.detail.NotificationDetailExtractionDelegator)6 NotificationContentComponent (com.synopsys.integration.blackduck.api.manual.component.NotificationContentComponent)5 PageImpl (org.springframework.data.domain.PageImpl)5 TaskManager (com.synopsys.integration.alert.api.task.TaskManager)4 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4