Search in sources :

Example 21 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails 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)

Example 22 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails 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 23 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails 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)

Example 24 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class ProjectMessageTest 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);
    // Create then delete
    List<ProjectMessage> combinedProjectMessages1 = projectMessage1.combine(projectMessage2);
    assertEquals(0, combinedProjectMessages1.size());
    // Delete then create
    List<ProjectMessage> combinedProjectMessages2 = projectMessage2.combine(projectMessage1);
    assertEquals(1, combinedProjectMessages2.size());
    assertEquals(projectMessage1, combinedProjectMessages2.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 25 with ProviderDetails

use of com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails in project hub-alert by blackducksoftware.

the class ProjectMessageTest 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);
    assertCombined(projectMessage1, projectMessage2);
}
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

ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)27 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)25 Test (org.junit.jupiter.api.Test)13 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)8 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)7 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)5 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)5 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)5 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)5 ProjectOperation (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectOperation)4 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)3 WorkItemElementOperationModel (com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel)3 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)3 MockChannelMessageFormatter (com.synopsys.integration.alert.api.channel.convert.mock.MockChannelMessageFormatter)2 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)1 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)1 IssueTrackerCallbackInfo (com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo)1