use of com.synopsys.integration.jira.common.model.components.ProjectComponent in project hub-alert by blackducksoftware.
the class JiraServerIssueCreator method retrieveProjectComponent.
private ProjectComponent retrieveProjectComponent() throws AlertException {
String jiraProjectName = distributionDetails.getProjectNameOrKey();
List<ProjectComponent> foundProjectComponents;
try {
foundProjectComponents = projectService.getProjectsByName(jiraProjectName);
} catch (IntegrationException e) {
throw new AlertException("Failed to retrieve projects from Jira", e);
}
return foundProjectComponents.stream().findAny().orElseThrow(() -> new AlertException(String.format("Unable to find project matching '%s'", jiraProjectName)));
}
use of com.synopsys.integration.jira.common.model.components.ProjectComponent in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreator method createIssueCreationRequest.
@Override
protected IssueCreationRequestModel createIssueCreationRequest(IssueCreationModel alertIssueCreationModel, MessageReplacementValues replacementValues) throws AlertException {
ProjectComponent jiraProject = retrieveProjectComponent();
String issueSummary = distributionDetails.getIssueSummary();
String title = alertIssueCreationModel.getTitle();
if (StringUtils.isNotEmpty(issueSummary)) {
MessageValueReplacementResolver messageValueReplacementResolver = new MessageValueReplacementResolver(replacementValues);
title = messageValueReplacementResolver.createReplacedFieldValue(issueSummary);
}
IssueRequestModelFieldsMapBuilder fieldsBuilder = jiraIssueCreationRequestCreator.createIssueRequestModel(title, alertIssueCreationModel.getDescription(), jiraProject.getId(), distributionDetails.getIssueType(), replacementValues, distributionDetails.getCustomFields());
return new IssueCreationRequestModel(distributionDetails.getIssueCreatorEmail(), distributionDetails.getIssueType(), distributionDetails.getProjectNameOrKey(), fieldsBuilder, List.of());
}
use of com.synopsys.integration.jira.common.model.components.ProjectComponent in project hub-alert by blackducksoftware.
the class JiraCloudIssueCreatorTest method createTestJiraCloudIssueCreator.
private TestJiraCloudIssueCreator createTestJiraCloudIssueCreator(String projectNameOrKey, JiraCloudJobDetailsModel jiraCloudJobDetailsModel) throws IntegrationException {
ProjectService projectService = Mockito.mock(ProjectService.class);
Mockito.when(projectService.getProjectsByName(Mockito.anyString())).thenReturn(new PageOfProjectsResponseModel(List.of(new ProjectComponent("self", "id", "key", projectNameOrKey, null, null, null, null))));
JiraCustomFieldResolver jiraCustomFieldResolver = new JiraCustomFieldResolver(() -> List.of());
JiraIssueCreationRequestCreator jiraIssueCreationRequestCreator = new JiraIssueCreationRequestCreator(jiraCustomFieldResolver);
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
return new TestJiraCloudIssueCreator(jiraCloudJobDetailsModel, projectService, jiraIssueCreationRequestCreator, issueCategoryRetriever);
}
use of com.synopsys.integration.jira.common.model.components.ProjectComponent in project hub-alert by blackducksoftware.
the class JiraServerIssueCreator method createIssueCreationRequest.
@Override
protected IssueCreationRequestModel createIssueCreationRequest(IssueCreationModel alertIssueCreationModel, MessageReplacementValues replacementValues) throws AlertException {
ProjectComponent jiraProject = retrieveProjectComponent();
String issueSummary = distributionDetails.getIssueSummary();
String title = alertIssueCreationModel.getTitle();
if (StringUtils.isNotEmpty(issueSummary)) {
MessageValueReplacementResolver messageValueReplacementResolver = new MessageValueReplacementResolver(replacementValues);
title = messageValueReplacementResolver.createReplacedFieldValue(issueSummary);
}
IssueRequestModelFieldsMapBuilder fieldsBuilder = jiraIssueCreationRequestCreator.createIssueRequestModel(title, alertIssueCreationModel.getDescription(), jiraProject.getId(), distributionDetails.getIssueType(), replacementValues, distributionDetails.getCustomFields());
return new IssueCreationRequestModel(distributionDetails.getIssueCreatorUsername(), distributionDetails.getIssueType(), distributionDetails.getProjectNameOrKey(), fieldsBuilder);
}
Aggregations