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.git


The following commit(s) were added to refs/heads/master by this push:
     new be2f73d86d3 Add CDCJobTypeTest (#37114)
be2f73d86d3 is described below

commit be2f73d86d323b02bf0db365cbf5af39354fd80a
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Nov 15 18:02:17 2025 +0800

    Add CDCJobTypeTest (#37114)
    
    * Add CDCJobTypeTest
    
    * Add CDCJobTypeTest
---
 .../data/pipeline/cdc/CDCJobTypeTest.java          | 75 ++++++++++++++++++++++
 1 file changed, 75 insertions(+)

diff --git 
a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobTypeTest.java
 
b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobTypeTest.java
new file mode 100644
index 00000000000..94edac021e5
--- /dev/null
+++ 
b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/CDCJobTypeTest.java
@@ -0,0 +1,75 @@
+/*
+ * 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.data.pipeline.cdc;
+
+import 
org.apache.shardingsphere.data.pipeline.api.type.ShardingSpherePipelineDataSourceConfiguration;
+import org.apache.shardingsphere.data.pipeline.cdc.config.CDCJobConfiguration;
+import 
org.apache.shardingsphere.data.pipeline.cdc.config.yaml.swapper.YamlCDCJobConfigurationSwapper;
+import org.apache.shardingsphere.data.pipeline.core.datanode.JobDataNodeLine;
+import 
org.apache.shardingsphere.data.pipeline.core.job.progress.yaml.swapper.YamlTransmissionJobItemProgressSwapper;
+import org.apache.shardingsphere.data.pipeline.core.job.type.PipelineJobOption;
+import org.apache.shardingsphere.data.pipeline.core.job.type.PipelineJobType;
+import org.apache.shardingsphere.data.pipeline.core.pojo.PipelineJobObjective;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class CDCJobTypeTest {
+    
+    @SuppressWarnings("rawtypes")
+    private final PipelineJobType jobType = 
TypedSPILoader.getService(PipelineJobType.class, "STREAMING");
+    
+    @Test
+    void assertGetOption() {
+        PipelineJobOption actual = jobType.getOption();
+        assertThat(actual.getCode(), is("03"));
+        assertTrue(actual.isTransmissionJob());
+        assertThat(actual.getYamlJobConfigurationSwapper(), 
isA(YamlCDCJobConfigurationSwapper.class));
+        assertThat(actual.getYamlJobItemProgressSwapper(), 
isA(YamlTransmissionJobItemProgressSwapper.class));
+        assertThat(actual.getJobClass(), is(CDCJob.class));
+        
assertFalse(actual.isIgnoreToStartDisabledJobWhenJobItemProgressIsFinished());
+        assertNull(actual.getToBeStartDisabledNextJobType());
+        assertNull(actual.getToBeStoppedPreviousJobType());
+        
assertTrue(actual.isForceNoShardingWhenConvertToJobConfigurationPOJO());
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    void assertGetJobObjective() {
+        CDCJobConfiguration jobConfig = new CDCJobConfiguration("foo_job", 
"foo_db", Arrays.asList("foo_schema.foo_tbl", "bar_schema.bar_tbl"),
+                false, mock(DatabaseType.class), 
mock(ShardingSpherePipelineDataSourceConfiguration.class), 
mock(JobDataNodeLine.class), Collections.emptyList(),
+                false, mock(CDCJobConfiguration.SinkConfiguration.class), 1, 
3);
+        PipelineJobObjective actual = jobType.getJobObjective(jobConfig);
+        assertThat(actual.getDatabaseName(), is("foo_db"));
+        assertThat(actual.getTableName(), is("foo_schema.foo_tbl, 
bar_schema.bar_tbl"));
+    }
+    
+    private static <T> T mock(final Class<T> type) {
+        return org.mockito.Mockito.mock(type);
+    }
+}

Reply via email to