Search in sources :

Example 41 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method basicIssueTransitionModelTest.

private IssueTransitionModel<String> basicIssueTransitionModelTest(ItemOperation operation) {
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS);
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    ProjectIssueModelConverter converter = new ProjectIssueModelConverter(formatter);
    IssueTransitionModel<String> issueTransitionModel = converter.toIssueTransitionModel(EXISTING_ISSUE_DETAILS, projectIssueModel, operation);
    assertEquals(EXISTING_ISSUE_DETAILS, issueTransitionModel.getExistingIssueDetails());
    assertEquals(projectIssueModel, issueTransitionModel.getSource());
    return issueTransitionModel;
}
Also used : ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)

Example 42 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method toIssueCreationModelPolicyTest.

@Test
public void toIssueCreationModelPolicyTest() {
    IssuePolicyDetails testPolicy = new IssuePolicyDetails("Test Policy", ItemOperation.ADD, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.policy(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS, testPolicy);
    IssueCreationModel issueCreationModel = basicIssueCreationModelTest(projectIssueModel);
    assertTrue(issueCreationModel.getTitle().contains(testPolicy.getName()), "Expected policy name to be present in the title");
    assertTrue(issueCreationModel.getDescription().contains(testPolicy.getName()), "Expected policy name to be present in the description");
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 43 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class ProjectIssueModelConverterTest method toIssueCreationModelBomTest.

@Test
public void toIssueCreationModelBomTest() {
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS);
    basicIssueCreationModelTest(projectIssueModel);
}
Also used : ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 44 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class JiraIssueSearchResultCreator method createResultFromProjectIssue.

public ProjectIssueSearchResult<String> createResultFromProjectIssue(JiraSearcherResponseModel issue, ProviderDetails providerDetails, LinkableItem project) throws AlertException {
    JiraIssueSearchProperties issueProperties = issuePropertiesManager.retrieveIssueProperties(issue.getIssueKey());
    String nullableSubComponentName = issueProperties.getSubComponentName();
    String nullableSubComponentValue = issueProperties.getSubComponentValue();
    LinkableItem componentVersion = null;
    if (StringUtils.isNotBlank(nullableSubComponentName) && StringUtils.isNotBlank(nullableSubComponentValue)) {
        componentVersion = new LinkableItem(nullableSubComponentName, nullableSubComponentValue);
    }
    LinkableItem projectVersion = new LinkableItem(issueProperties.getSubTopicName(), issueProperties.getSubTopicValue());
    IssueBomComponentDetails bomComponentDetails = IssueBomComponentDetails.fromSearchResults(new LinkableItem(issueProperties.getComponentName(), issueProperties.getComponentValue()), componentVersion);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(providerDetails, project, projectVersion, bomComponentDetails);
    return createIssueResult(issue, projectIssueModel);
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) JiraIssueSearchProperties(com.synopsys.integration.alert.api.channel.jira.JiraIssueSearchProperties) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Example 45 with ProjectIssueModel

use of com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel in project hub-alert by blackducksoftware.

the class IssueCategoryRetrieverTest method retrieveIssueCategoryFromProjectIssueModel_VulnerabilityTest.

@Test
public void retrieveIssueCategoryFromProjectIssueModel_VulnerabilityTest() {
    IssueVulnerabilityDetails issueVulnerabilityDetails = Mockito.mock(IssueVulnerabilityDetails.class);
    ProjectIssueModel projectIssueModel = Mockito.mock(ProjectIssueModel.class);
    Mockito.when(projectIssueModel.getPolicyDetails()).thenReturn(Optional.empty());
    Mockito.when(projectIssueModel.getVulnerabilityDetails()).thenReturn(Optional.of(issueVulnerabilityDetails));
    IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
    IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromProjectIssueModel(projectIssueModel);
    assertEquals(IssueCategory.VULNERABILITY, issueCategory);
}
Also used : IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)47 Test (org.junit.jupiter.api.Test)29 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)19 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)17 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)16 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)12 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)11 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)11 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)10 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)8 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)8 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)6 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)6 IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)5 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)5 LinkedList (java.util.LinkedList)5 Optional (java.util.Optional)5 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)4 ProjectIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ProjectIssueSearchResult)4 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)4