use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method distributeMissingDestinationKeyTest.
@Test
public void distributeMissingDestinationKeyTest() {
MockProcessingAuditAccessor processingAuditAccessor = new MockProcessingAuditAccessor();
EventManager eventManager = Mockito.mock(EventManager.class);
ProcessedNotificationDetails processedNotificationDetails = new ProcessedNotificationDetails(uuid, "bad channel key", "JobName");
ProcessedProviderMessageHolder processedMessageHolder = createProcessedProviderMessageHolder(1, 0);
ProviderMessageDistributor providerMessageDistributor = new ProviderMessageDistributor(processingAuditAccessor, eventManager);
providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
Mockito.verify(eventManager, Mockito.times(0)).sendEvent(Mockito.any());
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class NotificationContentProcessorTest method processNotificationContentSummaryTest.
@Test
public void processNotificationContentSummaryTest() {
AlertNotificationModel notificationModel = createNotification(NotificationType.RULE_VIOLATION.name());
RuleViolationUniquePolicyNotificationContent notificationContent = blackDuckResponseTestUtility.createRuleViolationUniquePolicyNotificationContent(projectName, projectVersionName);
NotificationContentWrapper notificationContentWrapper1 = new NotificationContentWrapper(notificationModel, notificationContent, RuleViolationUniquePolicyNotificationContent.class);
// When set to summary, project messages will be summarized into a SimpleMessage rather than ProjectMessage
ProcessedProviderMessageHolder processedProviderMessageHolder = notificationContentProcessor.processNotificationContent(ProcessingType.SUMMARY, List.of(notificationContentWrapper1));
List<ProcessedProviderMessage<ProjectMessage>> processedProviderMessages = processedProviderMessageHolder.getProcessedProjectMessages();
List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = processedProviderMessageHolder.getProcessedSimpleMessages();
assertTrue(processedProviderMessages.isEmpty());
assertEquals(1, processedSimpleMessages.size());
ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = processedSimpleMessages.get(0);
assertEquals(1, processedSimpleMessage.getNotificationIds().size());
assertTrue(processedSimpleMessage.getNotificationIds().contains(notificationId));
SimpleMessage simpleMessage = processedSimpleMessage.getProviderMessage();
assertEquals(PROVIDER_DETAILS, simpleMessage.getProviderDetails());
assertTrue(simpleMessage.getSource().isPresent());
ProjectMessage sourceProjectMessage = simpleMessage.getSource().get();
assertEquals(projectName, sourceProjectMessage.getProject().getValue());
assertTrue(sourceProjectMessage.getProjectVersion().isPresent());
assertEquals(projectVersionName, sourceProjectMessage.getProjectVersion().get().getValue());
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class JobNotificationProcessor method processAndDistribute.
private void processAndDistribute(ProcessedNotificationDetails processedNotificationDetails, ProcessingType processingType, List<AlertNotificationModel> notifications) {
List<NotificationContentWrapper> notificationContentWrappers = notifications.stream().map(notificationDetailExtractionDelegator::wrapNotification).flatMap(List::stream).map(DetailedNotificationContent::getNotificationContentWrapper).collect(Collectors.toList());
ProcessedProviderMessageHolder processedMessageHolder = notificationContentProcessor.processNotificationContent(processingType, notificationContentWrappers);
providerMessageDistributor.distribute(processedNotificationDetails, processedMessageHolder);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class ProviderMessageDistributor method distribute.
public void distribute(ProcessedNotificationDetails processedNotificationDetails, ProcessedProviderMessageHolder processedMessageHolder) {
String channelName = processedNotificationDetails.getChannelName();
ChannelKey destinationKey = ChannelKeys.getChannelKey(channelName);
if (null == destinationKey) {
logger.warn("Unable to send {}. No {} with the name {} exists", EVENT_CLASS_NAME, DESTINATION_WRAPPER_CLASS_NAME, channelName);
return;
}
for (ProcessedProviderMessageHolder singleMessageHolder : processedMessageHolder.expand()) {
distributeIndividually(processedNotificationDetails.getJobId(), processedNotificationDetails.getJobName(), destinationKey, singleMessageHolder);
}
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder in project hub-alert by blackducksoftware.
the class ProviderMessageExtractor method extract.
public final ProcessedProviderMessageHolder extract(NotificationContentWrapper notificationContentWrapper) {
if (!notificationContentClass.isAssignableFrom(notificationContentWrapper.getNotificationContentClass())) {
logger.error("The notification type provided is incompatible with this extractor: {}", notificationContentWrapper.extractNotificationType());
return ProcessedProviderMessageHolder.empty();
}
T stronglyTypedContent = notificationContentClass.cast(notificationContentWrapper.getNotificationContent());
ProviderMessageHolder extractedMessages = extract(notificationContentWrapper, stronglyTypedContent);
return toProcessedProviderMessageHolder(notificationContentWrapper.getNotificationId(), extractedMessages);
}
Aggregations