Search in sources :

Example 11 with ConfigurationModelMutable

use of com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable 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

ConfigurationModelMutable (com.synopsys.integration.alert.common.persistence.model.mutable.ConfigurationModelMutable)11 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)7 AlertRuntimeException (com.synopsys.integration.alert.api.common.model.exception.AlertRuntimeException)3 FieldValueEntity (com.synopsys.integration.alert.database.configuration.FieldValueEntity)3 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)3 Test (org.junit.jupiter.api.Test)3 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)2 SchedulingDescriptorKey (com.synopsys.integration.alert.component.scheduling.descriptor.SchedulingDescriptorKey)2 DefinedFieldEntity (com.synopsys.integration.alert.database.configuration.DefinedFieldEntity)2 DescriptorConfigEntity (com.synopsys.integration.alert.database.configuration.DescriptorConfigEntity)2 ArrayList (java.util.ArrayList)2 Gson (com.google.gson.Gson)1 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)1 DailyTask (com.synopsys.integration.alert.component.scheduling.workflow.DailyTask)1 PurgeTask (com.synopsys.integration.alert.component.scheduling.workflow.PurgeTask)1 StaticJobAccessor (com.synopsys.integration.alert.database.api.StaticJobAccessor)1 BlackDuckProperties (com.synopsys.integration.alert.provider.blackduck.BlackDuckProperties)1 MockAlertProperties (com.synopsys.integration.alert.test.common.MockAlertProperties)1 TestProperties (com.synopsys.integration.alert.test.common.TestProperties)1