Search in sources :

Example 1 with IssueTrackerMessageSender

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

the class IssueTrackerFieldModelTestActionTest method testConfigNoReopen.

@Test
public void testConfigNoReopen() throws AlertException {
    IssueTrackerMessageSender<String> messageSender = Mockito.mock(IssueTrackerMessageSender.class);
    Mockito.when(messageSender.sendMessages(Mockito.any())).thenReturn(List.of(TEST_ISSUE_RESPONSE_MODEL));
    IssueTrackerMessageSenderFactory<TestJobDetails, String> messageSenderFactory = distributionDetails -> messageSender;
    TestIssueTrackerTestAction issueTrackerTestAction = new TestIssueTrackerTestAction(messageSenderFactory, true, false);
    MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
    assertFalse(messageResult.hasErrors(), EXPECTED_NO_ERRORS);
    assertFalse(messageResult.hasWarnings(), EXPECTED_NO_WARNINGS);
}
Also used : DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) IssueTrackerMessageSenderFactory(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSenderFactory) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender) IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) FrequencyType(com.synopsys.integration.alert.common.enumeration.FrequencyType) UUID(java.util.UUID) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProcessingType(com.synopsys.integration.alert.common.enumeration.ProcessingType) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IssueTrackerChannelKey(com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) Test(org.junit.jupiter.api.Test)

Example 2 with IssueTrackerMessageSender

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

the class JiraCloudMessageSenderFactory method createMessageSender.

public IssueTrackerMessageSender<String> createMessageSender(IssueService issueService, JiraCloudJobDetailsModel distributionDetails, ProjectService projectService, JiraIssueCreationRequestCreator issueCreationRequestCreator, JiraIssueAlertPropertiesManager issuePropertiesManager, JiraErrorMessageUtility jiraErrorMessageUtility) {
    // Jira Services
    IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
    // Message Sender Requirements
    JiraCloudIssueCommenter issueCommenter = new JiraCloudIssueCommenter(issueResponseCreator, issueService, distributionDetails);
    JiraCloudIssueTransitioner issueTransitioner = new JiraCloudIssueTransitioner(issueCommenter, issueResponseCreator, distributionDetails, issueService);
    JiraCloudIssueCreator issueCreator = new JiraCloudIssueCreator(channelKey, issueCommenter, callbackInfoCreator, distributionDetails, issueService, projectService, issueCreationRequestCreator, issuePropertiesManager, jiraErrorMessageUtility, issueCategoryRetriever);
    return new IssueTrackerMessageSender<>(issueCreator, issueTransitioner, issueCommenter);
}
Also used : JiraCloudIssueTransitioner(com.synopsys.integration.alert.channel.jira.cloud.distribution.delegate.JiraCloudIssueTransitioner) JiraCloudIssueCreator(com.synopsys.integration.alert.channel.jira.cloud.distribution.delegate.JiraCloudIssueCreator) IssueTrackerIssueResponseCreator(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueResponseCreator) JiraCloudIssueCommenter(com.synopsys.integration.alert.channel.jira.cloud.distribution.delegate.JiraCloudIssueCommenter) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)

Example 3 with IssueTrackerMessageSender

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

the class JiraServerMessageSenderFactory method createMessageSender.

public IssueTrackerMessageSender<String> createMessageSender(IssueService issueService, JiraServerJobDetailsModel distributionDetails, ProjectService projectService, JiraIssueCreationRequestCreator issueCreationRequestCreator, JiraIssueAlertPropertiesManager issuePropertiesManager, JiraErrorMessageUtility jiraErrorMessageUtility) {
    IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
    // Message Sender Requirements
    JiraServerIssueCommenter commenter = new JiraServerIssueCommenter(issueResponseCreator, issueService, distributionDetails);
    JiraServerIssueTransitioner transitioner = new JiraServerIssueTransitioner(commenter, issueResponseCreator, distributionDetails, issueService);
    JiraServerIssueCreator creator = new JiraServerIssueCreator(channelKey, commenter, callbackInfoCreator, distributionDetails, issueService, projectService, issueCreationRequestCreator, issuePropertiesManager, jiraErrorMessageUtility, issueCategoryRetriever);
    return new IssueTrackerMessageSender<>(creator, transitioner, commenter);
}
Also used : JiraServerIssueCommenter(com.synopsys.integration.alert.channel.jira.server.distribution.delegate.JiraServerIssueCommenter) JiraServerIssueTransitioner(com.synopsys.integration.alert.channel.jira.server.distribution.delegate.JiraServerIssueTransitioner) IssueTrackerIssueResponseCreator(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueResponseCreator) JiraServerIssueCreator(com.synopsys.integration.alert.channel.jira.server.distribution.delegate.JiraServerIssueCreator) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)

Example 4 with IssueTrackerMessageSender

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

the class AzureBoardsMessageSenderFactory method createMessageSender.

public IssueTrackerMessageSender<Integer> createMessageSender(AzureWorkItemService workItemService, AzureWorkItemTypeStateService workItemTypeStateService, AzureWorkItemCommentService workItemCommentService, String organizationName, AzureBoardsJobDetailsModel distributionDetails) {
    IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
    AzureBoardsWorkItemTypeStateRetriever workItemTypeStateRetriever = new AzureBoardsWorkItemTypeStateRetriever(gson, workItemService, workItemTypeStateService);
    AzureBoardsAlertIssuePropertiesManager issuePropertiesManager = new AzureBoardsAlertIssuePropertiesManager();
    // Message Sender Requirements
    AzureBoardsIssueCommenter commenter = new AzureBoardsIssueCommenter(issueResponseCreator, organizationName, distributionDetails, workItemCommentService);
    AzureBoardsIssueTransitioner transitioner = new AzureBoardsIssueTransitioner(commenter, issueResponseCreator, gson, organizationName, distributionDetails, workItemService, workItemTypeStateRetriever, exceptionMessageImprover);
    AzureBoardsIssueCreator creator = new AzureBoardsIssueCreator(channelKey, commenter, callbackInfoCreator, gson, organizationName, distributionDetails, workItemService, issuePropertiesManager, exceptionMessageImprover, issueCategoryRetriever);
    return new IssueTrackerMessageSender<>(creator, transitioner, commenter);
}
Also used : AzureBoardsAlertIssuePropertiesManager(com.synopsys.integration.alert.channel.azure.boards.distribution.search.AzureBoardsAlertIssuePropertiesManager) AzureBoardsIssueCreator(com.synopsys.integration.alert.channel.azure.boards.distribution.delegate.AzureBoardsIssueCreator) IssueTrackerIssueResponseCreator(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerIssueResponseCreator) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender) AzureBoardsIssueTransitioner(com.synopsys.integration.alert.channel.azure.boards.distribution.delegate.AzureBoardsIssueTransitioner) AzureBoardsIssueCommenter(com.synopsys.integration.alert.channel.azure.boards.distribution.delegate.AzureBoardsIssueCommenter)

Example 5 with IssueTrackerMessageSender

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

the class IssueTrackerFieldModelTestActionTest method testConfigResolveFailure.

@Test
public void testConfigResolveFailure() throws AlertException {
    IssueTrackerMessageSender<String> messageSender = Mockito.mock(IssueTrackerMessageSender.class);
    Mockito.when(messageSender.sendMessages(Mockito.any())).thenAnswer(invocation -> {
        IssueTrackerModelHolder<String> argument = invocation.getArgument(0);
        if (!argument.getIssueCreationModels().isEmpty()) {
            return List.of(TEST_ISSUE_RESPONSE_MODEL);
        }
        return List.of();
    });
    IssueTrackerMessageSenderFactory<TestJobDetails, String> messageSenderFactory = distributionDetails -> messageSender;
    TestIssueTrackerTestAction issueTrackerTestAction = new TestIssueTrackerTestAction(messageSenderFactory, true, false);
    MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
    assertTrue(messageResult.hasErrors(), EXPECTED_ERRORS);
}
Also used : DistributionJobModel(com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel) IssueTrackerMessageSenderFactory(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSenderFactory) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) IssueTrackerMessageSender(com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender) IssueTrackerIssueResponseModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) FrequencyType(com.synopsys.integration.alert.common.enumeration.FrequencyType) UUID(java.util.UUID) DistributionJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel) IssueTrackerModelHolder(com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder) IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) OffsetDateTime(java.time.OffsetDateTime) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) ProcessingType(com.synopsys.integration.alert.common.enumeration.ProcessingType) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) IssueTrackerChannelKey(com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) Test(org.junit.jupiter.api.Test)

Aggregations

IssueTrackerMessageSender (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSender)10 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)7 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)7 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)7 DistributionJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.DistributionJobDetailsModel)7 Test (org.junit.jupiter.api.Test)7 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)6 IssueTrackerModelHolder (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerModelHolder)6 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)6 IssueTrackerMessageSenderFactory (com.synopsys.integration.alert.api.channel.issue.send.IssueTrackerMessageSenderFactory)6 FrequencyType (com.synopsys.integration.alert.common.enumeration.FrequencyType)6 ProcessingType (com.synopsys.integration.alert.common.enumeration.ProcessingType)6 DistributionJobModel (com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel)6 IssueTrackerChannelKey (com.synopsys.integration.alert.descriptor.api.model.IssueTrackerChannelKey)6 OffsetDateTime (java.time.OffsetDateTime)6 List (java.util.List)6 UUID (java.util.UUID)6 Assertions.assertFalse (org.junit.jupiter.api.Assertions.assertFalse)6 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)6 Mockito (org.mockito.Mockito)6