Search in sources :

Example 6 with IssueTrackerCallbackInfoCreator

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

the class IssueTrackerIssueTransitionerTest method transitionIssueThrowsExceptionTest.

@Test
public void transitionIssueThrowsExceptionTest() throws AlertException {
    IssueOperation testOperation = IssueOperation.RESOLVE;
    IssueTransitionModel<String> issueTransitionModel = new IssueTransitionModel<>(null, testOperation, List.of("comment 1"), null);
    IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
    IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
    IssueTrackerIssueCommenter<String> exceptionThrowingCommenter = Mockito.mock(IssueTrackerIssueCommenter.class);
    Mockito.when(exceptionThrowingCommenter.commentOnIssue(Mockito.any())).thenThrow(new AlertException("Test exception"));
    IssueTrackerIssueTransitioner<String> transitioner = new TestTransitioner(exceptionThrowingCommenter, issueResponseCreator, "TODO", true, true);
    try {
        transitioner.transitionIssue(issueTransitionModel);
        fail("Expected an exception to be thrown");
    } catch (IssueMissingTransitionException e) {
        assertEquals(TEST_EXCEPTION, e);
    }
}
Also used : IssueTrackerCallbackInfoCreator(com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator) IssueTransitionModel(com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel) IssueMissingTransitionException(com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueMissingTransitionException) IssueOperation(com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test)

Example 7 with IssueTrackerCallbackInfoCreator

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

the class IssueTrackerIssueResponseCreatorTest method createIssueResponseWithCallbackInfoTest.

@Test
public void createIssueResponseWithCallbackInfoTest() {
    IssueTrackerCallbackInfo callbackInfo = Mockito.mock(IssueTrackerCallbackInfo.class);
    IssueTrackerCallbackInfoCreator callbackInfoCreator = Mockito.mock(IssueTrackerCallbackInfoCreator.class);
    Mockito.when(callbackInfoCreator.createCallbackInfo(Mockito.any())).thenReturn(Optional.of(callbackInfo));
    ProjectIssueModel source = Mockito.mock(ProjectIssueModel.class);
    runTest(source, callbackInfoCreator);
}
Also used : IssueTrackerCallbackInfoCreator(com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator) IssueTrackerCallbackInfo(com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Example 8 with IssueTrackerCallbackInfoCreator

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

the class IssueTrackerIssueResponseCreatorTest method createIssueResponseTest.

@Test
public void createIssueResponseTest() {
    IssueTrackerCallbackInfoCreator callbackInfoCreator = Mockito.mock(IssueTrackerCallbackInfoCreator.class);
    Mockito.when(callbackInfoCreator.createCallbackInfo(Mockito.any())).thenReturn(Optional.empty());
    ProjectIssueModel source = Mockito.mock(ProjectIssueModel.class);
    runTest(source, callbackInfoCreator);
}
Also used : IssueTrackerCallbackInfoCreator(com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator) ProjectIssueModel(com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel) Test(org.junit.jupiter.api.Test)

Aggregations

IssueTrackerCallbackInfoCreator (com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator)8 Test (org.junit.jupiter.api.Test)6 Gson (com.google.gson.Gson)3 IssueCategoryRetriever (com.synopsys.integration.alert.api.channel.issue.search.IssueCategoryRetriever)3 GsonBuilder (com.google.gson.GsonBuilder)2 IssueTransitionModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel)2 ProjectIssueModel (com.synopsys.integration.alert.api.channel.issue.model.ProjectIssueModel)2 JiraServerMessageSenderFactory (com.synopsys.integration.alert.channel.jira.server.distribution.JiraServerMessageSenderFactory)2 IssueOperation (com.synopsys.integration.alert.common.channel.issuetracker.enumeration.IssueOperation)2 TestProperties (com.synopsys.integration.alert.test.common.TestProperties)2 ProjectMessageToIssueModelTransformer (com.synopsys.integration.alert.api.channel.issue.convert.ProjectMessageToIssueModelTransformer)1 IssueTrackerIssueResponseModel (com.synopsys.integration.alert.api.channel.issue.model.IssueTrackerIssueResponseModel)1 ExistingIssueDetails (com.synopsys.integration.alert.api.channel.issue.search.ExistingIssueDetails)1 JiraMessageFormatter (com.synopsys.integration.alert.api.channel.jira.distribution.JiraMessageFormatter)1 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 JiraCloudMessageSenderFactory (com.synopsys.integration.alert.channel.jira.cloud.distribution.JiraCloudMessageSenderFactory)1 JiraServerGlobalConfigAccessor (com.synopsys.integration.alert.channel.jira.server.database.accessor.JiraServerGlobalConfigAccessor)1 JiraServerProcessorFactory (com.synopsys.integration.alert.channel.jira.server.distribution.JiraServerProcessorFactory)1 IssueMissingTransitionException (com.synopsys.integration.alert.common.channel.issuetracker.exception.IssueMissingTransitionException)1 IssueTrackerCallbackInfo (com.synopsys.integration.alert.common.channel.issuetracker.message.IssueTrackerCallbackInfo)1