Search in sources :

Example 21 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class ConfigurationServiceTest method assertPersistExistedJobConfiguration.

@Test
public void assertPersistExistedJobConfiguration() throws NoSuchFieldException {
    when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true);
    when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobJson());
    LiteJobConfiguration liteJobConfig = JobConfigurationUtil.createSimpleLiteJobConfiguration(true);
    configService.persist(liteJobConfig);
    verify(jobNodeStorage).replaceJobNode("config", LiteJobConfigurationGsonFactory.toJson(liteJobConfig));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) Test(org.junit.Test)

Example 22 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class ConfigurationServiceTest method assertPersistNewJobConfiguration.

@Test
public void assertPersistNewJobConfiguration() {
    LiteJobConfiguration liteJobConfig = JobConfigurationUtil.createSimpleLiteJobConfiguration();
    configService.persist(liteJobConfig);
    verify(jobNodeStorage).replaceJobNode("config", LiteJobConfigurationGsonFactory.toJson(liteJobConfig));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) Test(org.junit.Test)

Example 23 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class ConfigurationServiceTest method assertLoadDirectly.

@Test
public void assertLoadDirectly() {
    when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(LiteJsonConstants.getJobJson());
    LiteJobConfiguration actual = configService.load(false);
    assertThat(actual.getJobName(), is("test_job"));
    assertThat(actual.getTypeConfig().getCoreConfig().getCron(), is("0/1 * * * * ?"));
    assertThat(actual.getTypeConfig().getCoreConfig().getShardingTotalCount(), is(3));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) Test(org.junit.Test)

Example 24 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobConfigurationGsonFactoryTest method assertToJsonForSimpleJob.

@Test
public void assertToJsonForSimpleJob() {
    LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).misfire(false).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(false).maxTimeDiffSeconds(1000).monitorPort(8888).jobShardingStrategyClass("testClass").disabled(true).overwrite(true).reconcileIntervalMinutes(15).build();
    assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(simpleJobJson));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) SimpleJobConfiguration(com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration) Test(org.junit.Test)

Example 25 with LiteJobConfiguration

use of com.dangdang.ddframe.job.lite.config.LiteJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobConfigurationGsonFactoryTest method assertToJsonForDataflowJob.

@Test
public void assertToJsonForDataflowJob() {
    LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build();
    assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(dataflowJobJson));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Aggregations

LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)30 Test (org.junit.Test)14 JobCoreConfiguration (com.dangdang.ddframe.job.config.JobCoreConfiguration)5 SpringJobScheduler (com.dangdang.ddframe.job.lite.spring.api.SpringJobScheduler)5 ElasticJob (com.dangdang.ddframe.job.api.ElasticJob)4 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)4 SimpleJob (com.dangdang.ddframe.job.api.simple.SimpleJob)3 JobTypeConfiguration (com.dangdang.ddframe.job.config.JobTypeConfiguration)3 JobEventRdbConfiguration (com.dangdang.ddframe.job.event.rdb.JobEventRdbConfiguration)3 ElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener)3 DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)2 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)2 JobNodePath (com.dangdang.ddframe.job.lite.internal.storage.JobNodePath)2 ElasticSimpleJob (com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob)2 PtElasticJobSimpleJob (com.pamirs.attach.plugin.shadowjob.obj.PtElasticJobSimpleJob)2 Map (java.util.Map)2 DataSource (javax.sql.DataSource)2 BeanDefinitionBuilder (org.springframework.beans.factory.support.BeanDefinitionBuilder)2 DefaultListableBeanFactory (org.springframework.beans.factory.support.DefaultListableBeanFactory)2 DataflowJob (com.dangdang.ddframe.job.api.dataflow.DataflowJob)1