use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class RealTimeListenerTest method testReceiveMessageException.
@SuppressWarnings("unchecked")
@Test
public void testReceiveMessageException() throws IOException, Exception {
try (OutputLogger outputLogger = new OutputLogger()) {
final Gson gson = new Gson();
final MockNotificationEntity notificationEntity = new MockNotificationEntity();
final NotificationModel model = new NotificationModel(notificationEntity.createEntity(), Collections.emptyList());
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
final ProjectDataFactory projectDataFactory = Mockito.mock(ProjectDataFactory.class);
final NotificationEventManager eventManager = Mockito.mock(NotificationEventManager.class);
Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.any());
Mockito.doThrow(new NullPointerException("null error")).when(projectDataFactory).createProjectDataCollection(Mockito.anyCollection(), Mockito.any());
final RealTimeListener realTimeListener = new RealTimeListener(gson, channelTemplateManager, projectDataFactory, eventManager);
final RealTimeEvent realTimeEvent = new RealTimeEvent(Arrays.asList(model));
final String realTimeEventString = gson.toJson(realTimeEvent);
realTimeListener.receiveMessage(realTimeEventString);
assertTrue(outputLogger.isLineContainingText("null"));
}
}
use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class DigestItemWriterTest method testWrite.
@Test
public void testWrite() throws Exception {
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.anyListOf(AbstractChannelEvent.class));
final DigestItemWriter digestItemWriter = new DigestItemWriter(channelTemplateManager);
final AbstractChannelEvent abstractChannelEvent = Mockito.mock(AbstractChannelEvent.class);
final List<AbstractChannelEvent> channelList = Arrays.asList(abstractChannelEvent);
digestItemWriter.write(Arrays.asList(channelList));
Mockito.verify(channelTemplateManager).sendEvents(Mockito.anyListOf(AbstractChannelEvent.class));
}
use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class AccumulatorWriterTest method testWrite.
@Test
public void testWrite() throws Exception {
final NotificationManager notificationManager = Mockito.mock(NotificationManager.class);
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
final AccumulatorWriter accumulatorWriter = new AccumulatorWriter(notificationManager, channelTemplateManager);
final String eventKey = "_event_key_";
final NotificationCategoryEnum categoryType = NotificationCategoryEnum.HIGH_VULNERABILITY;
final NotificationEvent notificationEvent = new NotificationEvent(eventKey, categoryType, generateDataSet());
final DBStoreEvent storeEvent = new DBStoreEvent(Arrays.asList(notificationEvent));
accumulatorWriter.write(Arrays.asList(storeEvent));
Mockito.verify(channelTemplateManager).sendEvent(Mockito.any());
}
use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class RealTimeListenerTest method testReceiveMessage.
@Test
public void testReceiveMessage() {
final Gson gson = new Gson();
final MockNotificationEntity notificationEntity = new MockNotificationEntity();
final NotificationModel model = new NotificationModel(notificationEntity.createEntity(), Collections.emptyList());
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
final ProjectDataFactory projectDataFactory = Mockito.mock(ProjectDataFactory.class);
final NotificationEventManager eventManager = Mockito.mock(NotificationEventManager.class);
final RealTimeListener realTimeListener = new RealTimeListener(gson, channelTemplateManager, projectDataFactory, eventManager);
final RealTimeEvent realTimeEvent = new RealTimeEvent(Arrays.asList(model));
final String realTimeEventString = gson.toJson(realTimeEvent);
realTimeListener.receiveMessage(realTimeEventString);
Mockito.doNothing().when(channelTemplateManager).sendEvents(Mockito.any());
Mockito.verify(channelTemplateManager).sendEvents(Mockito.any());
}
use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method createMockedConfigActionsUsingObjectTransformer.
@Override
public GlobalSchedulingConfigActions createMockedConfigActionsUsingObjectTransformer(final ObjectTransformer objectTransformer) {
final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
Mockito.when(mockedAccumulatorConfig.getMillisecondsToNextRun()).thenReturn(33000l);
final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
Mockito.when(mockedDailyDigestBatchConfig.getFormatedNextRunTime()).thenReturn("01/19/2018 02:00 AM UTC");
final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
Mockito.when(mockedPurgeConfig.getFormatedNextRunTime()).thenReturn("01/21/2018 12:00 AM UTC");
final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
final NotificationRepositoryWrapper notificationRepository = Mockito.mock(NotificationRepositoryWrapper.class);
final VulnerabilityRepositoryWrapper vulnerabilityRepository = Mockito.mock(VulnerabilityRepositoryWrapper.class);
final GlobalSchedulingConfigActions configActions = new GlobalSchedulingConfigActions(mockedAccumulatorConfig, mockedDailyDigestBatchConfig, mockedPurgeConfig, globalSchedulingRepository, objectTransformer, globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
return configActions;
}
Aggregations