use of com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig in project hub-alert by blackducksoftware.
the class StartupManagerTest method testInitializeCronJobs.
@Test
public void testInitializeCronJobs() throws IOException {
final AccumulatorConfig accumulatorConfig = Mockito.mock(AccumulatorConfig.class);
Mockito.doNothing().when(accumulatorConfig).scheduleJobExecution(Mockito.anyString());
Mockito.doReturn(1L).when(accumulatorConfig).getMillisecondsToNextRun();
final DailyDigestBatchConfig dailyDigestBatchConfig = Mockito.mock(DailyDigestBatchConfig.class);
Mockito.doNothing().when(dailyDigestBatchConfig).scheduleJobExecution(Mockito.anyString());
Mockito.doReturn("time").when(dailyDigestBatchConfig).getFormatedNextRunTime();
final PurgeConfig purgeConfig = Mockito.mock(PurgeConfig.class);
Mockito.doNothing().when(purgeConfig).scheduleJobExecution(Mockito.anyString());
Mockito.doReturn("time").when(purgeConfig).getFormatedNextRunTime();
final GlobalSchedulingRepositoryWrapper globalSchedulingRepositoryWrapper = Mockito.mock(GlobalSchedulingRepositoryWrapper.class);
final MockGlobalSchedulingEntity mockGlobalSchedulingEntity = new MockGlobalSchedulingEntity();
final GlobalSchedulingConfigEntity entity = mockGlobalSchedulingEntity.createGlobalEntity();
Mockito.when(globalSchedulingRepositoryWrapper.save(Mockito.any(GlobalSchedulingConfigEntity.class))).thenReturn(entity);
final StartupManager startupManager = new StartupManager(globalSchedulingRepositoryWrapper, null, accumulatorConfig, dailyDigestBatchConfig, purgeConfig);
startupManager.initializeCronJobs();
final String expectedLog = entity.toString();
assertTrue(outputLogger.isLineContainingText(expectedLog));
}
use of com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig 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;
}
use of com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig 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());
}
Aggregations