use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder 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.processor.api.extract.model.ProcessedProviderMessageHolder 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);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder 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());
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method createProcessedProviderMessageHolder.
private ProcessedProviderMessageHolder createProcessedProviderMessageHolder(int numberOfProjectMessages, int numberOfSimpleMessages) {
List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = new ArrayList<>();
List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = new ArrayList<>();
LinkableItem commonProject = new LinkableItem("Project", "Common Project");
ProjectOperation commonOperation = ProjectOperation.CREATE;
for (long i = 1; i < numberOfProjectMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Provider", "Provider " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = ProcessedProviderMessage.singleSource(i, projectMessage);
processedProjectMessages.add(processedProviderMessage);
}
for (long i = 1; i < numberOfSimpleMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Details", "Detail " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Summary " + i, "Description " + i, List.of(commonProject));
ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = ProcessedProviderMessage.singleSource(i, simpleMessage);
processedSimpleMessages.add(processedSimpleMessage);
}
return new ProcessedProviderMessageHolder(processedProjectMessages, processedSimpleMessages);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class NotificationProcessor method processAndDistribute.
private void processAndDistribute(FilteredJobNotificationWrapper jobNotificationWrapper) {
List<NotificationContentWrapper> filteredNotifications = jobNotificationWrapper.getJobNotifications();
ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(jobNotificationWrapper.getJobId(), jobNotificationWrapper.getChannelName(), jobNotificationWrapper.getJobName());
ProcessedProviderMessageHolder processedMessageHolder = notificationContentProcessor.processNotificationContent(jobNotificationWrapper.getProcessingType(), filteredNotifications);
providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
}
Aggregations