Search in sources :

Example 1 with IssueCreationModel

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

the class JiraServerSummaryFieldLengthTestIT method summaryLength254SucceedsTest.

@Test
public void summaryLength254SucceedsTest() {
    IssueCreationModel issueCreationModel = createIssueCreationModel(254);
    IssueTrackerModelHolder<String> messages = new IssueTrackerModelHolder<>(List.of(issueCreationModel), List.of(), List.of());
    try {
        jiraServerMessageSender.sendMessages(messages);
    } catch (AlertException e) {
        fail("Failed to send a message with a 254 character summary", e);
    }
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test)

Example 2 with IssueCreationModel

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

the class IssueTrackerModelExtractor method extractSimpleMessageIssueModels.

public final IssueTrackerModelHolder<T> extractSimpleMessageIssueModels(List<SimpleMessage> simpleMessages, String jobName) {
    List<IssueCreationModel> simpleMessageIssueCreationModels = new ArrayList<>(simpleMessages.size());
    for (SimpleMessage simpleMessage : simpleMessages) {
        IssueCreationModel simpleMessageIssueCreationModel = issueTrackerSimpleMessageConverter.convertToIssueCreationModel(simpleMessage, jobName);
        simpleMessageIssueCreationModels.add(simpleMessageIssueCreationModel);
    }
    return new IssueTrackerModelHolder<>(simpleMessageIssueCreationModels, 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) SimpleMessage(com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage) ArrayList(java.util.ArrayList)

Example 3 with IssueCreationModel

use of com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel 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)

Example 4 with IssueCreationModel

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

the class IssueTrackerIssueCreatorTest method createIssueTrackerIssueWithSourceTest.

@Test
public void createIssueTrackerIssueWithSourceTest() throws AlertException {
    TestIssueCreator issueCreator = new TestIssueCreator(commenter, callbackInfoCreator);
    ProjectIssueModel projectIssueModel = Mockito.mock(ProjectIssueModel.class);
    IssueCreationModel issueCreationModel = IssueCreationModel.project("Test title", null, List.of("example comment"), projectIssueModel);
    IssueTrackerIssueResponseModel<String> responseModel = issueCreator.createIssueTrackerIssue(issueCreationModel);
    assertEquals(issueCreationModel.getTitle(), responseModel.getIssueTitle());
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 5 with IssueCreationModel

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

the class IssueTrackerIssueCreatorTest method createIssueTrackerIssueTest.

@Test
public void createIssueTrackerIssueTest() throws AlertException {
    TestIssueCreator issueCreator = new TestIssueCreator(commenter, callbackInfoCreator);
    IssueCreationModel issueCreationModel = IssueCreationModel.simple("Test title", null, List.of("comment 1", "comment 2"), null);
    IssueTrackerIssueResponseModel<String> responseModel = issueCreator.createIssueTrackerIssue(issueCreationModel);
    assertEquals(issueCreationModel.getTitle(), responseModel.getIssueTitle());
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) Test(org.junit.jupiter.api.Test)

Aggregations

IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)21 Test (org.junit.jupiter.api.Test)15 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)8 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)8 MockIssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.mock.MockIssueTrackerMessageFormatter)6 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)5 LinkableItem (com.synopsys.integration.alert.common.message.model.LinkableItem)4 IssuePolicyDetails (com.synopsys.integration.alert.api.channel.issue.model.IssuePolicyDetails)3 IssueVulnerabilityDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityDetails)3 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)3 IssueBomComponentDetails (com.synopsys.integration.alert.api.channel.issue.model.IssueBomComponentDetails)2 IssueVulnerabilityModel (com.synopsys.integration.alert.api.channel.issue.model.IssueVulnerabilityModel)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 SimpleMessage (com.synopsys.integration.alert.processor.api.extract.model.SimpleMessage)2 ComponentVulnerabilities (com.synopsys.integration.alert.processor.api.extract.model.project.ComponentVulnerabilities)2 IssueRequestModelFieldsBuilder (com.synopsys.integration.jira.common.cloud.builder.IssueRequestModelFieldsBuilder)2 IssueCreationRequestModel (com.synopsys.integration.jira.common.cloud.model.IssueCreationRequestModel)2 BomComponentDetailConverter (com.synopsys.integration.alert.api.channel.convert.BomComponentDetailConverter)1 LinkableItemConverter (com.synopsys.integration.alert.api.channel.convert.LinkableItemConverter)1