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 e2f2a625ce1 Add YamlConsistencyCheckJobConfigurationSwapperTest 
(#37101)
e2f2a625ce1 is described below

commit e2f2a625ce1e62321a5d597ec4595260c3ff966f
Author: Liang Zhang <[email protected]>
AuthorDate: Fri Nov 14 19:54:25 2025 +0800

    Add YamlConsistencyCheckJobConfigurationSwapperTest (#37101)
---
 AGENTS.md                                          |  5 +-
 ...onsistencyCheckJobConfigurationSwapperTest.java | 95 ++++++++++++++++++++++
 2 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/AGENTS.md b/AGENTS.md
index d4751083f18..518b45d17c4 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -48,9 +48,10 @@ Mention which topology you target, the registry used, and 
any compatibility cons
 ## AI Execution Workflow
 1. **Intake & Clarify** — restate the ask, map affected modules, confirm 
sandbox/approval/network constraints.
    - After clarifying, jot down a “constraint checklist” capturing any 
user-specific rules (forbidden APIs/assertions, output formats, required order 
of operations) plus coverage targets; revisit this list before making edits.
+   - Mirror the checklist in your first substantive reply so every 
user-specific requirement (e.g., “must use `assertThat+is`”) is written down 
verbatim; update the list as scope evolves and explicitly re-check each item 
before the final response.
 2. **Plan & Reason** — write a multi-step plan with checkpoints (analysis, 
edits, tests). Align scope with release tempo (prefer incremental fixes unless 
told otherwise). When the user demands precise branch coverage or “minimum 
test” constraints, first enumerate the target branches and map each to the 
single test case that will cover it before touching code, and reply with that 
list (or test plan) for confirmation before modifying files whenever the user 
explicitly asks for it. If the u [...]
 3. **Implement** — touch only necessary files, reuse abstractions, keep ASF 
headers.
-4. **Validate** — choose the smallest meaningful command, announce the intent 
before execution, summarize exit codes afterward; if blocked (sandbox, missing 
deps), explain what would have run and why it matters.
+4. **Validate** — choose the smallest meaningful command, announce the intent 
before execution, summarize exit codes afterward; if blocked (sandbox, missing 
deps), explain what would have run and why it matters. When edits only touch 
tests or assertions, run the narrowest viable command (e.g., `./mvnw -pl 
<module> -DskipITs -Dspotless.skip=true -Dtest=ClassName test`) before 
rerunning heavier `-am` builds.
 5. **Report** — lead with intent, list edited files with rationale and line 
references, state verification results, propose next actions.
 
 ## Tooling & Verification Matrix
@@ -76,7 +77,7 @@ Mention which topology you target, the registry used, and any 
compatibility cons
 - Static / constructor mocking: prefer `@ExtendWith(AutoMockExtension.class)` 
with `@StaticMockSettings`/`@ConstructionMockSettings`; avoid manual 
`mockStatic`/`mockConstruction`. Ensure the module `pom.xml` has the 
`shardingsphere-test-infra-framework` test dependency before using these 
annotations.
 - For coverage gating, run `./mvnw test jacoco:check@jacoco-check 
-Pcoverage-check` and report results. If code is truly unreachable, cite 
file/line and explain why, noting whether cleanup is recommended.
 - When a request calls for “minimal branch coverage” or “each branch appears 
only once,” list every branch up front, map each to a single test, and 
explicitly document any uncovered branches (file, line, reason) to avoid 
redundant cases.
-- If the user bans specific assertions/tools (e.g., “don’t use 
`assertEquals`”), add that rule to your test plan, avoid the disallowed API 
during implementation, and run a quick search (e.g., `rg assertEquals`) before 
finishing to ensure compliance.
+- If the user bans specific assertions/tools (e.g., “don’t use 
`assertEquals`”), add that rule to your test plan, avoid the disallowed API 
during implementation, and run a quick search (e.g., `rg assertEquals`) before 
finishing to ensure compliance; mention the search command and result in the 
final report.
 
 ### Test Auto-Directives
 When a task requires tests, automatically:
diff --git 
a/kernel/data-pipeline/scenario/consistency-check/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/config/yaml/swapper/YamlConsistencyCheckJobConfigurationSwapperTest.java
 
b/kernel/data-pipeline/scenario/consistency-check/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/config/yaml/swapper/YamlConsistencyCheckJobConfigurationSwapperTest.java
new file mode 100644
index 00000000000..9f92541f1a4
--- /dev/null
+++ 
b/kernel/data-pipeline/scenario/consistency-check/src/test/java/org/apache/shardingsphere/data/pipeline/scenario/consistencycheck/config/yaml/swapper/YamlConsistencyCheckJobConfigurationSwapperTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.scenario.consistencycheck.config.yaml.swapper;
+
+import 
org.apache.shardingsphere.data.pipeline.scenario.consistencycheck.config.ConsistencyCheckJobConfiguration;
+import 
org.apache.shardingsphere.data.pipeline.scenario.consistencycheck.config.yaml.config.YamlConsistencyCheckJobConfiguration;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.apache.shardingsphere.infra.util.props.PropertiesBuilder;
+import org.apache.shardingsphere.infra.util.props.PropertiesBuilder.Property;
+import org.junit.jupiter.api.Test;
+
+import java.util.Properties;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+final class YamlConsistencyCheckJobConfigurationSwapperTest {
+    
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "H2");
+    
+    private final YamlConsistencyCheckJobConfigurationSwapper swapper = new 
YamlConsistencyCheckJobConfigurationSwapper();
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        Properties algorithmProps = PropertiesBuilder.build(new 
Property("chunk-size", "1000"));
+        YamlConsistencyCheckJobConfiguration actual = 
swapper.swapToYamlConfiguration(new ConsistencyCheckJobConfiguration("foo_job", 
"parent_job", "FIXTURE", algorithmProps, databaseType));
+        assertThat(actual.getJobId(), is("foo_job"));
+        assertThat(actual.getParentJobId(), is("parent_job"));
+        assertThat(actual.getAlgorithmTypeName(), is("FIXTURE"));
+        assertThat(actual.getAlgorithmProps(), is(algorithmProps));
+        assertThat(actual.getSourceDatabaseType(), is("H2"));
+    }
+    
+    @Test
+    void assertSwapToYamlConfigurationWithoutSourceDatabaseType() {
+        YamlConsistencyCheckJobConfiguration actual = 
swapper.swapToYamlConfiguration(new ConsistencyCheckJobConfiguration("foo_job", 
"parent_job", "FIXTURE", new Properties(), null));
+        assertThat(actual.getJobId(), is("foo_job"));
+        assertThat(actual.getParentJobId(), is("parent_job"));
+        assertThat(actual.getAlgorithmTypeName(), is("FIXTURE"));
+        assertThat(actual.getAlgorithmProps(), is(new Properties()));
+        assertNull(actual.getSourceDatabaseType());
+    }
+    
+    @Test
+    void assertSwapToObjectFromYamlConfiguration() {
+        YamlConsistencyCheckJobConfiguration yamlConfig = new 
YamlConsistencyCheckJobConfiguration();
+        yamlConfig.setJobId("foo_job");
+        yamlConfig.setParentJobId("parent_job");
+        yamlConfig.setAlgorithmTypeName("FIXTURE");
+        yamlConfig.setAlgorithmProps(new Properties());
+        ConsistencyCheckJobConfiguration actual = 
swapper.swapToObject(yamlConfig);
+        assertThat(actual.getJobId(), is("foo_job"));
+        assertThat(actual.getParentJobId(), is("parent_job"));
+        assertThat(actual.getAlgorithmTypeName(), is("FIXTURE"));
+        assertThat(actual.getSourceDatabaseType(), is(nullValue()));
+    }
+    
+    @Test
+    void assertSwapToObjectFromJobParam() {
+        String jobParam = "jobId: foo_job\n"
+                + "parentJobId: parent_job\n"
+                + "algorithmTypeName: FIXTURE\n"
+                + "algorithmProps:\n"
+                + "  chunk-size: 64\n"
+                + "sourceDatabaseType: H2\n";
+        ConsistencyCheckJobConfiguration actual = 
swapper.swapToObject(jobParam);
+        assertThat(actual.getJobId(), is("foo_job"));
+        assertThat(actual.getParentJobId(), is("parent_job"));
+        assertThat(actual.getAlgorithmTypeName(), is("FIXTURE"));
+        assertThat(actual.getSourceDatabaseType().getType(), is("H2"));
+    }
+    
+    @Test
+    void assertSwapToObjectFromJobParamWithNullJobParam() {
+        assertNull(swapper.swapToObject((String) null));
+    }
+}

Reply via email to