Search in sources :

Example 6 with IssueComponentUnknownVersionDetails

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

the class IssueComponentUnknownDetailsConverterTest method createComponentUnknownDetailsAddTest.

@Test
public void createComponentUnknownDetailsAddTest() {
    IssueComponentUnknownVersionDetails details = createDetails(ItemOperation.ADD);
    List<String> sectionPieces = callCreateSectionPieces(details);
    int headerSize = 3;
    int severityCounts = (2 * details.getEstimatedRiskModelList().size());
    assertEquals(headerSize + severityCounts, sectionPieces.size());
}
Also used : IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) Test(org.junit.jupiter.api.Test)

Example 7 with IssueComponentUnknownVersionDetails

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

the class IssueTrackerSearcher method findIssueByProjectIssueModel.

private ActionableIssueSearchResult<T> findIssueByProjectIssueModel(ProjectIssueModel projectIssueModel) throws AlertException {
    ExistingIssueDetails<T> existingIssue = null;
    ItemOperation searchResultOperation = ItemOperation.UPDATE;
    List<ExistingIssueDetails<T>> existingIssues = exactIssueFinder.findExistingIssuesByProjectIssueModel(projectIssueModel);
    int foundIssuesCount = existingIssues.size();
    if (foundIssuesCount == 1) {
        existingIssue = existingIssues.get(0);
        Optional<ItemOperation> policyOperation = projectIssueModel.getPolicyDetails().map(IssuePolicyDetails::getOperation);
        Optional<IssueVulnerabilityDetails> optionalVulnerabilityDetails = projectIssueModel.getVulnerabilityDetails();
        Optional<ItemOperation> componentUnknownOperation = projectIssueModel.getComponentUnknownVersionDetails().map(IssueComponentUnknownVersionDetails::getItemOperation);
        if (policyOperation.isPresent()) {
            searchResultOperation = policyOperation.get();
        } else if (optionalVulnerabilityDetails.isPresent()) {
            IssueVulnerabilityDetails issueVulnerabilityDetails = optionalVulnerabilityDetails.get();
            searchResultOperation = findVulnerabilitySearchResultOperation(existingIssue, issueVulnerabilityDetails);
        } else if (componentUnknownOperation.isPresent()) {
            searchResultOperation = componentUnknownOperation.get();
        }
    } else if (foundIssuesCount > 1) {
        Set<String> issueKeys = existingIssues.stream().map(ExistingIssueDetails::getIssueKey).collect(Collectors.toSet());
        String issueKeyString = StringUtils.join(issueKeys, ", ");
        throw new AlertException("Expected to find a unique issue, but more than one was found. " + issueKeyString);
    } else {
        searchResultOperation = ItemOperation.ADD;
    }
    return new ActionableIssueSearchResult<>(existingIssue, projectIssueModel, searchResultOperation);
}
Also used : IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) Set(java.util.Set) IssueVulnerabilityDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) ItemOperation(com.synopsys.integration.alert.common.enumeration.ItemOperation) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Aggregations

IssueComponentUnknownVersionDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails)7 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)4 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)3 ItemOperation (com.synopsys.integration.alert.common.enumeration.ItemOperation)3 Test (org.junit.jupiter.api.Test)3 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)2 IssueEstimatedRiskModel (com.synopsys.integration.alert.api.channel.issue.model.IssueEstimatedRiskModel)2 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)2 ComponentConcern (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentConcern)2 LinkedList (java.util.LinkedList)2 Gson (com.google.gson.Gson)1 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)1 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 AzureBoardsIssueTrackerQueryManager (com.synopsys.integration.alert.channel.azure.boards.distribution.AzureBoardsIssueTrackerQueryManager)1 BomComponentDetails (com.synopsys.integration.alert.processor.api.extract.model.project.BomComponentDetails)1 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)1 WorkItemResponseModel (com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemResponseModel)1 Set (java.util.Set)1