Search in sources :

Example 1 with IssueTrackerResponse

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

the class IssueTrackerProcessor method processMessages.

public final IssueTrackerResponse<T> processMessages(ProviderMessageHolder messages, String jobName) throws AlertException {
    List<IssueTrackerIssueResponseModel<T>> issueResponseModels = new LinkedList<>();
    IssueTrackerModelHolder<T> simpleMessageHolder = modelExtractor.extractSimpleMessageIssueModels(messages.getSimpleMessages(), jobName);
    List<IssueTrackerIssueResponseModel<T>> simpleMessageResponseModels = messageSender.sendMessages(simpleMessageHolder);
    issueResponseModels.addAll(simpleMessageResponseModels);
    for (ProjectMessage projectMessage : messages.getProjectMessages()) {
        IssueTrackerModelHolder<T> projectMessageHolder = modelExtractor.extractProjectMessageIssueModels(projectMessage, jobName);
        List<IssueTrackerIssueResponseModel<T>> projectMessageResponseModels = messageSender.sendMessages(projectMessageHolder);
        issueResponseModels.addAll(projectMessageResponseModels);
    }
    return new IssueTrackerResponse<>("Success", issueResponseModels);
}
Also used : IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) IssueTrackerResponse(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerResponse) LinkedList(java.util.LinkedList)

Example 2 with IssueTrackerResponse

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

the class IssueTrackerChannelTest method distributeMessagesTest.

@Test
public void distributeMessagesTest() throws AlertException {
    IssueTrackerModelExtractor<String> modelExtractor = new IssueTrackerModelExtractor<>(createFormatter(), null);
    IssueTrackerMessageSender<String> messageSender = createMessageSender();
    IssueTrackerProcessor<String> processor = new IssueTrackerProcessor<>(modelExtractor, messageSender);
    IssueTrackerProcessorFactory<DistributionJobDetailsModel, String> processorFactory = x -> processor;
    IssueTrackerResponsePostProcessor postProcessor = new IssueTrackerResponsePostProcessor() {

        @Override
        public <T extends Serializable> void postProcess(IssueTrackerResponse<T> response) {
        }
    };
    IssueTrackerChannel<DistributionJobDetailsModel, String> issueTrackerChannel = new IssueTrackerChannel<>(processorFactory, postProcessor) {
    };
    MessageResult testResult = issueTrackerChannel.distributeMessages(null, ProviderMessageHolder.empty(), null);
    IssueTrackerResponse<?> processorResponse = processor.processMessages(ProviderMessageHolder.empty(), "jobName");
    assertEquals(processorResponse.getStatusMessage(), testResult.getStatusMessage());
}
Also used : IssueTrackerIssueCommenter(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueCommenter) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender) ExistingIssueDetails(com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) IssueTrackerIssueTransitioner(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueTransitioner) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Serializable(java.io.Serializable) Test(org.junit.jupiter.api.Test) Nullable(org.jetbrains.annotations.Nullable) IssueTrackerMessageFormatter(com.synopsys.integration.alert.api.channel.issue.convert.IssueTrackerMessageFormatter) IssueTrackerIssueCreator(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueCreator) Optional(java.util.Optional) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) IssueTrackerResponse(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerResponse) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) Serializable(java.io.Serializable) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) IssueTrackerResponse(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerResponse) Test(org.junit.jupiter.api.Test)

Aggregations

IssueTrackerResponse (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerResponse)2 IssueTrackerMessageFormatter (com.synopsys.integration.alert.api.channel.issue.convert.IssueTrackerMessageFormatter)1 IssueCreationModel (com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel)1 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)1 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)1 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)1 IssueTrackerIssueCommenter (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueCommenter)1 IssueTrackerIssueCreator (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueCreator)1 IssueTrackerIssueTransitioner (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueTransitioner)1 IssueTrackerMessageSender (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)1 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)1 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)1 ProviderMessageHolder (com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder)1 ProjectMessage (com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage)1 Serializable (java.io.Serializable)1 LinkedList (java.util.LinkedList)1 Optional (java.util.Optional)1 Nullable (org.jetbrains.annotations.Nullable)1