Search in sources :

Example 11 with IssueTrackerModelHolder

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

the class IssueTrackerProcessorTest method processMessagesTest.

@Test
public void processMessagesTest() throws AlertException {
    IssueTrackerModelExtractor<String> extractor = Mockito.mock(IssueTrackerModelExtractor.class);
    IssueTrackerModelHolder<String> simpleMessageResponses = new IssueTrackerModelHolder<>(List.of(), List.of(), List.of());
    Mockito.when(extractor.extractSimpleMessageIssueModels(Mockito.anyList(), Mockito.any())).thenReturn(simpleMessageResponses);
    IssueTrackerIssueResponseModel<String> response1 = Mockito.mock(IssueTrackerIssueResponseModel.class);
    IssueTrackerIssueResponseModel<String> response2 = Mockito.mock(IssueTrackerIssueResponseModel.class);
    IssueTrackerIssueResponseModel<String> response3 = Mockito.mock(IssueTrackerIssueResponseModel.class);
    List<IssueTrackerIssueResponseModel<String>> simpleMessageResponse = List.of(response1, response2, response3);
    IssueTrackerIssueResponseModel<String> response4 = Mockito.mock(IssueTrackerIssueResponseModel.class);
    IssueTrackerIssueResponseModel<String> response5 = Mockito.mock(IssueTrackerIssueResponseModel.class);
    List<IssueTrackerIssueResponseModel<String>> projectMessageResponses = List.of(response4, response5);
    IssueTrackerMessageSender<String> sender = Mockito.mock(IssueTrackerMessageSender.class);
    Mockito.when(sender.sendMessages(Mockito.any())).thenReturn(simpleMessageResponse, projectMessageResponses);
    IssueTrackerProcessor<String> processor = new IssueTrackerProcessor<>(extractor, sender);
    ProjectMessage projectMessage = Mockito.mock(ProjectMessage.class);
    ProviderMessageHolder providerMessageHolder = new ProviderMessageHolder(List.of(projectMessage), List.of());
    IssueTrackerResponse<String> issueTrackerResponse = processor.processMessages(providerMessageHolder, "jobName");
    assertEquals(simpleMessageResponse.size() + projectMessageResponses.size(), issueTrackerResponse.getUpdatedIssues().size());
}
Also used : IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) ProjectMessage(com.synopsys.integration.alert.processor.api.extract.model.project.ProjectMessage) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) ProviderMessageHolder(com.synopsys.integration.alert.processor.api.extract.model.ProviderMessageHolder) Test(org.junit.jupiter.api.Test)

Example 12 with IssueTrackerModelHolder

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

the class IssueTrackerMessageSenderTest method createModelHolder.

private IssueTrackerModelHolder<String> createModelHolder() {
    IssueCreationModel issueCreationModel1 = Mockito.mock(IssueCreationModel.class);
    IssueCreationModel issueCreationModel2 = Mockito.mock(IssueCreationModel.class);
    IssueCommentModel<String> issueCommentModel = Mockito.mock(IssueCommentModel.class);
    return new IssueTrackerModelHolder<>(List.of(issueCreationModel1, issueCreationModel2), List.of(), List.of(issueCommentModel));
}
Also used : IssueCreationModel(com.synopsys.integration.alert.api.channel.issue.model.IssueCreationModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)

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