Search in sources :

Example 1 with IssueTrackerCallbackInfo

use of com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo in project hub-alert by blackducksoftware.

the class IssueTrackerCallbackInfoCreatorTest method createCallbackInfoWithProjectVersionUrlTest.

@Test
public void createCallbackInfoWithProjectVersionUrlTest() {
    LinkableItem projectVersionWithUrl = new LinkableItem("Project Version", "A Project Version", "https://project-version-url");
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(PROVIDER_DETAILS, TEST_ITEM, projectVersionWithUrl, ISSUE_BOM_COMPONENT_DETAILS);
    IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
    Optional<IssueTrackerCallbackInfo> optionalCallbackInfo = callbackInfoCreator.createCallbackInfo(projectIssueModel);
    assertTrue(optionalCallbackInfo.isPresent(), "Expected a callback info to be present because a project-version url was present");
    IssueTrackerCallbackInfo callbackInfo = optionalCallbackInfo.get();
    assertEquals(PROVIDER_DETAILS.getProviderConfigId(), callbackInfo.getProviderConfigId());
    assertEquals(BOM_COMPONENT_DETAILS.getBlackDuckIssuesUrl(), callbackInfo.getCallbackUrl());
    assertEquals(projectVersionWithUrl.getUrl().orElse(null), callbackInfo.getBlackDuckProjectVersionUrl());
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 2 with IssueTrackerCallbackInfo

use of com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo in project hub-alert by blackducksoftware.

the class IssueTrackerCallbackInfoCreator method createCallbackInfo.

private IssueTrackerCallbackInfo createCallbackInfo(ProjectIssueModel projectIssueModel, String projectVersionUrl) {
    ProviderDetails providerDetails = projectIssueModel.getProviderDetails();
    IssueBomComponentDetails bomComponentDetails = projectIssueModel.getBomComponentDetails();
    return new IssueTrackerCallbackInfo(providerDetails.getProviderConfigId(), bomComponentDetails.getBlackDuckIssuesUrl(), projectVersionUrl);
}
Also used : IssueBomComponentDetails(com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails) ProviderDetails(com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo)

Example 3 with IssueTrackerCallbackInfo

use of com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo in project hub-alert by blackducksoftware.

the class IssueTrackerIssueCreator method createIssueTrackerIssue.

/**
 * This method does three things:<br />
 * 1. Creates a new issue in an issue-tracker.<br />
 * 2. If applicable, Assigns "Alert Search Properties" so that Alert can find the issue in the future.<br />
 * 3. Adds comments to the issue with any additional contextual information that the issue requires.<br />
 * @param alertIssueCreationModel - A model containing common issue-tracker fields, post-create comments, and details about the source of the model.
 * @return {@link IssueTrackerIssueResponseModel}
 * @throws AlertException Thrown if there is a problem connecting to the issue-tracker or if the issue-tracker server responds with an error.
 */
public final IssueTrackerIssueResponseModel<T> createIssueTrackerIssue(IssueCreationModel alertIssueCreationModel) throws AlertException {
    ExistingIssueDetails<T> createdIssueDetails = createIssueAndExtractDetails(alertIssueCreationModel);
    logger.debug("Created new {} issue: {}", channelKey.getDisplayName(), createdIssueDetails);
    IssueTrackerCallbackInfo callbackInfo = null;
    Optional<ProjectIssueModel> optionalSource = alertIssueCreationModel.getSource();
    if (optionalSource.isPresent()) {
        ProjectIssueModel alertIssueSource = optionalSource.get();
        assignAlertSearchProperties(createdIssueDetails, alertIssueSource);
        callbackInfo = callbackInfoCreator.createCallbackInfo(alertIssueSource).orElse(null);
    }
    addPostCreateComments(createdIssueDetails, alertIssueCreationModel, optionalSource.orElse(null));
    return new IssueTrackerIssueResponseModel<>(createdIssueDetails.getIssueId(), createdIssueDetails.getIssueKey(), createdIssueDetails.getIssueUILink(), createdIssueDetails.getIssueSummary(), IssueOperation.OPEN, callbackInfo);
}
Also used : IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)

Example 4 with IssueTrackerCallbackInfo

use of com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo in project hub-alert by blackducksoftware.

the class BlackDuckIssueTrackerCallbackEventHandler method handle.

@Override
public void handle(IssueTrackerCallbackEvent event) {
    String eventId = event.getEventId();
    logger.debug("Handling issue-tracker callback event with id '{}'", eventId);
    IssueTrackerCallbackInfo callbackInfo = event.getCallbackInfo();
    Optional<BlackDuckServicesFactory> optionalBlackDuckServicesFactory = createBlackDuckProperties(callbackInfo.getProviderConfigId()).flatMap(this::createBlackDuckServicesFactory);
    if (optionalBlackDuckServicesFactory.isPresent()) {
        BlackDuckServicesFactory blackDuckServicesFactory = optionalBlackDuckServicesFactory.get();
        BlackDuckApiClient blackDuckApiClient = blackDuckServicesFactory.getBlackDuckApiClient();
        IssueService blackDuckIssueService = blackDuckServicesFactory.createIssueService();
        BlackDuckProviderIssueHandler blackDuckProviderIssueHandler = new BlackDuckProviderIssueHandler(gson, blackDuckApiClient, blackDuckIssueService);
        BlackDuckProviderIssueModel issueModel = createBlackDuckIssueModel(event);
        createOrUpdateBlackDuckIssue(blackDuckProviderIssueHandler, issueModel, callbackInfo);
    }
    logger.debug("Finished handling issue-tracker callback event with id '{}'", eventId);
}
Also used : IssueService(com.synopsys.integration.blackduck.service.dataservice.IssueService) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo) BlackDuckServicesFactory(com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)

Example 5 with IssueTrackerCallbackInfo

use of com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo in project hub-alert by blackducksoftware.

the class IssueTrackerCallbackInfoCreatorTest method createCallbackInfoNoProjectVersionUrlTest.

@Test
public void createCallbackInfoNoProjectVersionUrlTest() {
    LinkableItem projectVersionNoUrl = new LinkableItem("Project Version", "A Project Version", null);
    ProjectIssueModel projectIssueModel = ProjectIssueModel.bom(PROVIDER_DETAILS, TEST_ITEM, projectVersionNoUrl, ISSUE_BOM_COMPONENT_DETAILS);
    IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
    Optional<IssueTrackerCallbackInfo> callbackInfo = callbackInfoCreator.createCallbackInfo(projectIssueModel);
    assertTrue(callbackInfo.isEmpty(), "Expected no callback info to be present because no project-version url was present");
}
Also used : LinkableItem(com.synopsys.integration.alert.common.message.model.LinkableItem) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Aggregations

IssueTrackerCallbackInfo (com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo)6 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)4 Test (org.junit.jupiter.api.Test)3 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)2 IssueTrackerCallbackInfoCreator (com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator)1 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)1 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)1 ProviderDetails (com.synopsys.integration.alert.processor.api.extract.model.ProviderDetails)1 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)1 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)1 IssueService (com.synopsys.integration.blackduck.service.dataservice.IssueService)1