Search in sources :

Example 1 with SlackEvent

use of com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent in project hub-alert by blackducksoftware.

the class RestDistributionChannelTest method sendMessageFailureTest.

@Test
public void sendMessageFailureTest() {
    final GlobalProperties globalProperties = new TestGlobalProperties();
    final ChannelRestConnectionFactory channelRestConnectionFactory = new ChannelRestConnectionFactory(globalProperties);
    final RestDistributionChannel<AbstractChannelEvent, GlobalChannelConfigEntity, DistributionChannelConfigEntity> restChannel = new RestDistributionChannel<AbstractChannelEvent, GlobalChannelConfigEntity, DistributionChannelConfigEntity>(null, null, null, null, null, null, channelRestConnectionFactory) {

        @Override
        public String getApiUrl() {
            return null;
        }

        @Override
        public Request createRequest(final ChannelRequestHelper channelRequestHelper, final DistributionChannelConfigEntity config, final ProjectData projectData) throws AlertException {
            return new Request.Builder().uri("http://google.com").build();
        }
    };
    final SlackEvent event = new SlackEvent(createProjectData("Rest channel test"), 1L);
    final SlackDistributionConfigEntity config = new SlackDistributionConfigEntity("more garbage", "garbage", "garbage");
    Exception thrownException = null;
    try {
        restChannel.sendAuditedMessage(event, config);
    } catch (final IntegrationException ex) {
        thrownException = ex;
    }
    assertNotNull(thrownException);
}
Also used : IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) SlackEvent(com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent) GlobalChannelConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity) AlertException(com.blackducksoftware.integration.hub.alert.exception.AlertException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) AbstractChannelEvent(com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) DistributionChannelConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity) SlackDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.channel.slack.repository.distribution.SlackDistributionConfigEntity) TestGlobalProperties(com.blackducksoftware.integration.hub.alert.TestGlobalProperties) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) Test(org.junit.Test) ChannelTest(com.blackducksoftware.integration.hub.alert.channel.ChannelTest)

Example 2 with SlackEvent

use of com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent in project hub-alert by blackducksoftware.

the class ChannelTemplateManagerTest method testSendEventReturnsFalse.

@Test
public void testSendEventReturnsFalse() {
    final ChannelTemplateManager channelTemplateManager = new ChannelTemplateManager(new Gson(), null, null, null);
    final SlackEvent slackEvent = new SlackEvent(null, 1L);
    final boolean isFalse = channelTemplateManager.sendEvent(slackEvent);
    assertTrue(!isFalse);
}
Also used : Gson(com.google.gson.Gson) SlackEvent(com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent) Test(org.junit.Test)

Aggregations

SlackEvent (com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent)2 Test (org.junit.Test)2 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)1 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)1 ChannelTest (com.blackducksoftware.integration.hub.alert.channel.ChannelTest)1 SlackDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.channel.slack.repository.distribution.SlackDistributionConfigEntity)1 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)1 DistributionChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity)1 GlobalChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity)1 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)1 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)1 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)1 Gson (com.google.gson.Gson)1