Search in sources :

Example 11 with ProcessedProviderMessage

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage 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"));
}
Also used : ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ComponentConcern(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern) BomComponentDetails(com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails) Test(org.junit.jupiter.api.Test)

Example 12 with ProcessedProviderMessage

use of com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage 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);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProcessedProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder) ProcessedProviderMessage(com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ArrayList(java.util.ArrayList) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)

Aggregations

ProcessedProviderMessage (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessage)12 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)12 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)10 Test (org.junit.jupiter.api.Test)8 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)4 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)4 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)4 ProcessedProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProcessedProviderMessageHolder)2 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)1 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)1 NotificationContentWrapper (com.synopsys.integration.alert.processor.api.filter.NotificationContentWrapper)1 RuleViolationUniquePolicyNotificationContent (com.synopsys.integration.alert.provider.blackduck.processor.model.RuleViolationUniquePolicyNotificationContent)1 ArrayList (java.util.ArrayList)1