use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class GlobalSchedulingConfigActionsTest method testConfigurationChangeTriggers.
@Override
public void testConfigurationChangeTriggers() {
final AccumulatorConfig mockedAccumulatorConfig = Mockito.mock(AccumulatorConfig.class);
final DailyDigestBatchConfig mockedDailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
final PurgeConfig mockedPurgeConfig = Mockito.mock(PurgeConfig.class);
final GlobalSchedulingRepositoryWrapper globalSchedulingRepository = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
Mockito.when(globalSchedulingRepository.findAll()).thenReturn(Arrays.asList(getGlobalEntityMockUtil().createGlobalEntity()));
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, new ObjectTransformer(), globalProperties, channelTemplateManager, new NotificationManager(notificationRepository, vulnerabilityRepository, null, null));
configActions.configurationChangeTriggers(null);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.reset(mockedAccumulatorConfig);
Mockito.reset(mockedDailyDigestBatchConfig);
Mockito.reset(mockedPurgeConfig);
final GlobalSchedulingConfigRestModel restModel = getGlobalRestModelMockUtil().createGlobalRestModel();
configActions.configurationChangeTriggers(restModel);
Mockito.verify(mockedAccumulatorConfig, Mockito.times(0)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedDailyDigestBatchConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
Mockito.verify(mockedPurgeConfig, Mockito.times(1)).scheduleJobExecution(Mockito.any());
}
use of com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager in project hub-alert by blackducksoftware.
the class DigestItemWriterTest method testWriteNull.
@Test
public void testWriteNull() throws Exception {
final ChannelTemplateManager channelTemplateManager = Mockito.mock(ChannelTemplateManager.class);
Mockito.doThrow(new NullPointerException()).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));
final boolean exceptionThrown = outputLogger.isLineContainingText("Error occurred writing digest notification data to channels");
assertTrue(exceptionThrown);
}
Aggregations