use of com.synopsys.integration.alert.common.rest.model.AlertPagedDetails in project hub-alert by blackducksoftware.
the class JobNotificationMapper method mapPageOfJobsToNotification.
private AlertPagedDetails<FilteredJobNotificationWrapper> mapPageOfJobsToNotification(List<DetailedNotificationContent> detailedContents, List<FrequencyType> frequencies, int pageNumber, int pageSize) {
if (detailedContents.isEmpty()) {
return new AlertPagedDetails<>(1, pageNumber, pageSize, List.of());
}
Map<FilteredDistributionJobResponseModel, List<NotificationContentWrapper>> groupedFilterableNotifications = new HashMap<>();
FilteredDistributionJobRequestModel filteredDistributionJobRequestModel = createRequestModelFromNotifications(detailedContents, frequencies);
AlertPagedDetails<FilteredDistributionJobResponseModel> jobs = processingJobAccessor.getMatchingEnabledJobsByFilteredNotifications(filteredDistributionJobRequestModel, pageNumber, pageSize);
for (DetailedNotificationContent detailedNotificationContent : detailedContents) {
for (FilteredDistributionJobResponseModel filteredDistributionJobResponseModel : jobs.getModels()) {
if (JobNotificationFilterUtils.doesNotificationApplyToJob(filteredDistributionJobResponseModel, detailedNotificationContent)) {
List<NotificationContentWrapper> applicableNotifications = groupedFilterableNotifications.computeIfAbsent(filteredDistributionJobResponseModel, ignoredKey -> new LinkedList<>());
applicableNotifications.add(detailedNotificationContent.getNotificationContentWrapper());
}
}
}
List<FilteredJobNotificationWrapper> filterableJobNotifications = new LinkedList<>();
for (Map.Entry<FilteredDistributionJobResponseModel, List<NotificationContentWrapper>> groupedEntry : groupedFilterableNotifications.entrySet()) {
FilteredDistributionJobResponseModel filteredJob = groupedEntry.getKey();
FilteredJobNotificationWrapper wrappedJobNotifications = new FilteredJobNotificationWrapper(filteredJob.getId(), filteredJob.getProcessingType(), filteredJob.getChannelName(), filteredJob.getJobName(), groupedEntry.getValue());
filterableJobNotifications.add(wrappedJobNotifications);
}
return new AlertPagedDetails<>(jobs.getTotalPages(), pageNumber, pageSize, filterableJobNotifications);
}
use of com.synopsys.integration.alert.common.rest.model.AlertPagedDetails in project hub-alert by blackducksoftware.
the class NotificationReceivedEventHandlerTest method mockNotificationProcessor.
private NotificationProcessor mockNotificationProcessor(NotificationAccessor notificationAccessor) {
NotificationDetailExtractionDelegator detailExtractionDelegator = new NotificationDetailExtractionDelegator(blackDuckResponseResolver, List.of());
JobNotificationMapper jobNotificationMapper = Mockito.mock(JobNotificationMapper.class);
Predicate<AlertPagedDetails> hasNextPage = page -> page.getCurrentPage() < (page.getTotalPages() - 1);
StatefulAlertPage<FilteredJobNotificationWrapper, RuntimeException> statefulAlertPage = new StatefulAlertPage(AlertPagedDetails.emptyPage(), Mockito.mock(PageRetriever.class), hasNextPage);
Mockito.when(jobNotificationMapper.mapJobsToNotifications(Mockito.anyList(), Mockito.anyList())).thenReturn(statefulAlertPage);
return new NotificationProcessor(detailExtractionDelegator, jobNotificationMapper, null, null, List.of(), notificationAccessor);
}
use of com.synopsys.integration.alert.common.rest.model.AlertPagedDetails in project hub-alert by blackducksoftware.
the class BlackDuckAccumulatorTest method createMockNotificationPage.
private StatefulAlertPage<NotificationUserView, IntegrationException> createMockNotificationPage(PageRetriever pageRetriever) throws IntegrationException {
NotificationUserView notificationView = createMockNotificationView();
AlertPagedDetails<NotificationUserView> alertPagedDetails = new AlertPagedDetails<>(1, 0, 1, List.of(notificationView));
return new StatefulAlertPage<>(alertPagedDetails, pageRetriever, BlackDuckNotificationRetriever.HAS_NEXT_PAGE);
}
Aggregations