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