Search in sources :

Example 6 with StaticJobAccessor

use of com.synopsys.integration.alert.database.api.StaticJobAccessor in project hub-alert by blackducksoftware.

the class DailyTaskTest method cronExpressionNotDefault.

@Test
void cronExpressionNotDefault() {
    final String notDefaultValue = "44";
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    ConfigurationModelMutable configurationModel = new ConfigurationModelMutable(1L, 1L, null, null, ConfigContextEnum.GLOBAL);
    ConfigurationFieldModel configurationFieldModel = ConfigurationFieldModel.create(SchedulingDescriptor.KEY_DAILY_PROCESSOR_HOUR_OF_DAY);
    configurationFieldModel.setFieldValue(notDefaultValue);
    configurationModel.put(configurationFieldModel);
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
    StaticJobAccessor jobAccessor = Mockito.mock(StaticJobAccessor.class);
    Mockito.when(jobAccessor.hasJobsByFrequency(Mockito.any())).thenReturn(true);
    DailyTask task = new DailyTask(SCHEDULING_DESCRIPTOR_KEY, null, null, null, null, configurationModelConfigurationAccessor, jobAccessor);
    String cronWithNotDefault = task.scheduleCronExpression();
    String expectedCron = String.format(DailyTask.CRON_FORMAT, notDefaultValue);
    assertEquals(expectedCron, cronWithNotDefault);
}
Also used : ConfigurationModelMutable(com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DailyTask(com.synopsys.integration.alert.component.scheduling.workflow.DailyTask) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) SchedulingDescriptorKey(com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey) StaticJobAccessor(com.synopsys.integration.alert.database.api.StaticJobAccessor) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) Test(org.junit.jupiter.api.Test)

Aggregations

StaticJobAccessor (com.synopsys.integration.alert.database.api.StaticJobAccessor)6 Test (org.junit.jupiter.api.Test)6 TaskManager (com.synopsys.integration.alert.api.task.TaskManager)5 DefaultNotificationAccessor (com.synopsys.integration.alert.database.api.DefaultNotificationAccessor)5 NotificationProcessor (com.synopsys.integration.alert.processor.api.NotificationProcessor)5 NotificationDetailExtractionDelegator (com.synopsys.integration.alert.processor.api.detail.NotificationDetailExtractionDelegator)5 TaskScheduler (org.springframework.scheduling.TaskScheduler)5 DateRange (com.synopsys.integration.alert.common.message.model.DateRange)4 NotificationAccessor (com.synopsys.integration.alert.common.persistence.accessor.NotificationAccessor)4 AlertNotificationModel (com.synopsys.integration.alert.common.rest.model.AlertNotificationModel)4 ArrayList (java.util.ArrayList)2 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)1 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)1 ConfigurationModelMutable (com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable)1 SchedulingDescriptorKey (com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey)1 DailyTask (com.synopsys.integration.alert.component.scheduling.workflow.DailyTask)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1 FilteredJobNotificationWrapper (com.synopsys.integration.alert.processor.api.filter.FilteredJobNotificationWrapper)1 JobNotificationMapper (com.synopsys.integration.alert.processor.api.filter.JobNotificationMapper)1 PageRetriever (com.synopsys.integration.alert.processor.api.filter.PageRetriever)1