Search in sources :

Example 1 with ExistingIssueDetails

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

the class JiraIssueSearchResultCreator method createExistingIssueDetails.

public ExistingIssueDetails<String> createExistingIssueDetails(JiraSearcherResponseModel issue, IssueCategory issueCategory) {
    String issueCallbackLink = JiraCallbackUtils.createUILink(issue);
    IssueStatus issueStatus = jiraIssueStatusCreator.createIssueStatus(issue, jiraIssueTransitionRetriever::fetchIssueTransitions);
    return new ExistingIssueDetails<>(issue.getIssueId(), issue.getIssueKey(), issue.getSummaryField(), issueCallbackLink, issueStatus, issueCategory);
}
Also used : ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) IssueStatus(com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueStatus)

Example 2 with ExistingIssueDetails

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

the class AzureBoardsComponentIssueFinderTest method findExistingIssuesByProjectIssueModelForUnknownVersionTest.

@Test
public void findExistingIssuesByProjectIssueModelForUnknownVersionTest() throws AlertException {
    Gson gson = new Gson();
    String organizationName = "orgName";
    AzureBoardsIssueTrackerQueryManager queryManager = Mockito.mock(AzureBoardsIssueTrackerQueryManager.class);
    IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
    AzureBoardsExistingIssueDetailsCreator issueDetailsCreator = new AzureBoardsExistingIssueDetailsCreator(organizationName, issueCategoryRetriever, azureBoardsIssueStatusResolver);
    AzureBoardsWorkItemFinder workItemFinder = new AzureBoardsWorkItemFinder(queryManager, "test proj");
    AzureBoardsComponentIssueFinder componentIssueFinder = new AzureBoardsComponentIssueFinder(gson, workItemFinder, issueDetailsCreator);
    IssueComponentUnknownVersionDetails componentUnknownVersionDetails = new IssueComponentUnknownVersionDetails(ItemOperation.ADD, createRiskModels());
    IssuePolicyDetails testPolicy = new IssuePolicyDetails("Test Policy", ItemOperation.ADD, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.componentUnknownVersion(PROVIDER_DETAILS, PROJECT_ITEM, PROJECT_VERSION_ITEM, ISSUE_BOM_COMPONENT_DETAILS, componentUnknownVersionDetails);
    WorkItemResponseModel workItemResponseModel = createWorkItemResponseModel(workItemReopenState);
    Mockito.when(queryManager.executeQueryAndRetrieveWorkItems(Mockito.any())).thenReturn(List.of(workItemResponseModel));
    List<ExistingIssueDetails<Integer>> existingIssueDetailsList = componentIssueFinder.findExistingIssuesByProjectIssueModel(projectIssueModel);
    assertEquals(1, existingIssueDetailsList.size());
    ExistingIssueDetails<Integer> existingIssueDetails = existingIssueDetailsList.get(0);
    assertEquals(IssueStatus.RESOLVABLE, existingIssueDetails.getIssueStatus());
    assertEquals(IssueCategory.BOM, existingIssueDetails.getIssueCategory());
}
Also used : IssueComponentUnknownVersionDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueComponentUnknownVersionDetails) AzureBoardsIssueTrackerQueryManager(com.synopsys.integration.alert.channel.azure.boards.distribution.AzureBoardsIssueTrackerQueryManager) Gson(com.google.gson.Gson) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) WorkItemResponseModel(com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemResponseModel) IssueCategoryRetriever(com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever) Test(org.junit.jupiter.api.Test)

Example 3 with ExistingIssueDetails

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

the class IssueTrackerIssueTransitionerTest method transitionIssueTest.

@Test
public void transitionIssueTest() throws AlertException {
    IssueOperation testOperation = IssueOperation.RESOLVE;
    ExistingIssueDetails<String> existingIssueDetails = new ExistingIssueDetails<>("id", "key", "title", "https://link", IssueStatus.UNKNOWN, IssueCategory.BOM);
    IssueTransitionModel<String> issueTransitionModel = new IssueTransitionModel<>(existingIssueDetails, testOperation, List.of("comment 1"), null);
    IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
    IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
    IssueTrackerIssueTransitioner<String> transitioner = new TestTransitioner(commenter, issueResponseCreator, "TODO", true, false);
    Optional<IssueTrackerIssueResponseModel<String>> optionalResponseModel = transitioner.transitionIssue(issueTransitionModel);
    assertTrue(optionalResponseModel.isPresent(), "Expected response model to be present");
    IssueTrackerIssueResponseModel<String> responseModel = optionalResponseModel.get();
    assertEquals(existingIssueDetails.getIssueId(), responseModel.getIssueId());
    assertEquals(existingIssueDetails.getIssueKey(), responseModel.getIssueKey());
    assertEquals(existingIssueDetails.getIssueSummary(), responseModel.getIssueTitle());
    assertEquals(existingIssueDetails.getIssueUILink(), responseModel.getIssueLink());
    assertEquals(testOperation, responseModel.getIssueOperation());
}
Also used : IssueTrackerCallbackInfoCreator(com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator) IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) Test(org.junit.jupiter.api.Test)

Example 4 with ExistingIssueDetails

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

the class IssueTrackerModelExtractorTest method extractProjectMessageIssueModelsCommentTest.

@Test
public void extractProjectMessageIssueModelsCommentTest() throws AlertException {
    ProjectMessage projectMessage = Mockito.mock(ProjectMessage.class);
    ExistingIssueDetails<String> existingIssueDetails = new ExistingIssueDetails<>("issue-id", "issue-key", "issue summary", "https://ui-link", IssueStatus.UNKNOWN, IssueCategory.POLICY);
    IssuePolicyDetails policyDetails = new IssuePolicyDetails("A policy", ItemOperation.UPDATE, ComponentConcernSeverity.UNSPECIFIED_UNKNOWN);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.policy(PROVIDER_DETAILS, PROJECT, PROJECT_VERSION, ISSUE_BOM_COMPONENT_DETAILS, policyDetails);
    ActionableIssueSearchResult<String> searchResult = new ActionableIssueSearchResult<>(existingIssueDetails, projectIssueModel, ItemOperation.UPDATE);
    MockIssueTrackerMessageFormatter formatter = MockIssueTrackerMessageFormatter.withIntegerMaxValueLength();
    IssueTrackerSearcher<String> searcher = Mockito.mock(IssueTrackerSearcher.class);
    Mockito.when(searcher.findIssues(Mockito.eq(projectMessage))).thenReturn(List.of(searchResult));
    IssueTrackerModelExtractor<String> extractor = new IssueTrackerModelExtractor<>(formatter, searcher);
    IssueTrackerModelHolder<String> modelHolder = extractor.extractProjectMessageIssueModels(projectMessage, "jobName");
    assertEquals(0, modelHolder.getIssueCreationModels().size());
    assertEquals(0, modelHolder.getIssueTransitionModels().size());
    assertEquals(1, modelHolder.getIssueCommentModels().size());
}
Also used : ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) MockIssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) ActionableIssueSearchResult(com.synopsys.integration.alert.api.channel.issue.search.ActionableIssueSearchResult) IssuePolicyDetails(com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) Test(org.junit.jupiter.api.Test)

Example 5 with ExistingIssueDetails

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

the class IssueTrackerModelExtractor method convertSearchResult.

private IssueTrackerModelHolder<T> convertSearchResult(ActionableIssueSearchResult<T> searchResult, String jobName) {
    Optional<ExistingIssueDetails<T>> existingIssueDetails = searchResult.getExistingIssueDetails();
    ProjectIssueModel projectIssueModel = searchResult.getProjectIssueModel();
    if (existingIssueDetails.isPresent()) {
        return convertExistingIssue(existingIssueDetails.get(), projectIssueModel, searchResult.getRequiredOperation());
    } else {
        IssueCreationModel issueCreationModel = projectIssueModelConverter.toIssueCreationModel(projectIssueModel, jobName);
        return new IssueTrackerModelHolder<>(List.of(issueCreationModel), List.of(), List.of());
    }
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Aggregations

ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)13 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)8 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)6 Test (org.junit.jupiter.api.Test)5 IssueCategory (com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueCategory)4 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)4 Gson (com.google.gson.Gson)3 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)3 WorkItemResponseModel (com.synopsys.integration.azure.boards.common.service.workitem.response.WorkItemResponseModel)3 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)2 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)2 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)2 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)2 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)2 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)2 ActionableIssueSearchResult (com.synopsys.integration.alert.api.channel.issue.search.ActionableIssueSearchResult)2 ExactIssueFinder (com.synopsys.integration.alert.api.channel.issue.search.ExactIssueFinder)2 IssueStatus (com.synopsys.integration.alert.api.channel.issue.search.enumeration.IssueStatus)2 AzureBoardsIssueTrackerQueryManager (com.synopsys.integration.alert.channel.azure.boards.distribution.AzureBoardsIssueTrackerQueryManager)2 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)2