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/07/04 16:55:00 UTC
[shardingsphere-elasticjob-lite] branch master updated: Remove and
merge useless test fixture (#942)
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 c838158 Remove and merge useless test fixture (#942)
c838158 is described below
commit c838158cd6438626048bcf1b77d2a85aab83422e
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jul 5 00:54:50 2020 +0800
Remove and merge useless test fixture (#942)
* remove useless TestSimpleJob
* remove useless TestDataflowJob
* remove useless ShardingContextsBuilder
* Refactor TaskNode
* remove useless JobConfigurationUtil
---
.../lite/api/job/ShardingContextTest.java | 15 ++++--
.../lite/executor/ElasticJobExecutorTest.java | 38 ++++++++++-----
.../lite/fixture/ShardingContextsBuilder.java | 54 ----------------------
.../elasticjob/lite/fixture/TestDataflowJob.java | 35 --------------
.../elasticjob/lite/fixture/TestSimpleJob.java | 28 -----------
.../elasticjob/lite/fixture/context/TaskNode.java | 13 ++----
.../lite/fixture/util/JobConfigurationUtil.java | 45 ------------------
.../internal/config/ConfigurationServiceTest.java | 19 ++++----
.../lite/internal/setup/SetUpFacadeTest.java | 8 ++--
9 files changed, 55 insertions(+), 200 deletions(-)
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/job/ShardingContextTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/job/ShardingContextTest.java
index 349585b..8fe986b 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/job/ShardingContextTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/api/job/ShardingContextTest.java
@@ -18,9 +18,11 @@
package org.apache.shardingsphere.elasticjob.lite.api.job;
import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
import org.junit.Test;
+import java.util.HashMap;
+import java.util.Map;
+
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@@ -28,7 +30,7 @@ public final class ShardingContextTest {
@Test
public void assertNew() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createShardingContexts();
ShardingContext actual = new ShardingContext(shardingContexts, 1);
assertThat(actual.getJobName(), is(shardingContexts.getJobName()));
assertThat(actual.getTaskId(), is(shardingContexts.getTaskId()));
@@ -40,7 +42,14 @@ public final class ShardingContextTest {
@Test
public void assertToString() {
- assertThat(new ShardingContext(ShardingContextsBuilder.getMultipleShardingContexts(), 1).toString(),
+ assertThat(new ShardingContext(createShardingContexts(), 1).toString(),
is("ShardingContext(jobName=test_job, taskId=fake_task_id, shardingTotalCount=2, jobParameter=, shardingItem=1, shardingParameter=B)"));
}
+
+ private static ShardingContexts createShardingContexts() {
+ Map<Integer, String> map = new HashMap<>(2, 1);
+ map.put(0, "A");
+ map.put(1, "B");
+ return new ShardingContexts("fake_task_id", "test_job", 2, "", map);
+ }
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
index f75cc8f..d848d20 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
@@ -22,7 +22,6 @@ import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironme
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.ClassedFooJobExecutor;
import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.FooJob;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
@@ -33,6 +32,8 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@@ -69,7 +70,7 @@ public final class ElasticJobExecutorTest {
}
private JobConfiguration createJobConfiguration() {
- return JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
+ return JobConfiguration.newBuilder("test_job", 3)
.cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").jobParameter("param").failover(true).misfire(false).jobErrorHandlerType("THROW").description("desc").build();
}
@@ -85,7 +86,7 @@ public final class ElasticJobExecutorTest {
@Test
public void assertExecuteWhenPreviousJobStillRunning() {
- ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", ShardingContextsBuilder.JOB_NAME, 3, "", Collections.emptyMap());
+ ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 3, "", Collections.emptyMap());
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true);
elasticJobExecutor.execute();
@@ -107,12 +108,12 @@ public final class ElasticJobExecutorTest {
@Test(expected = JobSystemException.class)
public void assertExecuteFailureWhenThrowExceptionForSingleShardingItem() {
- assertExecuteFailureWhenThrowException(ShardingContextsBuilder.getSingleShardingContexts());
+ assertExecuteFailureWhenThrowException(createSingleShardingContexts());
}
@Test
public void assertExecuteFailureWhenThrowExceptionForMultipleShardingItems() {
- assertExecuteFailureWhenThrowException(ShardingContextsBuilder.getMultipleShardingContexts());
+ assertExecuteFailureWhenThrowException(createMultipleShardingContexts());
}
private void assertExecuteFailureWhenThrowException(final ShardingContexts shardingContexts) {
@@ -138,12 +139,12 @@ public final class ElasticJobExecutorTest {
@Test
public void assertExecuteSuccessForSingleShardingItems() {
- assertExecuteSuccess(ShardingContextsBuilder.getSingleShardingContexts());
+ assertExecuteSuccess(createSingleShardingContexts());
}
@Test
public void assertExecuteSuccessForMultipleShardingItems() {
- assertExecuteSuccess(ShardingContextsBuilder.getMultipleShardingContexts());
+ assertExecuteSuccess(createMultipleShardingContexts());
}
private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
@@ -157,7 +158,7 @@ public final class ElasticJobExecutorTest {
@Test
public void assertExecuteWithMisfireIsEmpty() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
elasticJobExecutor.execute();
verifyForIsNotMisfire(jobFacade, shardingContexts);
@@ -166,7 +167,7 @@ public final class ElasticJobExecutorTest {
@Test
public void assertExecuteWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
elasticJobExecutor.execute();
verifyForIsNotMisfire(jobFacade, shardingContexts);
@@ -176,7 +177,7 @@ public final class ElasticJobExecutorTest {
@Test
public void assertExecuteWithMisfire() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true, false);
elasticJobExecutor.execute();
@@ -190,7 +191,7 @@ public final class ElasticJobExecutorTest {
@Test(expected = JobSystemException.class)
public void assertBeforeJobExecutedFailure() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
doThrow(RuntimeException.class).when(jobFacade).beforeJobExecuted(shardingContexts);
try {
@@ -202,7 +203,7 @@ public final class ElasticJobExecutorTest {
@Test(expected = JobSystemException.class)
public void assertAfterJobExecutedFailure() {
- ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
+ ShardingContexts shardingContexts = createMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
doThrow(RuntimeException.class).when(jobFacade).afterJobExecuted(shardingContexts);
try {
@@ -212,6 +213,19 @@ public final class ElasticJobExecutorTest {
}
}
+ private ShardingContexts createSingleShardingContexts() {
+ Map<Integer, String> map = new HashMap<>(1, 1);
+ map.put(0, "A");
+ return new ShardingContexts("fake_task_id", "test_job", 1, "", map);
+ }
+
+ private ShardingContexts createMultipleShardingContexts() {
+ Map<Integer, String> map = new HashMap<>(2, 1);
+ map.put(0, "A");
+ map.put(1, "B");
+ return new ShardingContexts("fake_task_id", "test_job", 2, "", map);
+ }
+
private void prepareForIsNotMisfire(final JobFacade jobFacade, final ShardingContexts shardingContexts) {
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/ShardingContextsBuilder.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/ShardingContextsBuilder.java
deleted file mode 100644
index 4b405bc..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/ShardingContextsBuilder.java
+++ /dev/null
@@ -1,54 +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;
-
-import lombok.AccessLevel;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-
-import java.util.HashMap;
-import java.util.Map;
-
-@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
-public final class ShardingContextsBuilder {
-
- public static final String JOB_NAME = "test_job";
-
- /**
- * Get single ShardingContexts.
- *
- * @return ShardingContexts
- */
- public static ShardingContexts getSingleShardingContexts() {
- Map<Integer, String> map = new HashMap<>(1, 1);
- map.put(0, "A");
- return new ShardingContexts("fake_task_id", JOB_NAME, 1, "", map);
- }
-
- /**
- * Get multiple ShardingContexts.
- *
- * @return ShardingContexts
- */
- public static ShardingContexts getMultipleShardingContexts() {
- Map<Integer, String> map = new HashMap<>(2, 1);
- map.put(0, "A");
- map.put(1, "B");
- return new ShardingContexts("fake_task_id", JOB_NAME, 2, "", map);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestDataflowJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestDataflowJob.java
deleted file mode 100644
index 64c4bcd..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestDataflowJob.java
+++ /dev/null
@@ -1,35 +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;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.DataflowJob;
-
-import java.util.List;
-
-public class TestDataflowJob implements DataflowJob {
-
- @Override
- public List fetchData(final ShardingContext shardingContext) {
- return null;
- }
-
- @Override
- public void processData(final ShardingContext shardingContext, final List data) {
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestSimpleJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestSimpleJob.java
deleted file mode 100644
index 12c12f4..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/TestSimpleJob.java
+++ /dev/null
@@ -1,28 +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;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
-
-public class TestSimpleJob implements SimpleJob {
-
- @Override
- public void execute(final ShardingContext shardingContext) {
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/context/TaskNode.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/context/TaskNode.java
index 3f33ec1..eee48d2 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/context/TaskNode.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/context/TaskNode.java
@@ -35,15 +35,6 @@ public final class TaskNode {
private String uuid;
/**
- * Get the path of task node.
- *
- * @return the path of task node
- */
- public String getTaskNodePath() {
- return Joiner.on("@-@").join(null == jobName ? "test_job" : jobName, shardingItem);
- }
-
- /**
* Get the value of task node.
*
* @return the value of task node
@@ -51,4 +42,8 @@ public final class TaskNode {
public String getTaskNodeValue() {
return Joiner.on("@-@").join(getTaskNodePath(), null == type ? ExecutionType.READY : type, null == slaveId ? "slave-S0" : slaveId, null == uuid ? "0" : uuid);
}
+
+ private String getTaskNodePath() {
+ return Joiner.on("@-@").join(null == jobName ? "test_job" : jobName, shardingItem);
+ }
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/util/JobConfigurationUtil.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/util/JobConfigurationUtil.java
deleted file mode 100644
index 0a60f37..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/util/JobConfigurationUtil.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.util;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class JobConfigurationUtil {
-
- /**
- * Create the configuration of simple job.
- *
- * @return job configuration
- */
- public static JobConfiguration createSimpleJobConfiguration() {
- return JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build();
- }
-
- /**
- * Create the configuration of simple job.
- *
- * @param overwrite whether overwrite the config
- * @return job configuration
- */
- public static JobConfiguration createSimpleJobConfiguration(final boolean overwrite) {
- return JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").overwrite(overwrite).build();
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
index 3096b04..c992fcc 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/config/ConfigurationServiceTest.java
@@ -17,12 +17,11 @@
package org.apache.shardingsphere.elasticjob.lite.internal.config;
+import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.fixture.LiteYamlConstants;
-import org.apache.shardingsphere.elasticjob.lite.fixture.TestSimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.fixture.util.JobConfigurationUtil;
import org.apache.shardingsphere.elasticjob.lite.internal.config.yaml.YamlJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.internal.storage.JobNodeStorage;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
@@ -85,7 +84,7 @@ public final class ConfigurationServiceTest {
when(jobNodeStorage.isJobRootNodeExisted()).thenReturn(true);
when(jobNodeStorage.getJobRootNodeData()).thenReturn("org.apache.shardingsphere.elasticjob.lite.api.script.api.ScriptJob");
try {
- configService.setUpJobConfiguration(null, JobConfigurationUtil.createSimpleJobConfiguration());
+ configService.setUpJobConfiguration(null, JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build());
} finally {
verify(jobNodeStorage).isJobRootNodeExisted();
verify(jobNodeStorage).getJobRootNodeData();
@@ -94,16 +93,16 @@ public final class ConfigurationServiceTest {
@Test
public void assertSetUpJobConfigurationNewJobConfiguration() {
- JobConfiguration jobConfig = JobConfigurationUtil.createSimpleJobConfiguration();
- assertThat(configService.setUpJobConfiguration(TestSimpleJob.class.getName(), jobConfig), is(jobConfig));
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build();
+ assertThat(configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig), is(jobConfig));
verify(jobNodeStorage).replaceJobNode("config", YamlEngine.marshal(YamlJobConfiguration.fromJobConfiguration(jobConfig)));
}
@Test
public void assertSetUpJobConfigurationExistedJobConfigurationAndOverwrite() {
when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true);
- JobConfiguration jobConfig = JobConfigurationUtil.createSimpleJobConfiguration(true);
- assertThat(configService.setUpJobConfiguration(TestSimpleJob.class.getName(), jobConfig), is(jobConfig));
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").overwrite(true).build();
+ assertThat(configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig), is(jobConfig));
verify(jobNodeStorage).replaceJobNode("config", YamlEngine.marshal(YamlJobConfiguration.fromJobConfiguration(jobConfig)));
}
@@ -111,9 +110,9 @@ public final class ConfigurationServiceTest {
public void assertSetUpJobConfigurationExistedJobConfigurationAndNotOverwrite() {
when(jobNodeStorage.isJobNodeExisted(ConfigurationNode.ROOT)).thenReturn(true);
when(jobNodeStorage.getJobNodeDataDirectly(ConfigurationNode.ROOT)).thenReturn(
- YamlEngine.marshal(YamlJobConfiguration.fromJobConfiguration(JobConfigurationUtil.createSimpleJobConfiguration())));
- JobConfiguration jobConfig = JobConfigurationUtil.createSimpleJobConfiguration(false);
- JobConfiguration actual = configService.setUpJobConfiguration(TestSimpleJob.class.getName(), jobConfig);
+ YamlEngine.marshal(YamlJobConfiguration.fromJobConfiguration(JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").build())));
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3).cron("0/1 * * * * ?").overwrite(false).build();
+ JobConfiguration actual = configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig);
assertThat(actual, not(jobConfig));
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java
index c7f9110..85c94e0 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/internal/setup/SetUpFacadeTest.java
@@ -17,9 +17,9 @@
package org.apache.shardingsphere.elasticjob.lite.internal.setup;
+import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.type.impl.DataflowJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.fixture.TestDataflowJob;
import org.apache.shardingsphere.elasticjob.lite.handler.sharding.JobInstance;
import org.apache.shardingsphere.elasticjob.lite.internal.config.ConfigurationService;
import org.apache.shardingsphere.elasticjob.lite.internal.election.LeaderService;
@@ -86,9 +86,9 @@ public final class SetUpFacadeTest {
public void assertSetUpJobConfiguration() {
JobConfiguration jobConfig = JobConfiguration.newBuilder("test_job", 3)
.cron("0/1 * * * * ?").setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.TRUE.toString()).build();
- when(configService.setUpJobConfiguration(TestDataflowJob.class.getName(), jobConfig)).thenReturn(jobConfig);
- assertThat(setUpFacade.setUpJobConfiguration(TestDataflowJob.class.getName(), jobConfig), is(jobConfig));
- verify(configService).setUpJobConfiguration(TestDataflowJob.class.getName(), jobConfig);
+ when(configService.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig)).thenReturn(jobConfig);
+ assertThat(setUpFacade.setUpJobConfiguration(ElasticJob.class.getName(), jobConfig), is(jobConfig));
+ verify(configService).setUpJobConfiguration(ElasticJob.class.getName(), jobConfig);
}
@Test