Search in sources :

Example 11 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProcessedProviderMessageTest method combineProjectVersionOperationsDontMatchTest.

@Test
public void combineProjectVersionOperationsDontMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    LinkableItem commonProjectVersion = new LinkableItem("Project Version", "Project Version 1");
    ProjectMessage projectMessage1 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, ProjectOperation.CREATE);
    ProjectMessage projectMessage2 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, ProjectOperation.DELETE);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
    // Create then delete
    List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages1 = processedProviderMessage1.combine(processedProviderMessage2);
    assertEquals(0, combinedProjectMessages1.size());
    // Delete then create
    List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages2 = processedProviderMessage2.combine(processedProviderMessage1);
    assertEquals(1, combinedProjectMessages2.size());
    assertEquals(processedProviderMessage1.getProviderMessage(), combinedProjectMessages2.get(0).getProviderMessage());
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) Test(org.junit.jupiter.api.Test)

Example 12 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProcessedProviderMessageTest method combineProviderDetailsDontMatchTest.

@Test
public void combineProviderDetailsDontMatchTest() {
    LinkableItem commonProject = new LinkableItem("Project", "Common Project");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    LinkableItem provider1 = new LinkableItem("Provider", "Provider 1");
    ProviderDetails providerDetails1 = new ProviderDetails(1L, provider1);
    ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails1, commonProject, commonOperation);
    LinkableItem provider2 = new LinkableItem("Provider", "Provider 2");
    ProviderDetails providerDetails2 = new ProviderDetails(2L, provider2);
    ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails2, commonProject, commonOperation);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
    assertNotCombined(processedProviderMessage1, processedProviderMessage2);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Example 13 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProcessedProviderMessageTest method combineProjectOperationsDontMatchTest.

@Test
public void combineProjectOperationsDontMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, ProjectOperation.CREATE);
    ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, ProjectOperation.DELETE);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
    // Create then delete
    List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages1 = processedProviderMessage1.combine(processedProviderMessage2);
    assertEquals(0, combinedProjectMessages1.size());
    // Delete then create
    List<ProcessedProviderMessage<ProjectMessage>> combinedProjectMessages2 = processedProviderMessage2.combine(processedProviderMessage1);
    assertEquals(1, combinedProjectMessages2.size());
    assertEquals(processedProviderMessage1.getProviderMessage(), combinedProjectMessages2.get(0).getProviderMessage());
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) Test(org.junit.jupiter.api.Test)

Example 14 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class ProcessedProviderMessageTest method combineProjectVersionOperationsMatchTest.

@Test
public void combineProjectVersionOperationsMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    LinkableItem commonProjectVersion = new LinkableItem("Project Version", "Project Version 1");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    ProjectMessage projectMessage1 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, commonOperation);
    ProjectMessage projectMessage2 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, commonProjectVersion, commonOperation);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage1 = ProcessedProviderMessage.singleSource(10L, projectMessage1);
    ProcessedProviderMessage<ProjectMessage> processedProviderMessage2 = ProcessedProviderMessage.singleSource(20L, projectMessage2);
    assertCombined(processedProviderMessage1, processedProviderMessage2);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ProjectOperation(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation) Test(org.junit.jupiter.api.Test)

Example 15 with LinkableItem

use of com.synopsys.integration.alert.common.message.model.LinkableItem in project hub-alert by blackducksoftware.

the class BomComponentDetailsTest method combineWithDifferentComponentsTest.

@Test
public void combineWithDifferentComponentsTest() {
    ComponentConcern policyConcern = ComponentConcern.policy(ItemOperation.ADD, "Added Policy", "https://policy");
    ComponentConcern vulnerabilityConcern = ComponentConcern.vulnerability(ItemOperation.ADD, "Added-Vuln01", ComponentConcernSeverity.CRITICAL, "https://synopsys.com");
    LinkableItem differentComponent = new LinkableItem("Component-does-not-match", "A BOM component");
    BomComponentDetails bomComponentDetailsPolicy = new BomComponentDetails(COMPONENT, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(), List.of(policyConcern), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(), ISSUES_URL);
    BomComponentDetails bomComponentDetailsVulnerability = new BomComponentDetails(differentComponent, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(), List.of(vulnerabilityConcern), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(), ISSUES_URL);
    List<BomComponentDetails> bomComponentDetailsList = bomComponentDetailsPolicy.combine(bomComponentDetailsVulnerability);
    assertEquals(2, bomComponentDetailsList.size());
    assertTrue(bomComponentDetailsList.contains(bomComponentDetailsPolicy));
    assertTrue(bomComponentDetailsList.contains(bomComponentDetailsVulnerability));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) Test(org.junit.jupiter.api.Test)

Aggregations

LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)94 Test (org.junit.jupiter.api.Test)39 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)26 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)22 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)18 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)15 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)13 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)11 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)11 ArrayList (java.util.ArrayList)11 LinkedList (java.util.LinkedList)11 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)9 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)9 List (java.util.List)9 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)8 Optional (java.util.Optional)7 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)6 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)6 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)6 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)6