Search in sources :

Example 1 with GlobalSchedulingRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper 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));
}
Also used : AccumulatorConfig(com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig) MockGlobalSchedulingEntity(com.blackducksoftware.integration.hub.alert.scheduling.mock.MockGlobalSchedulingEntity) GlobalSchedulingRepositoryWrapper(com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper) GlobalSchedulingConfigEntity(com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingConfigEntity) PurgeConfig(com.blackducksoftware.integration.hub.alert.config.PurgeConfig) DailyDigestBatchConfig(com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig) Test(org.junit.Test)

Example 2 with GlobalSchedulingRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper 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;
}
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) 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 3 with GlobalSchedulingRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper 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)

Aggregations

AccumulatorConfig (com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig)3 DailyDigestBatchConfig (com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig)3 PurgeConfig (com.blackducksoftware.integration.hub.alert.config.PurgeConfig)3 GlobalSchedulingRepositoryWrapper (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper)3 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)2 ChannelTemplateManager (com.blackducksoftware.integration.hub.alert.channel.ChannelTemplateManager)2 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)2 NotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationRepositoryWrapper)2 VulnerabilityRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.VulnerabilityRepositoryWrapper)2 MockGlobalSchedulingEntity (com.blackducksoftware.integration.hub.alert.scheduling.mock.MockGlobalSchedulingEntity)1 GlobalSchedulingConfigEntity (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingConfigEntity)1 ObjectTransformer (com.blackducksoftware.integration.hub.alert.web.ObjectTransformer)1 Test (org.junit.Test)1