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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations