Search in sources :

Example 1 with IssueCreationRequestModel

use of com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel 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());
}
Also used : ProjectComponent(com.synopsys.integration.jira.common.model.components.ProjectComponent) IssueCreationRequestModel(com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel) MessageValueReplacementResolver(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageValueReplacementResolver) IssueRequestModelFieldsMapBuilder(com.synopsys.integration.jira.common.model.request.builder.IssueRequestModelFieldsMapBuilder)

Example 2 with IssueCreationRequestModel

use of com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method verifySummaryReplacingValues.

@Test
public void verifySummaryReplacingValues() throws IntegrationException {
    String projectNameOrKey = "FakeProject";
    JiraCloudJobDetailsModel jiraCloudJobDetailsModel = new JiraCloudJobDetailsModel(UUID.randomUUID(), false, "my@email.com", projectNameOrKey, "Task", null, null, List.of(), "testSummary {{providerName}}");
    TestJiraCloudIssueCreator jiraCloudIssueCreator = createTestJiraCloudIssueCreator(projectNameOrKey, jiraCloudJobDetailsModel);
    IssueCreationModel issueCreationModel = createIssueCreationModel();
    String testProviderName = "providerName";
    MessageReplacementValues messageReplacementValues = new MessageReplacementValues.Builder(testProviderName, "projectName").projectVersionName("projectVersionName").componentName("componentName").componentVersionName("componentVersionName").severity("severity").policyCategory("UNCATEGORIZED").build();
    IssueCreationRequestModel issueCreationRequest = jiraCloudIssueCreator.createIssueCreationRequest(issueCreationModel, messageReplacementValues);
    String summaryText = getSummary(issueCreationRequest);
    assertEquals("testSummary " + testProviderName, summaryText);
}
Also used : MessageReplacementValues(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueCreationRequestModel(com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel) IssueRequestModelFieldsBuilder(com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder) JiraCloudJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel) Test(org.junit.jupiter.api.Test)

Example 3 with IssueCreationRequestModel

use of com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel in project hub-alert by blackducksoftware.

the class JiraCloudIssueCreatorTest method verifyIssueSummaryReplacement.

@Test
public void verifyIssueSummaryReplacement() throws IntegrationException {
    String testSummary = "testSummary";
    String projectNameOrKey = "FakeProject";
    JiraCloudJobDetailsModel jiraCloudJobDetailsModel = new JiraCloudJobDetailsModel(UUID.randomUUID(), false, "my@email.com", projectNameOrKey, "Task", null, null, List.of(), testSummary);
    TestJiraCloudIssueCreator jiraCloudIssueCreator = createTestJiraCloudIssueCreator(projectNameOrKey, jiraCloudJobDetailsModel);
    IssueCreationModel issueCreationModel = createIssueCreationModel();
    MessageReplacementValues messageReplacementValues = new MessageReplacementValues.Builder("providerName", "projectName").projectVersionName("projectVersionName").componentName("componentName").componentVersionName("componentVersionName").severity("severity").policyCategory("UNCATEGORIZED").build();
    IssueCreationRequestModel issueCreationRequest = jiraCloudIssueCreator.createIssueCreationRequest(issueCreationModel, messageReplacementValues);
    String summaryText = getSummary(issueCreationRequest);
    assertEquals(testSummary, summaryText);
}
Also used : MessageReplacementValues(com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueCreationRequestModel(com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel) IssueRequestModelFieldsBuilder(com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder) JiraCloudJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel) Test(org.junit.jupiter.api.Test)

Aggregations

IssueCreationRequestModel (com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel)3 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)2 MessageReplacementValues (com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageReplacementValues)2 JiraCloudJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.JiraCloudJobDetailsModel)2 IssueRequestModelFieldsBuilder (com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder)2 Test (org.junit.jupiter.api.Test)2 MessageValueReplacementResolver (com.synopsys.integration.alert.api.channel.jira.distribution.custom.MessageValueReplacementResolver)1 ProjectComponent (com.synopsys.integration.jira.common.model.components.ProjectComponent)1 IssueRequestModelFieldsMapBuilder (com.synopsys.integration.jira.common.model.request.builder.IssueRequestModelFieldsMapBuilder)1