use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage 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.ProcessedProviderMessage in project hub-alert by blackducksoftware.
the class NotificationContentProcessorTest method runProjectMessageAssertions.
private void runProjectMessageAssertions(ProcessedProviderMessageHolder processedProviderMessageHolder, String projectName, String projectVersionName) {
List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = processedProviderMessageHolder.getProcessedProjectMessages();
List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = processedProviderMessageHolder.getProcessedSimpleMessages();
assertTrue(processedSimpleMessages.isEmpty());
assertEquals(1, processedProjectMessages.size());
ProcessedProviderMessage<ProjectMessage> processedProjectMessage = processedProjectMessages.get(0);
assertEquals(1, processedProjectMessage.getNotificationIds().size());
assertTrue(processedProjectMessage.getNotificationIds().contains(notificationId));
ProjectMessage projectMessage = processedProjectMessage.getProviderMessage();
assertEquals(projectName, projectMessage.getProject().getValue());
assertTrue(projectMessage.getProjectVersion().isPresent());
assertEquals(projectVersionName, projectMessage.getProjectVersion().get().getValue());
assertEquals(PROVIDER_DETAILS, projectMessage.getProviderDetails());
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizer method summarize.
public ProcessedProviderMessage<SimpleMessage> summarize(ProcessedProviderMessage<ProjectMessage> digestedProjectMessage) {
ProjectMessage projectMessage = digestedProjectMessage.getProviderMessage();
Pair<String, String> summaryAndDescription = constructSummaryAndDescription(projectMessage);
List<LinkableItem> details = constructMessageDetails(projectMessage);
SimpleMessage derivedSimpleMessage = SimpleMessage.derived(summaryAndDescription.getLeft(), summaryAndDescription.getRight(), details, projectMessage);
return new ProcessedProviderMessage<>(digestedProjectMessage.getNotificationIds(), derivedSimpleMessage);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage in project hub-alert by blackducksoftware.
the class ProjectMessageDigesterTest method createProcessedProviderMessage.
private ProcessedProviderMessage<ProjectMessage> createProcessedProviderMessage(String projectName, ProjectOperation operation) {
LinkableItem project1 = new LinkableItem("proj", projectName, "https://" + projectName);
ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(PROVIDER_DETAILS, project1, operation);
return new ProcessedProviderMessage<>(Set.of(), projectMessage1);
}
use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizerTest method summarizeProjectStatusDeletedTest.
@Test
public void summarizeProjectStatusDeletedTest() {
ProjectOperation commonOperation = ProjectOperation.DELETE;
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = new ProcessedProviderMessage<>(Set.of(1L), projectMessage);
ProcessedProviderMessage<SimpleMessage> summarizedSimpleMessage = projectMessageSummarizer.summarize(processedProviderMessage);
SimpleMessage simpleMessage = summarizedSimpleMessage.getProviderMessage();
printSimpleMessage(simpleMessage);
testProjectStatus(simpleMessage);
assertEquals(1, simpleMessage.getDetails().size());
assertTrue(simpleMessage.getDetails().contains(commonProject));
assertTrue(simpleMessage.getSummary().contains(ProjectMessageSummarizer.OP_PARTICIPLE_DELETED));
}
Aggregations