use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationAccessorTestIT method testSave.
@Test
public void testSave() {
AlertNotificationModel notificationContent = createNotificationModel();
List<AlertNotificationModel> savedModels = notificationManager.saveAllNotifications(List.of(notificationContent));
assertNotNull(savedModels);
assertFalse(savedModels.isEmpty());
AlertNotificationModel savedModel = savedModels.get(0);
assertNotNull(savedModel.getId());
assertNotificationModel(notificationContent, savedModel);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel 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.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationContentProcessorTest method processNotificationContentDefaultTest.
@Test
public void processNotificationContentDefaultTest() {
// Create a NotificationContentWrapper
AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
NotificationContentWrapper notificationContentWrapper = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
// Run the test
ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.DEFAULT, List.of(notificationContentWrapper));
runProjectMessageAssertions(processedProviderMessageHolder, projectName, projectVersionName);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationContentProcessorTest method createNotification.
private AlertNotificationModel createNotification(String notificationType) {
RuleViolationNotificationView ruleViolationNotificationView = blackDuckResponseTestUtility.createRuleViolationNotificationView(projectName, projectVersionName);
String notificationContent = GSON.toJson(ruleViolationNotificationView);
return new AlertNotificationModel(notificationId, PROVIDER_DETAILS.getProviderConfigId(), PROVIDER_DETAILS.getProvider().getLabel(), PROVIDER_DETAILS.getProvider().getValue(), notificationType, notificationContent, OffsetDateTime.now(), OffsetDateTime.now(), false);
}
use of com.synopsys.integration.alert.common.rest.model.AlertNotificationModel in project hub-alert by blackducksoftware.
the class NotificationContentProcessorTest method processNotificationContentDigestTest.
@Test
public void processNotificationContentDigestTest() {
AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
NotificationContentWrapper notificationContentWrapper1 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
NotificationContentWrapper notificationContentWrapper2 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
// When set to digest, the NotificationContentProcessor will combine duplicate duplicate messages created from the two NotificationContentWrappers to a single message
ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.DIGEST, List.of(notificationContentWrapper1, notificationContentWrapper2));
runProjectMessageAssertions(processedProviderMessageHolder, projectName, projectVersionName);
}
Aggregations