Search in sources :

Example 86 with LinkableItem

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

the class ProcessedProviderMessageTest method combineProjectOperationsMatchTest.

@Test
public void combineProjectOperationsMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    ProjectMessage projectMessage1 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, commonOperation);
    ProjectMessage projectMessage2 = ProjectMessage.projectStatusInfo(providerDetails, commonProject, 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 87 with LinkableItem

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

the class BomComponentDetailsTest method combineAdditionalAttributesRightTest.

@Test
public void combineAdditionalAttributesRightTest() {
    LinkableItem additionalAttribute1 = new LinkableItem("Attribute 1", "additionalAttribute1");
    LinkableItem additionalAttribute2 = new LinkableItem("Attribute 2", "additionalAttribute2");
    ComponentConcern policyConcern = ComponentConcern.policy(ItemOperation.ADD, "Added Policy", "https://policy");
    ComponentConcern policyConcern2 = ComponentConcern.policy(ItemOperation.ADD, "Added Policy 2", "https://policy2");
    BomComponentDetails bomComponentDetailsPolicy = new BomComponentDetails(COMPONENT, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(COMPONENT_POLICY), List.of(policyConcern), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(additionalAttribute1), ISSUES_URL);
    BomComponentDetails bomComponentDetailsPolicy2 = new BomComponentDetails(COMPONENT, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(), List.of(policyConcern, policyConcern2), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(additionalAttribute2), ISSUES_URL);
    List<BomComponentDetails> bomComponentDetailsCombined = bomComponentDetailsPolicy.combine(bomComponentDetailsPolicy2);
    assertEquals(1, bomComponentDetailsCombined.size());
    BomComponentDetails bomComponentDetails = bomComponentDetailsCombined.get(0);
    assertEquals(1, bomComponentDetails.getAdditionalAttributes().size());
    assertTrue(bomComponentDetails.getAdditionalAttributes().contains(additionalAttribute2));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) Test(org.junit.jupiter.api.Test)

Example 88 with LinkableItem

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

the class BomComponentDetailsTest method combineAdditionalAttributesLeftTest.

@Test
public void combineAdditionalAttributesLeftTest() {
    LinkableItem additionalAttribute1 = new LinkableItem("Attribute 1", "additionalAttribute1");
    LinkableItem additionalAttribute2 = new LinkableItem("Attribute 2", "additionalAttribute2");
    ComponentConcern policyConcern = ComponentConcern.policy(ItemOperation.ADD, "Added Policy", "https://policy");
    ComponentConcern policyConcern2 = ComponentConcern.policy(ItemOperation.ADD, "Added Policy 2", "https://policy2");
    BomComponentDetails bomComponentDetailsPolicy = new BomComponentDetails(COMPONENT, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(COMPONENT_POLICY), List.of(policyConcern, policyConcern2), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(additionalAttribute1), ISSUES_URL);
    BomComponentDetails bomComponentDetailsPolicy2 = new BomComponentDetails(COMPONENT, COMPONENT_VERSION, ComponentVulnerabilities.none(), List.of(), List.of(policyConcern2), LICENSE, USAGE, ComponentUpgradeGuidance.none(), List.of(additionalAttribute2), ISSUES_URL);
    List<BomComponentDetails> bomComponentDetailsCombined = bomComponentDetailsPolicy.combine(bomComponentDetailsPolicy2);
    assertEquals(1, bomComponentDetailsCombined.size());
    BomComponentDetails bomComponentDetails = bomComponentDetailsCombined.get(0);
    assertEquals(1, bomComponentDetails.getAdditionalAttributes().size());
    assertTrue(bomComponentDetails.getAdditionalAttributes().contains(additionalAttribute1));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) Test(org.junit.jupiter.api.Test)

Example 89 with LinkableItem

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

the class ProjectMessageTest method hasBomComponentsTest.

@Test
public void hasBomComponentsTest() {
    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");
    BomComponentDetails bomComponentDetails = new BomComponentDetails(new LinkableItem("Component", "The component"), commonProjectVersion, ComponentVulnerabilities.none(), List.of(), List.of(), new LinkableItem("License", "The software license name", "https://license-url"), "The usage of the component", ComponentUpgradeGuidance.none(), List.of(), "https://blackduck-issues-url");
    ProjectMessage projectMessage = ProjectMessage.componentConcern(providerDetails, commonProject, commonProjectVersion, List.of(bomComponentDetails));
    assertTrue(projectMessage.hasBomComponents());
    assertEquals(1, projectMessage.getBomComponents().size());
    assertEquals(bomComponentDetails, projectMessage.getBomComponents().get(0));
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) Test(org.junit.jupiter.api.Test)

Example 90 with LinkableItem

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

the class ProjectMessageTest method combineProjectVersionsDontMatchTest.

@Test
public void combineProjectVersionsDontMatchTest() {
    LinkableItem provider = new LinkableItem("Provider", "Provider Config Name");
    ProviderDetails providerDetails = new ProviderDetails(1L, provider);
    LinkableItem commonProject = new LinkableItem("Project", "Project 1");
    ProjectOperation commonOperation = ProjectOperation.CREATE;
    LinkableItem projectVersion1 = new LinkableItem("Project Version", "Project Version 1");
    LinkableItem projectVersion2 = new LinkableItem("Project Version", "Project Version 2");
    ProjectMessage projectMessage1 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, null, commonOperation);
    ProjectMessage projectMessage2 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, projectVersion1, commonOperation);
    ProjectMessage projectMessage3 = ProjectMessage.projectVersionStatusInfo(providerDetails, commonProject, projectVersion2, commonOperation);
    assertNotCombined(projectMessage1, projectMessage2);
    assertNotCombined(projectMessage1, projectMessage3);
    assertNotCombined(projectMessage2, projectMessage3);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) 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