Search in sources :

Example 1 with IssueTrackerModelHolder

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

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

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

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

the class IssueTrackerTransitionTestAction method transitionTestIssueOrReturnFailureResult.

public Optional<MessageResult> transitionTestIssueOrReturnFailureResult(IssueOperation operation, ExistingIssueDetails<T> existingIssueDetails, ProjectIssueModel testProjectIssueModel) {
    String postTransitionComment = String.format("Successfully tested the %s operation", operation.name());
    IssueTransitionModel<T> resolveRequest = new IssueTransitionModel<>(existingIssueDetails, operation, List.of(postTransitionComment), testProjectIssueModel);
    IssueTrackerModelHolder<T> resolveRequestModelHolder = new IssueTrackerModelHolder<>(List.of(), List.of(resolveRequest), List.of());
    List<IssueTrackerIssueResponseModel<T>> transitionedIssues;
    try {
        transitionedIssues = messageSender.sendMessages(resolveRequestModelHolder);
    } catch (IssueMissingTransitionException e) {
        MessageResult issueMissingResult = handleIssueMessingTransitionException(e);
        return Optional.of(issueMissingResult);
    } catch (AlertException e) {
        MessageResult alertExceptionResult = handleAlertException(e, operation);
        return Optional.of(alertExceptionResult);
    }
    int transitionedIssuesSize = transitionedIssues.size();
    if (transitionedIssuesSize != 1) {
        String errorMessage = String.format("Expected [1] issue to be transitioned, but there were actually [%d]", transitionedIssuesSize);
        return Optional.of(new MessageResult(errorMessage, fieldStatusCreator.createWithoutField(errorMessage)));
    }
    return Optional.empty();
}
Also used : IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) IssueMissingTransitionException(com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueMissingTransitionException) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException)

Example 5 with IssueTrackerModelHolder

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

the class JiraCloudSummaryFieldLengthTestIT method summaryLength254SucceedsTest.

@Test
public void summaryLength254SucceedsTest() {
    IssueCreationModel issueCreationModel = createIssueCreationModel(254);
    IssueTrackerModelHolder<String> messages = new IssueTrackerModelHolder<>(List.of(issueCreationModel), List.of(), List.of());
    try {
        jiraCloudMessageSender.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)

Aggregations

IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)12 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)8 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)8 Test (org.junit.jupiter.api.Test)7 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)5 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)4 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)3 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)2 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)2 IssueTrackerMessageSender (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)2 IssueTrackerMessageSenderFactory (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSenderFactory)2 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)2 FrequencyType (com.synopsys.integration.alert.common.enumeration.FrequencyType)2 ProcessingType (com.synopsys.integration.alert.common.enumeration.ProcessingType)2 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)2 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)2 IssueTrackerChannelKey (com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey)2 OffsetDateTime (java.time.OffsetDateTime)2 List (java.util.List)2 UUID (java.util.UUID)2