use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity 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);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.global.GlobalChannelConfigEntity 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);
}
Aggregations