use of com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage 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.SimpleMessage 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));
}
use of com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage in project hub-alert by blackducksoftware.
the class ProjectMessageSummarizerTest method summarizeComponentUpdateTest.
@Test
public void summarizeComponentUpdateTest() {
ComponentConcern policyConcern = ComponentConcern.severePolicy(ItemOperation.ADD, "A severe policy", ComponentConcernSeverity.TRIVIAL_LOW, "https://severe-policy");
ComponentConcern vulnerabilityConcern1 = ComponentConcern.vulnerability(ItemOperation.ADD, "CVE-123", ComponentConcernSeverity.CRITICAL, "https://vuln-rul");
ComponentConcern vulnerabilityConcern2 = ComponentConcern.vulnerability(ItemOperation.UPDATE, "CVE-135", ComponentConcernSeverity.TRIVIAL_LOW, "https://vuln-rul");
ComponentConcern vulnerabilityConcern3 = ComponentConcern.vulnerability(ItemOperation.DELETE, "CVE-246", ComponentConcernSeverity.MINOR_MEDIUM, "https://vuln-rul");
BomComponentDetails bomComponentDetails = createBomComponentDetails(List.of(policyConcern, vulnerabilityConcern1, vulnerabilityConcern2, vulnerabilityConcern3));
ProjectMessage projectMessage = ProjectMessage.componentUpdate(providerDetails, commonProject, commonProjectVersion, List.of(bomComponentDetails));
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = new ProcessedProviderMessage<>(Set.of(1L), projectMessage);
ProcessedProviderMessage<SimpleMessage> summarizedSimpleMessage = projectMessageSummarizer.summarize(processedProviderMessage);
SimpleMessage simpleMessage = summarizedSimpleMessage.getProviderMessage();
printSimpleMessage(simpleMessage);
testProjectStatus(simpleMessage);
testComponentStatus(simpleMessage);
assertEquals(6, simpleMessage.getDetails().size());
assertTrue(doesLabelExist(simpleMessage.getDetails(), policyConcern.getSeverity().getPolicyLabel(), "Policies", ProjectMessageSummarizer.OP_PARTICIPLE_VIOLATED));
assertTrue(doesLabelExist(simpleMessage.getDetails(), vulnerabilityConcern1.getSeverity().getVulnerabilityLabel(), "Vulnerabilities", ProjectMessageSummarizer.OP_PARTICIPLE_ADDED));
assertTrue(doesLabelExist(simpleMessage.getDetails(), vulnerabilityConcern2.getSeverity().getVulnerabilityLabel(), "Vulnerabilities", ProjectMessageSummarizer.OP_PARTICIPLE_UPDATED));
assertTrue(doesLabelExist(simpleMessage.getDetails(), vulnerabilityConcern3.getSeverity().getVulnerabilityLabel(), "Vulnerabilities", ProjectMessageSummarizer.OP_PARTICIPLE_DELETED));
assertTrue(simpleMessage.getDescription().contains("updates"));
}
use of com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage in project hub-alert by blackducksoftware.
the class ProviderMessageDistributorTest method createProcessedProviderMessageHolder.
private ProcessedProviderMessageHolder createProcessedProviderMessageHolder(int numberOfProjectMessages, int numberOfSimpleMessages) {
List<ProcessedProviderMessage<ProjectMessage>> processedProjectMessages = new ArrayList<>();
List<ProcessedProviderMessage<SimpleMessage>> processedSimpleMessages = new ArrayList<>();
LinkableItem commonProject = new LinkableItem("Project", "Common Project");
ProjectOperation commonOperation = ProjectOperation.CREATE;
for (long i = 1; i < numberOfProjectMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Provider", "Provider " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
ProjectMessage projectMessage = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
ProcessedProviderMessage<ProjectMessage> processedProviderMessage = ProcessedProviderMessage.singleSource(i, projectMessage);
processedProjectMessages.add(processedProviderMessage);
}
for (long i = 1; i < numberOfSimpleMessages + 1; i++) {
LinkableItem provider = new LinkableItem("Details", "Detail " + i);
ProviderDetails providerDetails = new ProviderDetails(i, provider);
SimpleMessage simpleMessage = SimpleMessage.original(providerDetails, "Summary " + i, "Description " + i, List.of(commonProject));
ProcessedProviderMessage<SimpleMessage> processedSimpleMessage = ProcessedProviderMessage.singleSource(i, simpleMessage);
processedSimpleMessages.add(processedSimpleMessage);
}
return new ProcessedProviderMessageHolder(processedProjectMessages, processedSimpleMessages);
}
Aggregations