Search in sources :

Example 1 with DailyTask

use of com.synopsys.integration.alert.component.scheduling.workflow.DailyTask in project hub-alert by blackducksoftware.

the class DailyTaskTest method testGetTaskName.

@Test
void testGetTaskName() {
    DailyTask task = new DailyTask(SCHEDULING_DESCRIPTOR_KEY, null, null, null, null, null, null);
    assertEquals(ScheduledTask.computeTaskName(task.getClass()), task.getTaskName());
}
Also used : DailyTask(com.synopsys.integration.alert.component.scheduling.workflow.DailyTask) Test(org.junit.jupiter.api.Test)

Example 2 with DailyTask

use of com.synopsys.integration.alert.component.scheduling.workflow.DailyTask 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

DailyTask (com.synopsys.integration.alert.component.scheduling.workflow.DailyTask)2 Test (org.junit.jupiter.api.Test)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 StaticJobAccessor (com.synopsys.integration.alert.database.api.StaticJobAccessor)1 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)1