Search in sources :

Example 1 with IssueCategory

use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.

the class IssueCategoryRetrieverTest method retrieveIssueCategoryFromProjectIssueModel_PolicyTest.

@Test
public void retrieveIssueCategoryFromProjectIssueModel_PolicyTest() {
    IssuePolicyDetails issuePolicyDetails = Mockito.mock(IssuePolicyDetails.class);
    ProjectIssueModel projectIssueModel = Mockito.mock(ProjectIssueModel.class);
    Mockito.when(projectIssueModel.getPolicyDetails()).thenReturn(Optional.of(issuePolicyDetails));
    Mockito.when(projectIssueModel.getVulnerabilityDetails()).thenReturn(Optional.empty());
    IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
    IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromProjectIssueModel(projectIssueModel);
    assertEquals(IssueCategory.POLICY, issueCategory);
}
Also used : IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) 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 2 with IssueCategory

use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.

the class IssueCategoryRetrieverTest method assertIssueCategoryMatchesConcernType.

private static void assertIssueCategoryMatchesConcernType(ComponentConcernType componentConcernType) {
    IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
    IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromComponentConcernType(componentConcernType);
    assertEquals(componentConcernType.name(), issueCategory.name());
}
Also used : IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory)

Example 3 with IssueCategory

use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.

the class JiraIssueSearchResultCreator method createIssueResult.

public ProjectIssueSearchResult<String> createIssueResult(JiraSearcherResponseModel issue, ProjectIssueModel projectIssueModel) {
    IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromProjectIssueModel(projectIssueModel);
    ExistingIssueDetails<String> issueDetails = createExistingIssueDetails(issue, issueCategory);
    return new ProjectIssueSearchResult<>(issueDetails, projectIssueModel);
}
Also used : IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) ProjectIssueSearchResult(com.synopsys.integration.alert.api.channel.issue.search.ProjectIssueSearchResult)

Example 4 with IssueCategory

use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.

the class JiraExactIssueFinder method findExistingIssuesByProjectIssueModel.

@Override
public List<ExistingIssueDetails<String>> findExistingIssuesByProjectIssueModel(ProjectIssueModel projectIssueModel) throws AlertException {
    LinkableItem provider = projectIssueModel.getProvider();
    LinkableItem project = projectIssueModel.getProject();
    IssueBomComponentDetails bomComponent = projectIssueModel.getBomComponentDetails();
    ComponentConcernType concernType = ComponentConcernType.VULNERABILITY;
    String policyName = null;
    Optional<IssuePolicyDetails> policyDetails = projectIssueModel.getPolicyDetails();
    Optional<String> optionalPolicyName = policyDetails.map(IssuePolicyDetails::getName);
    if (optionalPolicyName.isPresent()) {
        concernType = ComponentConcernType.POLICY;
        policyName = optionalPolicyName.get();
    }
    if (projectIssueModel.getComponentUnknownVersionDetails().isPresent()) {
        concernType = ComponentConcernType.UNKNOWN_VERSION;
    }
    String jqlString = JqlStringCreator.createBlackDuckComponentConcernIssuesSearchString(jiraProjectKey, provider, project, projectIssueModel.getProjectVersion().orElse(null), bomComponent.getComponent(), bomComponent.getComponentVersion().orElse(null), concernType, policyName);
    logger.debug("Searching for Jira issues with this Query: {}", jqlString);
    IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromComponentConcernType(concernType);
    return jqlQueryExecutor.executeQuery(jqlString).stream().map(jiraSearcherResponseModel -> searchResultCreator.createExistingIssueDetails(jiraSearcherResponseModel, issueCategory)).collect(Collectors.toList());
}
Also used : Logger(org.slf4j.Logger) ExactIssueFinder(com.synopsys.integration.alert.api.channel.issue.search.ExactIssueFinder) ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) LoggerFactory(org.slf4j.LoggerFactory) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) Collectors(java.util.stream.Collectors) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) List(java.util.List) Optional(java.util.Optional) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) IssueCategoryRetriever(com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) ComponentConcernType(com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)

Example 5 with IssueCategory

use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.

the class AzureBoardsIssueCreator method extractIssueDetails.

private ExistingIssueDetails<Integer> extractIssueDetails(WorkItemResponseModel workItem, IssueCreationModel alertIssueCreationModel) {
    WorkItemFieldsWrapper workItemFields = workItem.createFieldsWrapper(gson);
    String workItemKey = Objects.toString(workItem.getId());
    String workItemTitle = workItemFields.getField(WorkItemResponseFields.System_Title).orElse("Unknown Title");
    String workItemUILink = AzureBoardsUILinkUtils.extractUILink(organizationName, workItem);
    IssueCategory issueCategory = alertIssueCreationModel.getSource().map(issueCategoryRetriever::retrieveIssueCategoryFromProjectIssueModel).orElse(IssueCategory.BOM);
    return new ExistingIssueDetails<>(workItem.getId(), workItemKey, workItemTitle, workItemUILink, IssueStatus.RESOLVABLE, issueCategory);
}
Also used : WorkItemFieldsWrapper(com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper) IssueCategory(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)

Aggregations

IssueCategory (com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory)8 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)4 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)3 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)2 Test (org.junit.jupiter.api.Test)2 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)1 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)1 ExactIssueFinder (com.synopsys.integration.alert.api.channel.issue.search.ExactIssueFinder)1 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)1 ProjectIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ProjectIssueSearchResult)1 IssueStatus (com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueStatus)1 MessageReplacementValues (com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues)1 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)1 ComponentConcernType (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcernType)1 WorkItemFieldsWrapper (com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemFieldsWrapper)1 IntegrationException (com.synopsys.integration.exception.IntegrationException)1 JiraPreconditionNotMetException (com.synopsys.integration.jira.common.exception.JiraPreconditionNotMetException)1 IssueFieldsComponent (com.synopsys.integration.jira.common.model.components.IssueFieldsComponent)1 IssueCreationResponseModel (com.synopsys.integration.jira.common.model.response.IssueCreationResponseModel)1