Search in sources :

Example 1 with ChannelRestConnectionFactory

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);
}
Also used : MarkupEncoderUtil(com.synopsys.integration.alert.common.util.MarkupEncoderUtil) ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) SlackJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 2 with ChannelRestConnectionFactory

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);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 3 with ChannelRestConnectionFactory

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);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Example 4 with ChannelRestConnectionFactory

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");
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MarkupEncoderUtil(com.synopsys.integration.alert.common.util.MarkupEncoderUtil) MSTeamsJobDetailsModel(com.synopsys.integration.alert.common.persistence.model.job.details.MSTeamsJobDetailsModel) MessageResult(com.synopsys.integration.alert.common.message.model.MessageResult) AlertException(com.synopsys.integration.alert.api.common.model.exception.AlertException) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag)

Example 5 with ChannelRestConnectionFactory

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);
}
Also used : ChannelRestConnectionFactory(com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory) MockAlertProperties(com.synopsys.integration.alert.test.common.MockAlertProperties) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager)

Aggregations

ChannelRestConnectionFactory (com.synopsys.integration.alert.api.channel.rest.ChannelRestConnectionFactory)5 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)3 MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)3 MarkupEncoderUtil (com.synopsys.integration.alert.common.util.MarkupEncoderUtil)2 Tag (org.junit.jupiter.api.Tag)2 Test (org.junit.jupiter.api.Test)2 AlertException (com.synopsys.integration.alert.api.common.model.exception.AlertException)1 MessageResult (com.synopsys.integration.alert.common.message.model.MessageResult)1 MSTeamsJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.MSTeamsJobDetailsModel)1 SlackJobDetailsModel (com.synopsys.integration.alert.common.persistence.model.job.details.SlackJobDetailsModel)1