use of com.synopsys.integration.alert.common.persistence.accessor.ProcessingJobAccessor in project hub-alert by blackducksoftware.
the class NotificationProcessorTest method processNotificationsWithMoreThanAPageOfJobsTest.
@Test
public // Passing case: A distribution event is sent
void processNotificationsWithMoreThanAPageOfJobsTest() {
String projectName = "2468 - Test Project";
String matchingProjectNamePattern = "2468.*";
String nonMatchingProjectNamePattern = "13579asdf - DO NOT MATCH";
String targetNotificationType = NotificationType.RULE_VIOLATION.name();
String nonTargetNotificationType = NotificationType.LICENSE_LIMIT.name();
RuleViolationNotificationView ruleViolationNotificationView = createRuleViolationNotificationView(projectName);
String notificationContentString = GSON.toJson(ruleViolationNotificationView);
AlertNotificationModel notification = createNotification(targetNotificationType, notificationContentString);
FilteredDistributionJobResponseModel matchingJob = createJob(targetNotificationType, true, matchingProjectNamePattern);
List<FilteredDistributionJobResponseModel> nonMatchingJobs = createNonMatchingJobs(250, nonTargetNotificationType, true, nonMatchingProjectNamePattern);
// Only needs to handle the target notification type
NotificationDetailExtractionDelegator extractionDelegator = new NotificationDetailExtractionDelegator(BLACK_DUCK_RESPONSE_RESOLVER, List.of(RULE_VIOLATION_NDE));
ProcessingJobAccessor processingJobAccessor = new MockProcessingJobAccessor(nonMatchingJobs, matchingJob, 199);
// This is needed to verify the notification is "sent"
ProviderMessageDistributor distributor = Mockito.mock(ProviderMessageDistributor.class);
Mockito.doNothing().when(distributor).distribute(Mockito.any(), Mockito.any());
NotificationProcessor notificationProcessor = createNotificationProcessor(extractionDelegator, processingJobAccessor, distributor);
notificationProcessor.processNotifications(List.of(notification), List.of(FrequencyType.REAL_TIME, FrequencyType.DAILY));
// Exactly one distribution event should be sent
Mockito.verify(distributor, Mockito.times(1)).distribute(Mockito.any(), Mockito.any());
}
Aggregations