use of com.synopsys.integration.alert.api.common.model.exception.AlertException 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);
}
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException 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);
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class IssueTrackerFieldModelTestActionTest method testConfigSendMessagesReturnsNoIssues.
@Test
public void testConfigSendMessagesReturnsNoIssues() throws AlertException {
IssueTrackerMessageSender<String> messageSender = Mockito.mock(IssueTrackerMessageSender.class);
Mockito.when(messageSender.sendMessages(Mockito.any())).thenReturn(List.of());
IssueTrackerMessageSenderFactory<TestJobDetails, String> messageSenderFactory = distributionDetails -> messageSender;
TestIssueTrackerTestAction issueTrackerTestAction = new TestIssueTrackerTestAction(messageSenderFactory);
MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
assertTrue(messageResult.hasErrors(), EXPECTED_ERRORS);
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class IssueTrackerFieldModelTestActionTest method testConfigNoResolveTransition.
@Test
public void testConfigNoResolveTransition() 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);
MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
assertFalse(messageResult.hasErrors(), EXPECTED_NO_ERRORS);
assertFalse(messageResult.hasWarnings(), EXPECTED_NO_WARNINGS);
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class IssueTrackerFieldModelTestActionTest method testConfigReopenFailure.
@Test
public void testConfigReopenFailure() throws AlertException {
IssueTrackerMessageSender<String> messageSender = Mockito.mock(IssueTrackerMessageSender.class);
Mockito.when(messageSender.sendMessages(Mockito.any())).thenAnswer(invocation -> {
IssueTrackerModelHolder<String> argument = invocation.getArgument(0);
List<IssueTransitionModel<String>> transitionModels = argument.getIssueTransitionModels();
if (!transitionModels.isEmpty()) {
if (transitionModels.stream().anyMatch(model -> IssueOperation.RESOLVE.equals(model.getIssueOperation()))) {
return List.of(TEST_ISSUE_RESPONSE_MODEL);
} else {
return List.of();
}
}
return List.of(TEST_ISSUE_RESPONSE_MODEL);
});
IssueTrackerMessageSenderFactory<TestJobDetails, String> messageSenderFactory = distributionDetails -> messageSender;
TestIssueTrackerTestAction issueTrackerTestAction = new TestIssueTrackerTestAction(messageSenderFactory, true, true);
MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
assertTrue(messageResult.hasErrors(), EXPECTED_ERRORS);
}
Aggregations