Search in sources :

Example 1 with SchedulingDescriptorKey

use of com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey in project hub-alert by blackducksoftware.

the class PurgeTaskTest method cronExpressionNotDefault.

@Test
public 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_PURGE_DATA_FREQUENCY_DAYS);
    configurationFieldModel.setFieldValue(notDefaultValue);
    configurationModel.put(configurationFieldModel);
    Mockito.when(configurationModelConfigurationAccessor.getConfigurationsByDescriptorKey(Mockito.any(DescriptorKey.class))).thenReturn(List.of(configurationModel));
    PurgeTask task = new PurgeTask(new SchedulingDescriptorKey(), null, null, null, null, configurationModelConfigurationAccessor);
    String cronWithNotDefault = task.scheduleCronExpression();
    String expectedCron = String.format(PurgeTask.CRON_FORMAT, notDefaultValue);
    assertEquals(expectedCron, cronWithNotDefault);
}
Also used : ConfigurationModelMutable(com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable) SchedulingDescriptorKey(com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) SchedulingDescriptorKey(com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) PurgeTask(com.synopsys.integration.alert.component.scheduling.workflow.PurgeTask) Test(org.junit.jupiter.api.Test)

Aggregations

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