use of com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method sendMessageTestIT.
@Test
@Tag(TestTags.DEFAULT_INTEGRATION)
@Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION)
public void sendMessageTestIT() {
MarkupEncoderUtil markupEncoderUtil = new MarkupEncoderUtil();
SlackChannelMessageFormatter slackChannelMessageFormatter = new SlackChannelMessageFormatter(markupEncoderUtil);
SlackChannelMessageConverter slackChannelMessageConverter = new SlackChannelMessageConverter(slackChannelMessageFormatter);
ChannelRestConnectionFactory connectionFactory = createConnectionFactory();
SlackChannelMessageSender slackChannelMessageSender = new SlackChannelMessageSender(ChannelKeys.SLACK, connectionFactory);
SlackChannel slackChannel = new SlackChannel(slackChannelMessageConverter, slackChannelMessageSender);
SlackJobDetailsModel distributionDetails = new SlackJobDetailsModel(null, properties.getProperty(TestPropertyKey.TEST_SLACK_WEBHOOK), properties.getProperty(TestPropertyKey.TEST_SLACK_CHANNEL_NAME), properties.getProperty(TestPropertyKey.TEST_SLACK_USERNAME));
ChannelITTestAssertions.assertSendSimpleMessageSuccess(slackChannel, distributionDetails);
}
use of com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class SlackChannelTestIT method createConnectionFactory.
private ChannelRestConnectionFactory createConnectionFactory() {
MockAlertProperties testAlertProperties = new MockAlertProperties();
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
use of com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class SlackDistributionEventHandlerTest method createConnectionFactory.
private ChannelRestConnectionFactory createConnectionFactory() {
MockAlertProperties testAlertProperties = new MockAlertProperties();
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
use of com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class MsTeamsChannelTest method sendMessageTestIT.
@Test
@Tag(TestTags.DEFAULT_INTEGRATION)
@Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION)
public void sendMessageTestIT() {
ChannelRestConnectionFactory connectionFactory = createConnectionFactory();
MarkupEncoderUtil markupEncoderUtil = new MarkupEncoderUtil();
MSTeamsChannelMessageConverter messageConverter = new MSTeamsChannelMessageConverter(new MSTeamsChannelMessageFormatter(markupEncoderUtil));
MSTeamsChannelMessageSender messageSender = new MSTeamsChannelMessageSender(ChannelKeys.MS_TEAMS, connectionFactory);
MSTeamsChannel msTeamsChannel = new MSTeamsChannel(messageConverter, messageSender);
MSTeamsJobDetailsModel msTeamsJobDetailsModel = new MSTeamsJobDetailsModel(UUID.randomUUID(), properties.getProperty(TestPropertyKey.TEST_MSTEAMS_WEBHOOK));
MessageResult messageResult = null;
try {
messageResult = msTeamsChannel.distributeMessages(msTeamsJobDetailsModel, TEST_MESSAGE_HOLDER, "jobName");
} catch (AlertException e) {
Assertions.fail("Failed to distribute simple channel message due to an exception", e);
}
Assertions.assertFalse(messageResult.hasErrors(), "The message result had errors");
Assertions.assertFalse(messageResult.hasWarnings(), "The message result had warnings");
}
use of com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory in project hub-alert by blackducksoftware.
the class MsTeamsChannelTest method createConnectionFactory.
private ChannelRestConnectionFactory createConnectionFactory() {
MockAlertProperties testAlertProperties = new MockAlertProperties();
ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
return new ChannelRestConnectionFactory(testAlertProperties, proxyManager, gson);
}
Aggregations