use of com.synopsys.integration.alert.api.channel.issue.model.IssueTransitionModel 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