Search in sources :

Example 1 with MockGlobalSchedulingEntity

use of com.blackducksoftware.integration.hub.alert.scheduling.mock.MockGlobalSchedulingEntity 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)

Aggregations

AccumulatorConfig (com.blackducksoftware.integration.hub.alert.config.AccumulatorConfig)1 DailyDigestBatchConfig (com.blackducksoftware.integration.hub.alert.config.DailyDigestBatchConfig)1 PurgeConfig (com.blackducksoftware.integration.hub.alert.config.PurgeConfig)1 MockGlobalSchedulingEntity (com.blackducksoftware.integration.hub.alert.scheduling.mock.MockGlobalSchedulingEntity)1 GlobalSchedulingConfigEntity (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingConfigEntity)1 GlobalSchedulingRepositoryWrapper (com.blackducksoftware.integration.hub.alert.scheduling.repository.global.GlobalSchedulingRepositoryWrapper)1 Test (org.junit.Test)1