Search in sources :

Example 1 with DistributionChannelConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity 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 DistributionChannelConfigEntity

use of com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity in project hub-alert by blackducksoftware.

the class ChannelEventFactoryTest method createEventWithChannelManagerTest.

@Test
public void createEventWithChannelManagerTest() {
    final DistributionChannelManager<GlobalChannelConfigEntity, DistributionChannelConfigEntity, AbstractChannelEvent, CommonDistributionConfigRestModel> manager = Mockito.mock(DistributionChannelManager.class);
    final List<DistributionChannelManager<GlobalChannelConfigEntity, DistributionChannelConfigEntity, AbstractChannelEvent, CommonDistributionConfigRestModel>> managers = Arrays.asList(manager);
    final ChannelEventFactory<AbstractChannelEvent, DistributionChannelConfigEntity, GlobalChannelConfigEntity, CommonDistributionConfigRestModel> factory = new ChannelEventFactory<>(managers);
    final Long id = 25L;
    final ProjectData projectData = new ProjectData(DigestTypeEnum.REAL_TIME, "Project Name", "Project Version", Collections.emptyList(), Collections.emptyMap());
    final AbstractChannelEvent mockEvent = new AbstractChannelEvent(projectData, id) {

        @Override
        public String getTopic() {
            return DISTRIBUTION_TYPE;
        }
    };
    Mockito.when(manager.isApplicable(DISTRIBUTION_TYPE)).thenReturn(true);
    Mockito.when(manager.createChannelEvent(Mockito.any(), Mockito.anyLong())).thenReturn(mockEvent);
    final AbstractChannelEvent event = factory.createEvent(id, "TYPE", projectData);
    assertEquals(mockEvent, event);
}
Also used : CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) DistributionChannelConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity) GlobalChannelConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity) ProjectData(com.blackducksoftware.integration.hub.alert.digest.model.ProjectData) AbstractChannelEvent(com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent) Test(org.junit.Test)

Aggregations

DistributionChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.distribution.DistributionChannelConfigEntity)2 GlobalChannelConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity)2 ProjectData (com.blackducksoftware.integration.hub.alert.digest.model.ProjectData)2 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)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 SlackEvent (com.blackducksoftware.integration.hub.alert.channel.slack.SlackEvent)1 SlackDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.channel.slack.repository.distribution.SlackDistributionConfigEntity)1 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)1 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)1 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)1