use of com.synopsys.integration.alert.common.util.MarkupEncoderUtil in project hub-alert by blackducksoftware.
the class SlackDistributionEventHandlerTest method init.
@BeforeEach
public void init() throws IOException {
MarkupEncoderUtil markupEncoderUtil = new MarkupEncoderUtil();
SlackChannelMessageFormatter slackChannelMessageFormatter = new SlackChannelMessageFormatter(markupEncoderUtil);
SlackChannelMessageConverter slackChannelMessageConverter = new SlackChannelMessageConverter(slackChannelMessageFormatter);
SlackChannelMessageSender slackChannelMessageSender = new SlackChannelMessageSender(ChannelKeys.SLACK, createConnectionFactory());
SlackChannel slackChannel = new SlackChannel(slackChannelMessageConverter, slackChannelMessageSender);
mockSlackServer.start();
String url = mockSlackServer.url("/").toString();
SlackJobDetailsModel slackJobDetailsModel = new SlackJobDetailsModel(null, url, "channelName", "userName");
SlackJobDetailsAccessor slackJobDetailsAccessor = jobId -> Optional.of(slackJobDetailsModel);
distributionEventHandler = new SlackDistributionEventHandler(slackChannel, slackJobDetailsAccessor, processingAuditAccessor);
}
use of com.synopsys.integration.alert.common.util.MarkupEncoderUtil 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.common.util.MarkupEncoderUtil 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");
}
Aggregations