use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.
the class AzureBoardsExistingIssueDetailsCreator method createIssueDetails.
public ExistingIssueDetails<Integer> createIssueDetails(WorkItemResponseModel workItem, WorkItemFieldsWrapper workItemFields, ProjectIssueModel projectIssueModel) {
Integer workItemId = workItem.getId();
String workItemTitle = workItemFields.getField(WorkItemResponseFields.System_Title).orElse("Unknown Title");
String workItemUILink = AzureBoardsUILinkUtils.extractUILink(organizationName, workItem);
IssueCategory issueCategory = issueCategoryRetriever.retrieveIssueCategoryFromProjectIssueModel(projectIssueModel);
String workItemState = workItemFields.getField(WorkItemResponseFields.System_State).orElse("Unknown");
IssueStatus issueStatus = issueStatusResolver.resolveIssueStatus(workItemState);
return new ExistingIssueDetails<>(workItemId, Objects.toString(workItemId), workItemTitle, workItemUILink, issueStatus, issueCategory);
}
use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory in project hub-alert by blackducksoftware.
the class JiraIssueCreator method createIssueAndExtractDetails.
@Override
protected final ExistingIssueDetails<String> createIssueAndExtractDetails(IssueCreationModel alertIssueCreationModel) throws AlertException {
MessageReplacementValues replacementValues = alertIssueCreationModel.getSource().map(this::createCustomFieldReplacementValues).orElse(new MessageReplacementValues.Builder(alertIssueCreationModel.getProvider().getLabel(), MessageReplacementValues.DEFAULT_NOTIFICATION_REPLACEMENT_VALUE).build());
T creationRequest = createIssueCreationRequest(alertIssueCreationModel, replacementValues);
try {
IssueCreationResponseModel issueCreationResponseModel = createIssue(creationRequest);
IssueResponseModel createdIssue = fetchIssue(issueCreationResponseModel.getKey());
IssueFieldsComponent createdIssueFields = createdIssue.getFields();
String issueUILink = JiraCallbackUtils.createUILink(createdIssue);
IssueCategory issueCategory = alertIssueCreationModel.getSource().map(issueCategoryRetriever::retrieveIssueCategoryFromProjectIssueModel).orElse(IssueCategory.BOM);
return new ExistingIssueDetails<>(createdIssue.getId(), createdIssue.getKey(), createdIssueFields.getSummary(), issueUILink, IssueStatus.RESOLVABLE, issueCategory);
} catch (IntegrationRestException restException) {
throw jiraErrorMessageUtility.improveRestException(restException, issueCreatorDescriptorKey, extractReporter(creationRequest));
} catch (JiraPreconditionNotMetException jiraException) {
String message = StringUtils.join(FAILED_TO_CREATE_ISSUE_MESSAGE, jiraException.getMessage(), " ");
throw new AlertException(message, jiraException);
} catch (IntegrationException intException) {
throw new AlertException(FAILED_TO_CREATE_ISSUE_MESSAGE, intException);
}
}
use of com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory 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);
}
Aggregations