You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/06/26 15:39:46 UTC
[shardingsphere-elasticjob-lite] branch master updated: Remove
unreasonable test fixture implementation of JobRootConfiguration (#846)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new bb94441 Remove unreasonable test fixture implementation of JobRootConfiguration (#846)
bb94441 is described below
commit bb9444154989e8f9dfdd4a8ce5756f5c8ba3e334
Author: Liang Zhang <te...@163.com>
AuthorDate: Fri Jun 26 23:39:36 2020 +0800
Remove unreasonable test fixture implementation of JobRootConfiguration (#846)
* Remove JobConfigurationGsonTypeAdapterTest
* Remove TestJobRootConfiguration
* Remove TestScriptJobConfiguration
* Remove TestSimpleJobConfiguration
* Remove TestDataflowJobConfiguration
---
.../config/LiteJobConfigurationGsonFactory.java | 2 +-
.../type/impl/DataflowJobExecutorTest.java | 8 +-
.../executor/type/impl/ScriptJobExecutorTest.java | 15 +++-
.../executor/type/impl/SimpleJobExecutorTest.java | 16 +++-
.../executor/type/impl/WrongJobExecutorTest.java | 15 +++-
.../config/TestDataflowJobConfiguration.java | 36 --------
.../fixture/config/TestJobRootConfiguration.java | 33 --------
.../fixture/config/TestScriptJobConfiguration.java | 39 ---------
.../fixture/config/TestSimpleJobConfiguration.java | 45 ----------
.../json/JobConfigurationGsonTypeAdapterTest.java | 96 ----------------------
10 files changed, 42 insertions(+), 263 deletions(-)
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/LiteJobConfigurationGsonFactory.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/LiteJobConfigurationGsonFactory.java
index 2d44228..f339a64 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/LiteJobConfigurationGsonFactory.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/LiteJobConfigurationGsonFactory.java
@@ -72,7 +72,7 @@ public final class LiteJobConfigurationGsonFactory {
/**
* Job configuration gson type adapter.
*/
- static final class LiteJobConfigurationGsonTypeAdapter extends AbstractJobConfigurationGsonTypeAdapter<LiteJobConfiguration> {
+ public static final class LiteJobConfigurationGsonTypeAdapter extends AbstractJobConfigurationGsonTypeAdapter<LiteJobConfiguration> {
@Override
protected void addToCustomizedValueMap(final String jsonName, final JsonReader in, final Map<String, Object> customizedValueMap) throws IOException {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
index febc1a7..1fea4a9 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
@@ -17,11 +17,13 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
+import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestDataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.fixture.job.JobCaller;
import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestDataflowJob;
import org.junit.After;
@@ -169,7 +171,9 @@ public final class DataflowJobExecutorTest {
private void setUp(final boolean isStreamingProcess, final ShardingContexts shardingContexts) {
this.shardingContexts = shardingContexts;
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(isStreamingProcess));
+ LiteJobConfiguration liteJobConfig = LiteJobConfiguration.newBuilder(
+ new DataflowJobConfiguration(JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).jobErrorHandlerType("IGNORE").build(), isStreamingProcess)).build();
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(liteJobConfig);
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
elasticJobExecutor = new ElasticJobExecutor(new TestDataflowJob(jobCaller), jobFacade);
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
index 5d9efe6..7963e25 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
@@ -17,12 +17,14 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
+import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.script.ScriptJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestScriptJobConfiguration;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -42,7 +44,7 @@ public final class ScriptJobExecutorTest {
@Test
public void assertExecuteWhenCommandLineIsEmpty() {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("", "IGNORE"));
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration("", "IGNORE"));
elasticJobExecutor = new ElasticJobExecutor(null, jobFacade);
elasticJobExecutor.execute();
}
@@ -59,7 +61,7 @@ public final class ScriptJobExecutorTest {
private void assertExecuteWhenExecuteFailure(final ShardingContexts shardingContexts) {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("not_exists_file", "THROW"));
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration("not_exists_file", "THROW"));
elasticJobExecutor = new ElasticJobExecutor(null, jobFacade);
elasticJobExecutor.execute();
}
@@ -76,9 +78,14 @@ public final class ScriptJobExecutorTest {
private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("exists_file param0 param1", "IGNORE"));
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration("exists_file param0 param1", "IGNORE"));
elasticJobExecutor = new ElasticJobExecutor(null, jobFacade);
elasticJobExecutor.execute();
verify(jobFacade).loadJobRootConfiguration(true);
}
+
+ private LiteJobConfiguration createLiteJobConfiguration(final String scriptCommandLine, final String jobErrorHandlerType) {
+ return LiteJobConfiguration.newBuilder(new ScriptJobConfiguration(
+ JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).jobErrorHandlerType(jobErrorHandlerType).build(), scriptCommandLine)).build();
+ }
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
index f0c03fc..5e3bc84 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
@@ -17,18 +17,20 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestSimpleJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.fixture.job.JobCaller;
import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestSimpleJob;
import org.apache.shardingsphere.elasticjob.lite.handler.error.impl.LogJobErrorHandler;
import org.apache.shardingsphere.elasticjob.lite.handler.threadpool.impl.CPUUsageJobExecutorServiceHandler;
+import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
import org.junit.Before;
import org.junit.Test;
@@ -58,13 +60,19 @@ public final class SimpleJobExecutorTest {
@Before
public void setUp() {
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration(null, "THROW"));
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration(null, "THROW"));
elasticJobExecutor = new ElasticJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
}
+ private LiteJobConfiguration createLiteJobConfiguration(final String jobExecutorServiceHandlerType, final String jobErrorHandlerType) {
+ return LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(
+ JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").jobParameter("param")
+ .failover(true).misfire(false).jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).jobErrorHandlerType(jobErrorHandlerType).description("desc").build())).build();
+ }
+
@Test
public void assertNewExecutorWithDefaultHandlers() {
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration(null, null));
elasticJobExecutor = new ElasticJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "executorService"), instanceOf(new CPUUsageJobExecutorServiceHandler().createExecutorService("test_job").getClass()));
assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "jobErrorHandler"), instanceOf(LogJobErrorHandler.class));
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
index 9291752..31657c9 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
@@ -17,12 +17,15 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
+import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.LiteJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestSimpleJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestWrongJob;
+import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,10 +48,16 @@ public final class WrongJobExecutorTest {
@Before
public void setUp() {
- when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration(null, "THROW"));
+ when(jobFacade.loadJobRootConfiguration(true)).thenReturn(createLiteJobConfiguration());
wrongJobExecutor = new ElasticJobExecutor(new TestWrongJob(), jobFacade);
}
+ private LiteJobConfiguration createLiteJobConfiguration() {
+ return LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(
+ JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").jobParameter("param")
+ .failover(true).misfire(false).jobExecutorServiceHandlerType(null).jobErrorHandlerType("THROW").description("desc").build())).build();
+ }
+
@Test(expected = RuntimeException.class)
public void assertWrongJobExecutorWithSingleItem() {
Map<Integer, String> map = new HashMap<>(1, 1);
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestDataflowJobConfiguration.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestDataflowJobConfiguration.java
deleted file mode 100644
index 4b26174..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestDataflowJobConfiguration.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.config;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobRootConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-
-@RequiredArgsConstructor
-public final class TestDataflowJobConfiguration implements JobRootConfiguration {
-
- private final boolean streamingProcess;
-
- @Override
- public JobTypeConfiguration getTypeConfig() {
- return new DataflowJobConfiguration(JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).jobErrorHandlerType("IGNORE").build(), streamingProcess);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestJobRootConfiguration.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestJobRootConfiguration.java
deleted file mode 100644
index 69760c5..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestJobRootConfiguration.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.config;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.config.JobRootConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-
-@RequiredArgsConstructor
-public final class TestJobRootConfiguration implements JobRootConfiguration {
-
- private final JobTypeConfiguration typeConfig;
-
- @Override
- public JobTypeConfiguration getTypeConfig() {
- return typeConfig;
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestScriptJobConfiguration.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestScriptJobConfiguration.java
deleted file mode 100644
index 8f8c8ba..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestScriptJobConfiguration.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.config;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobRootConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.script.ScriptJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-
-@RequiredArgsConstructor
-public final class TestScriptJobConfiguration implements JobRootConfiguration {
-
- private final String scriptCommandLine;
-
- private final String jobErrorHandlerType;
-
- @Override
- public JobTypeConfiguration getTypeConfig() {
- return new ScriptJobConfiguration(
- JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3).jobErrorHandlerType(jobErrorHandlerType).build(), scriptCommandLine);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestSimpleJobConfiguration.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestSimpleJobConfiguration.java
deleted file mode 100644
index 0720612..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/config/TestSimpleJobConfiguration.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.config;
-
-import lombok.AllArgsConstructor;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration.Builder;
-import org.apache.shardingsphere.elasticjob.lite.config.JobRootConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-
-@AllArgsConstructor
-@NoArgsConstructor
-public final class TestSimpleJobConfiguration implements JobRootConfiguration {
-
- private String jobExecutorServiceHandlerType;
-
- private String jobErrorHandlerType;
-
- @Override
- public JobTypeConfiguration getTypeConfig() {
- Builder builder = JobCoreConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, "0/1 * * * * ?", 3)
- .shardingItemParameters("0=A,1=B,2=C").jobParameter("param").failover(true).misfire(false).description("desc");
- builder.jobExecutorServiceHandlerType(jobExecutorServiceHandlerType);
- builder.jobErrorHandlerType(jobErrorHandlerType);
- return new SimpleJobConfiguration(builder.build());
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/json/JobConfigurationGsonTypeAdapterTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/json/JobConfigurationGsonTypeAdapterTest.java
deleted file mode 100644
index deeda78..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/util/json/JobConfigurationGsonTypeAdapterTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.util.json;
-
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.APIJsonConstants;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestDataflowJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestJobRootConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestScriptJobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.fixture.config.TestSimpleJobConfiguration;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public final class JobConfigurationGsonTypeAdapterTest {
-
- @BeforeClass
- public static void setUp() {
- GsonFactory.registerTypeAdapter(TestJobRootConfiguration.class, new JobConfigurationGsonTypeAdapter());
- }
-
- @Test
- public void assertToSimpleJobJson() {
- System.out.println(GsonFactory.getGson().toJson(new TestJobRootConfiguration(new TestSimpleJobConfiguration(null, "LOG").getTypeConfig())));
- assertThat(GsonFactory.getGson().toJson(new TestJobRootConfiguration(new TestSimpleJobConfiguration(null, "LOG").getTypeConfig())), is(APIJsonConstants.getSimpleJobJson("LOG")));
- }
-
- @Test
- public void assertToDataflowJobJson() {
- assertThat(GsonFactory.getGson().toJson(new TestJobRootConfiguration(new TestDataflowJobConfiguration(true).getTypeConfig())),
- is(APIJsonConstants.getDataflowJobJson("IGNORE")));
- }
-
- @Test
- public void assertToScriptJobJson() {
- assertThat(GsonFactory.getGson().toJson(new TestJobRootConfiguration(new TestScriptJobConfiguration("test.sh", "THROW").getTypeConfig())), is(APIJsonConstants.getScriptJobJson("THROW")));
- }
-
- @Test
- public void assertFromSimpleJobJson() {
- TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getSimpleJobJson("THROW"), TestJobRootConfiguration.class);
- TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestSimpleJobConfiguration(null, "THROW").getTypeConfig());
- assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
- }
-
- @Test
- public void assertFromDataflowJobJson() {
- TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getDataflowJobJson("IGNORE"), TestJobRootConfiguration.class);
- TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestDataflowJobConfiguration(true).getTypeConfig());
- assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
- }
-
- @Test
- public void assertFromScriptJobJson() {
- TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getScriptJobJson("THROW"), TestJobRootConfiguration.class);
- TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestScriptJobConfiguration("test.sh", "THROW").getTypeConfig());
- assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
- }
-
- private static class JobConfigurationGsonTypeAdapter extends AbstractJobConfigurationGsonTypeAdapter<TestJobRootConfiguration> {
-
- @Override
- protected void addToCustomizedValueMap(final String jsonName, final JsonReader in, final Map<String, Object> customizedValueMap) {
- }
-
- @Override
- protected TestJobRootConfiguration getJobRootConfiguration(final JobTypeConfiguration typeConfig, final Map<String, Object> customizedValueMap) {
- return new TestJobRootConfiguration(typeConfig);
- }
-
- @Override
- protected void writeCustomized(final JsonWriter out, final TestJobRootConfiguration value) {
- }
- }
-}