use of com.synopsys.integration.alert.common.message.model.MessageResult 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.common.message.model.MessageResult 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.common.message.model.MessageResult 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.common.message.model.MessageResult 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);
}
use of com.synopsys.integration.alert.common.message.model.MessageResult in project hub-alert by blackducksoftware.
the class IssueTrackerFieldModelTestActionTest method testConfigSendMessagesThrowsException.
@Test
public void testConfigSendMessagesThrowsException() throws AlertException {
String testExceptionMessage = "test exception message";
IssueTrackerMessageSender<String> messageSender = Mockito.mock(IssueTrackerMessageSender.class);
Mockito.when(messageSender.sendMessages(Mockito.any())).thenThrow(new AlertException(testExceptionMessage));
IssueTrackerMessageSenderFactory<TestJobDetails, String> messageSenderFactory = distributionDetails -> messageSender;
TestIssueTrackerTestAction issueTrackerTestAction = new TestIssueTrackerTestAction(messageSenderFactory);
MessageResult messageResult = issueTrackerTestAction.testConfig(TEST_JOB_MODEL, "jobName", null, null);
assertTrue(messageResult.getStatusMessage().contains(testExceptionMessage), "Expected the message result to contain the expected exception message");
}
Aggregations