use of com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator in project hub-alert by blackducksoftware.
the class JiraServerSummaryFieldLengthTestIT method createJiraServerMessageSender.
private static IssueTrackerMessageSender<String> createJiraServerMessageSender() throws AlertException {
TestProperties testProperties = new TestProperties();
Gson gson = new GsonBuilder().create();
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
JiraServerMessageSenderFactory jiraServerMessageSenderFactory = new JiraServerMessageSenderFactory(gson, ChannelKeys.JIRA_SERVER, createJiraServerPropertiesFactory(testProperties), new IssueTrackerCallbackInfoCreator(), issueCategoryRetriever);
JiraServerJobDetailsModel jiraServerJobDetails = createJiraServerJobDetails(testProperties);
return jiraServerMessageSenderFactory.createMessageSender(jiraServerJobDetails);
}
use of com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator in project hub-alert by blackducksoftware.
the class JiraServerExternalConnectionTest method sendJiraServerMessageTest.
// This test is @Disabled since it requires a running Jira Server instance. In order to run this test, you must deploy a Jira Server and
// add the Jira Server environment values into test.properties
@Test
@Disabled
public void sendJiraServerMessageTest() throws AlertException {
Gson gson = new Gson();
JiraMessageFormatter jiraMessageFormatter = new JiraMessageFormatter();
JiraServerChannelKey jiraServerChannelKey = new JiraServerChannelKey();
JiraServerGlobalConfigAccessor jiraServerGlobalConfigAccessor = Mockito.mock(JiraServerGlobalConfigAccessor.class);
Mockito.when(jiraServerGlobalConfigAccessor.getConfigurationByName(Mockito.anyString())).thenReturn(Optional.of(createJiraServerConfigModel()));
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(null);
JobAccessor jobAccessor = Mockito.mock(JobAccessor.class);
Mockito.when(jobAccessor.getJobById(Mockito.any())).thenReturn(Optional.of(createDistributionJobModel()));
JiraServerPropertiesFactory jiraServerPropertiesFactory = new JiraServerPropertiesFactory(proxyManager, jiraServerGlobalConfigAccessor, jobAccessor);
IssueTrackerCallbackInfoCreator issueTrackerCallbackInfoCreator = new IssueTrackerCallbackInfoCreator();
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
JiraServerMessageSenderFactory jiraServerMessageSenderFactory = new JiraServerMessageSenderFactory(gson, jiraServerChannelKey, jiraServerPropertiesFactory, issueTrackerCallbackInfoCreator, issueCategoryRetriever);
ProjectMessageToIssueModelTransformer modelTransformer = new ProjectMessageToIssueModelTransformer();
JiraServerProcessorFactory jiraServerProcessorFactory = new JiraServerProcessorFactory(gson, jiraMessageFormatter, jiraServerPropertiesFactory, jiraServerMessageSenderFactory, modelTransformer, issueCategoryRetriever);
IssueTrackerProcessor<String> processor = jiraServerProcessorFactory.createProcessor(createDistributionDetails());
IssueTrackerResponse<String> response = processor.processMessages(createMessage(), "jobName");
assertEquals("Success", response.getStatusMessage());
}
use of com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator in project hub-alert by blackducksoftware.
the class IssueTrackerIssueTransitionerTest method transitionIssueTest.
@Test
public void transitionIssueTest() throws AlertException {
IssueOperation testOperation = IssueOperation.RESOLVE;
ExistingIssueDetails<String> existingIssueDetails = new ExistingIssueDetails<>("id", "key", "title", "https://link", IssueStatus.UNKNOWN, IssueCategory.BOM);
IssueTransitionModel<String> issueTransitionModel = new IssueTransitionModel<>(existingIssueDetails, testOperation, List.of("comment 1"), null);
IssueTrackerCallbackInfoCreator callbackInfoCreator = new IssueTrackerCallbackInfoCreator();
IssueTrackerIssueResponseCreator issueResponseCreator = new IssueTrackerIssueResponseCreator(callbackInfoCreator);
IssueTrackerIssueTransitioner<String> transitioner = new TestTransitioner(commenter, issueResponseCreator, "TODO", true, false);
Optional<IssueTrackerIssueResponseModel<String>> optionalResponseModel = transitioner.transitionIssue(issueTransitionModel);
assertTrue(optionalResponseModel.isPresent(), "Expected response model to be present");
IssueTrackerIssueResponseModel<String> responseModel = optionalResponseModel.get();
assertEquals(existingIssueDetails.getIssueId(), responseModel.getIssueId());
assertEquals(existingIssueDetails.getIssueKey(), responseModel.getIssueKey());
assertEquals(existingIssueDetails.getIssueSummary(), responseModel.getIssueTitle());
assertEquals(existingIssueDetails.getIssueUILink(), responseModel.getIssueLink());
assertEquals(testOperation, responseModel.getIssueOperation());
}
use of com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator in project hub-alert by blackducksoftware.
the class IssueTrackerIssueResponseCreatorTest method createIssueResponseWithNullSourceTest.
@Test
public void createIssueResponseWithNullSourceTest() {
IssueTrackerCallbackInfoCreator callbackInfoCreator = Mockito.mock(IssueTrackerCallbackInfoCreator.class);
runTest(null, callbackInfoCreator);
}
use of com.synopsys.integration.alert.api.channel.issue.callback.IssueTrackerCallbackInfoCreator in project hub-alert by blackducksoftware.
the class JiraCloudSummaryFieldLengthTestIT method createJiraCloudMessageSender.
private static IssueTrackerMessageSender<String> createJiraCloudMessageSender() throws AlertException {
TestProperties testProperties = new TestProperties();
Gson gson = new GsonBuilder().create();
IssueCategoryRetriever issueCategoryRetriever = new IssueCategoryRetriever();
JiraCloudMessageSenderFactory jiraCloudMessageSenderFactory = new JiraCloudMessageSenderFactory(gson, ChannelKeys.JIRA_CLOUD, createJiraCloudPropertiesFactory(testProperties), new IssueTrackerCallbackInfoCreator(), issueCategoryRetriever);
JiraCloudJobDetailsModel jiraCloudJobDetails = createJiraCloudJobDetails(testProperties);
return jiraCloudMessageSenderFactory.createMessageSender(jiraCloudJobDetails);
}
Aggregations