Search in sources :

Example 6 with ChannelTemplateManager

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());
}
Also used : NotificationRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper) AccumulatorConfig(com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig) GlobalSchedulingRepositoryWrapper(com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) NotificationManager(com.blackducksoftware.integration.hub.alert.NotificationManager) ObjectTransformer(com.blackducksoftware.integration.hub.alert.web.ObjectTransformer) PurgeConfig(com.blackducksoftware.integration.hub.alert.config.PurgeConfig) DailyDigestBatchConfig(com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig) VulnerabilityRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)

Example 7 with ChannelTemplateManager

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);
}
Also used : ChannelTemplateManager(com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager) AbstractChannelEvent(com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent) Test(org.junit.Test)

Aggregations

ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)7 Test (org.junit.Test)5 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)3 AccumulatorConfig (com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig)2 DailyDigestBatchConfig (com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig)2 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)2 PurgeConfig (com.blackducksoftware.integration.hub.alert.config.PurgeConfig)2 NotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper)2 VulnerabilityRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)2 NotificationEventManager (com.blackducksoftware.integration.hub.alert.digest.filter.NotificationEventManager)2 ProjectDataFactory (com.blackducksoftware.integration.hub.alert.digest.model.ProjectDataFactory)2 AbstractChannelEvent (com.blackducksoftware.integration.hub.alert.event.AbstractChannelEvent)2 RealTimeEvent (com.blackducksoftware.integration.hub.alert.event.RealTimeEvent)2 NotificationModel (com.blackducksoftware.integration.hub.alert.hub.model.NotificationModel)2 MockNotificationEntity (com.blackducksoftware.integration.hub.alert.mock.entity.MockNotificationEntity)2 GlobalSchedulingRepositoryWrapper (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper)2 Gson (com.google.gson.Gson)2 OutputLogger (com.blackducksoftware.integration.hub.alert.OutputLogger)1 DBStoreEvent (com.blackducksoftware.integration.hub.alert.event.DBStoreEvent)1 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)1