use of com.synopsys.integration.alert.processor.api.digest.ProjectMessageDigester in project hub-alert by blackducksoftware.
the class JobNotificationProcessorTest method processNotificationForJobTest.
@Test
public void processNotificationForJobTest() throws IntegrationException {
// Set up dependencies for JobNotificationProcessor
RuleViolationNotificationDetailExtractor ruleViolationNotificationDetailExtractor = new RuleViolationNotificationDetailExtractor();
NotificationDetailExtractionDelegator notificationDetailExtractionDelegator = new NotificationDetailExtractionDelegator(RESPONSE_RESOLVER, List.of(ruleViolationNotificationDetailExtractor));
RuleViolationNotificationMessageExtractor ruleViolationNotificationMessageExtractor = createRuleViolationNotificationMessageExtractor();
ProviderMessageExtractionDelegator providerMessageExtractionDelegator = new ProviderMessageExtractionDelegator(List.of(ruleViolationNotificationMessageExtractor));
ProjectMessageDigester projectMessageDigester = new ProjectMessageDigester();
ProjectMessageSummarizer projectMessageSummarizer = new ProjectMessageSummarizer();
NotificationContentProcessor notificationContentProcessor = new NotificationContentProcessor(providerMessageExtractionDelegator, projectMessageDigester, projectMessageSummarizer);
MockProcessingAuditAccessor processingAuditAccessor = new MockProcessingAuditAccessor();
EventManager eventManager = Mockito.mock(EventManager.class);
ProviderMessageDistributor providerMessageDistributor = new ProviderMessageDistributor(processingAuditAccessor, eventManager);
NotificationExtractorBlackDuckServicesFactoryCache lifecycleCaches = createNotificationExtractorBlackDuckServicesFactoryCache();
// Create Requirements for processNotificationForJob
ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(uuid, CHANNEL_KEY, "JobName");
AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
// Run test and verify notification saved by ProcessingAuditAccessor
JobNotificationProcessor jobNotificationProcessor = new JobNotificationProcessor(notificationDetailExtractionDelegator, notificationContentProcessor, providerMessageDistributor, List.of(lifecycleCaches));
jobNotificationProcessor.processNotificationForJob(processedNotificationDetails, ProcessingType.DEFAULT, List.of(notificationModel));
Set<Long> auditNotificationIds = processingAuditAccessor.getNotificationIds(uuid);
Mockito.verify(eventManager, Mockito.times(1)).sendEvent(Mockito.any());
assertEquals(1, auditNotificationIds.size());
assertTrue(auditNotificationIds.contains(notificationId));
}
Aggregations