Search in sources :

Example 1 with TestDataflowJobConfiguration

use of com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class JobExecutorFactoryTest method assertGetJobExecutorTwice.

@Test
public void assertGetJobExecutorTwice() {
    when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "twice_test_job", 10, "", Collections.<Integer, String>emptyMap()));
    when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(false));
    AbstractElasticJobExecutor executor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
    AbstractElasticJobExecutor anotherExecutor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
    assertTrue(executor.hashCode() != anotherExecutor.hashCode());
}
Also used : TestDataflowJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration) TestSimpleJob(com.dangdang.ddframe.job.fixture.job.TestSimpleJob) Test(org.junit.Test)

Example 2 with TestDataflowJobConfiguration

use of com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class JobExecutorFactoryTest method assertGetJobExecutorForDataflowJob.

@Test
public void assertGetJobExecutorForDataflowJob() {
    when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "dataflow_test_job", 10, "", Collections.<Integer, String>emptyMap()));
    when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(false));
    assertThat(JobExecutorFactory.getJobExecutor(new TestDataflowJob(null), jobFacade), instanceOf(DataflowJobExecutor.class));
}
Also used : TestDataflowJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration) DataflowJobExecutor(com.dangdang.ddframe.job.executor.type.DataflowJobExecutor) TestDataflowJob(com.dangdang.ddframe.job.fixture.job.TestDataflowJob) Test(org.junit.Test)

Example 3 with TestDataflowJobConfiguration

use of com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class DataflowJobExecutorTest method setUp.

private void setUp(final boolean isStreamingProcess, final ShardingContexts shardingContexts) {
    this.shardingContexts = shardingContexts;
    when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(isStreamingProcess));
    when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
    dataflowJobExecutor = new DataflowJobExecutor(new TestDataflowJob(jobCaller), jobFacade);
    ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
}
Also used : TestDataflowJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.fixture.job.TestDataflowJob)

Example 4 with TestDataflowJobConfiguration

use of com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class JobConfigurationGsonTypeAdapterTest method assertFromDataflowJobJson.

@Test
public void assertFromDataflowJobJson() {
    TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getDataflowJobJson(IgnoreJobExceptionHandler.class.getCanonicalName()), TestJobRootConfiguration.class);
    TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestDataflowJobConfiguration(true).getTypeConfig());
    assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
}
Also used : TestDataflowJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration) TestJobRootConfiguration(com.dangdang.ddframe.job.fixture.config.TestJobRootConfiguration) Test(org.junit.Test)

Aggregations

TestDataflowJobConfiguration (com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration)4 Test (org.junit.Test)3 TestDataflowJob (com.dangdang.ddframe.job.fixture.job.TestDataflowJob)2 DataflowJobExecutor (com.dangdang.ddframe.job.executor.type.DataflowJobExecutor)1 TestJobRootConfiguration (com.dangdang.ddframe.job.fixture.config.TestJobRootConfiguration)1 TestSimpleJob (com.dangdang.ddframe.job.fixture.job.TestSimpleJob)1