use of com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel in project hub-alert by blackducksoftware.
the class AzureBoardsIssueTransitioner method findAndPerformTransition.
@Override
protected void findAndPerformTransition(ExistingIssueDetails<Integer> existingIssueDetails, String transitionName) throws AlertException {
WorkItemElementOperationModel replaceSystemStateField = WorkItemElementOperationModel.fieldElement(WorkItemElementOperation.REPLACE, WorkItemResponseFields.System_State, transitionName);
WorkItemRequest request = new WorkItemRequest(List.of(replaceSystemStateField));
Integer issueId = existingIssueDetails.getIssueId();
try {
workItemService.updateWorkItem(organizationName, distributionDetails.getProjectNameOrId(), issueId, request);
} catch (HttpServiceException e) {
List<String> availableStates = retrieveAvailableStates(existingIssueDetails.getIssueId()).stream().map(WorkItemTypeStateResponseModel::getName).collect(Collectors.toList());
throw new IssueMissingTransitionException(existingIssueDetails.getIssueKey(), transitionName, availableStates);
}
}
use of com.synopsys.integration.azure.boards.common.service.workitem.request.WorkItemElementOperationModel in project hub-alert by blackducksoftware.
the class AzureBoardsAlertIssuePropertiesManagerTest method verifyValidPolicyIssuesAreCreated.
@Test
public void verifyValidPolicyIssuesAreCreated() {
AzureBoardsAlertIssuePropertiesManager azureBoardsAlertIssuePropertiesManager = new AzureBoardsAlertIssuePropertiesManager();
LinkableItem providerConfig = new LinkableItem("providerConfigLabel", "providerConfigValue");
ProviderDetails providerDetails = new ProviderDetails(1L, providerConfig);
LinkableItem project = new LinkableItem("projectLabel", "projectValue");
LinkableItem projectVersion = new LinkableItem("projectVersionLabel", "projectVersionValue");
LinkableItem component = new LinkableItem("componentLabel", "componentValue");
LinkableItem componentVersion = new LinkableItem("componentVersionLabel", "componentVersionValue");
IssueBomComponentDetails issueBomComponentDetails = IssueBomComponentDetails.fromSearchResults(component, componentVersion);
IssuePolicyDetails issuePolicyDetails = new IssuePolicyDetails("policy", ItemOperation.ADD, ComponentConcernSeverity.CRITICAL);
ProjectIssueModel policy = ProjectIssueModel.policy(providerDetails, project, projectVersion, issueBomComponentDetails, issuePolicyDetails);
List<WorkItemElementOperationModel> workItemRequestCustomFieldOperations = azureBoardsAlertIssuePropertiesManager.createWorkItemRequestCustomFieldOperations(policy);
LinkableItem provider = providerDetails.getProvider();
String providerKey = AzureBoardsSearchPropertiesUtils.createProviderKey(provider.getLabel(), provider.getUrl().orElse(null));
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_PROVIDER_KEY_FIELD_REFERENCE_NAME, providerKey);
String additionalInfo = AzureBoardsAlertIssuePropertiesManager.POLICY_ADDITIONAL_KEY_COMPATIBILITY_LABEL + issuePolicyDetails.getName();
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_ADDITIONAL_INFO_KEY_FIELD_REFERENCE_NAME, additionalInfo);
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_CATEGORY_KEY_FIELD_REFERENCE_NAME, AzureBoardsAlertIssuePropertiesManager.CATEGORY_TYPE_POLICY_COMPATIBILITY_LABEL);
String subTopicKey = AzureBoardsSearchPropertiesUtils.createNullableLinkableItemKey(policy.getProjectVersion().orElse(null));
assertValidContents(workItemRequestCustomFieldOperations, AzureCustomFieldManager.ALERT_SUB_TOPIC_KEY_FIELD_REFERENCE_NAME, subTopicKey);
}
Aggregations