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 11247e745f2 Refactor YamlRuleConfigurationUnmarshalIT (#33031)
11247e745f2 is described below

commit 11247e745f2e4f1cdd8ff397d1458996df5a728f
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Sep 28 00:50:31 2024 +0800

    Refactor YamlRuleConfigurationUnmarshalIT (#33031)
    
    * Revise #33024
    
    * Revise #33024
    
    * Refactor YamlRuleConfigurationUnmarshalIT
    
    * Refactor YamlRuleConfigurationUnmarshalIT
    
    * Refactor YamlRuleConfigurationUnmarshalIT
    
    * Refactor YamlRuleConfigurationUnmarshalIT
    
    * Refactor YamlRuleConfigurationUnmarshalIT
    
    * Refactor YamlRuleConfigurationUnmarshalIT
---
 .../BroadcastRuleConfigurationYamlUnmarshalIT.java |  21 +---
 .../EncryptRuleConfigurationYamlUnmarshalIT.java   |  30 +++++-
 .../it/MaskRuleConfigurationYamlUnmarshalIT.java   |  30 +++++-
 ...eSplittingRuleConfigurationYamlUnmarshalIT.java |  28 ++++-
 .../datasource/ShadowDataSourceConfiguration.java  |   2 +-
 .../it/ShadowRuleConfigurationYamlUnmarshalIT.java | 117 +++++----------------
 ...onfigurationRepositoryTupleSwapperEngineIT.java |   2 +-
 .../ShardingRuleConfigurationYamlUnmarshalIT.java  |  86 +++++++++++----
 ...ding-rule.yaml => sharding-rule-for-tuple.yaml} |   8 +-
 .../src/test/resources/yaml/sharding-rule.yaml     |   7 +-
 .../YamlRuleConfigurationSwapperFixture.java       |   2 +-
 .../AuthorityRuleConfigurationYamlUnmarshalIT.java |  59 ++---------
 .../src/test/resources/yaml/authority-rule.yaml    |   2 +-
 ...lobalClockRuleConfigurationYamlUnmarshalIT.java |  25 +----
 .../LoggingRuleConfigurationYamlUnmarshalIT.java   |  50 +++------
 .../YamlLoggingRuleConfigurationSwapperTest.java   |  65 ------------
 .../YamlRuleConfigurationSwapperFixture.java       |   2 +-
 .../it/SingleRuleConfigurationYamlUnmarshalIT.java |  23 ++--
 ...FederationRuleConfigurationYamlUnmarshalIT.java |  27 +----
 .../SQLParserRuleConfigurationYamlUnmarshalIT.java |  30 +-----
 .../src/test/resources/yaml/sql-parser-rule.yaml   |   6 +-
 kernel/sql-translator/core/pom.xml                 |   6 ++
 ...TranslatorRuleConfigurationYamlUnmarshalIT.java |  24 +----
 .../test/resources/yaml/sql-translator-rule.yaml   |   2 +-
 kernel/transaction/core/pom.xml                    |   6 ++
 ...ransactionRuleConfigurationYamlUnmarshalIT.java |  23 +---
 .../it/yaml/YamlRuleConfigurationUnmarshalIT.java  |  62 ++++++++---
 .../test/util/PropertiesBuilder.java               |   9 +-
 28 files changed, 303 insertions(+), 451 deletions(-)

diff --git 
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationYamlUnmarshalIT.java
 
b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationYamlUnmarshalIT.java
index ff9581c81bf..b094610c528 100644
--- 
a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationYamlUnmarshalIT.java
@@ -17,29 +17,14 @@
 
 package org.apache.shardingsphere.broadcast.it;
 
-import 
org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import org.apache.shardingsphere.broadcast.config.BroadcastRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import java.util.ArrayList;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import java.util.Arrays;
 
 class BroadcastRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     BroadcastRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/broadcast-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertBroadcastRule((YamlBroadcastRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertBroadcastRule(final YamlBroadcastRuleConfiguration 
actual) {
-        assertThat(actual.getTables().size(), is(2));
-        assertThat(new ArrayList<>(actual.getTables()).get(0), is("foo_tbl"));
-        assertThat(new ArrayList<>(actual.getTables()).get(1), is("bar_tbl"));
+        super("yaml/broadcast-rule.yaml", new 
BroadcastRuleConfiguration(Arrays.asList("foo_tbl", "bar_tbl")));
     }
 }
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptRuleConfigurationYamlUnmarshalIT.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptRuleConfigurationYamlUnmarshalIT.java
index 9febe3baf68..a9253981b5f 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptRuleConfigurationYamlUnmarshalIT.java
@@ -17,12 +17,22 @@
 
 package org.apache.shardingsphere.encrypt.it;
 
+import org.apache.shardingsphere.encrypt.config.EncryptRuleConfiguration;
+import 
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnItemRuleConfiguration;
+import 
org.apache.shardingsphere.encrypt.config.rule.EncryptColumnRuleConfiguration;
+import 
org.apache.shardingsphere.encrypt.config.rule.EncryptTableRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
 import 
org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -31,12 +41,24 @@ import static org.hamcrest.MatcherAssert.assertThat;
 class EncryptRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     EncryptRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/encrypt-rule.yaml");
+        super("yaml/encrypt-rule.yaml", getExpectedRuleConfiguration());
+    }
+    
+    private static EncryptRuleConfiguration getExpectedRuleConfiguration() {
+        EncryptColumnRuleConfiguration encryptColumnRuleConfig = new 
EncryptColumnRuleConfiguration("username",
+                new EncryptColumnItemRuleConfiguration("username_cipher", 
"aes_encryptor"));
+        encryptColumnRuleConfig.setAssistedQuery(new 
EncryptColumnItemRuleConfiguration("assisted_query_username", 
"assisted_encryptor"));
+        Collection<EncryptTableRuleConfiguration> tables = 
Collections.singletonList(new EncryptTableRuleConfiguration("t_user", 
Collections.singletonList(encryptColumnRuleConfig)));
+        Map<String, AlgorithmConfiguration> encryptors = new 
LinkedHashMap<>(2, 1F);
+        encryptors.put("aes_encryptor", new AlgorithmConfiguration("AES", 
PropertiesBuilder.build(new Property("aes-key-value", "123456abc"), new 
Property("digest-algorithm-name", "SHA-1"))));
+        encryptors.put("assisted_encryptor", new AlgorithmConfiguration("AES", 
PropertiesBuilder.build(new Property("aes-key-value", "123456abc"), new 
Property("digest-algorithm-name", "SHA-1"))));
+        return new EncryptRuleConfiguration(tables, encryptors);
     }
     
     @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertEncryptRule((YamlEncryptRuleConfiguration) 
actual.getRules().iterator().next());
+    protected boolean assertYamlConfiguration(final YamlRuleConfiguration 
actual) {
+        assertEncryptRule((YamlEncryptRuleConfiguration) actual);
+        return true;
     }
     
     private void assertEncryptRule(final YamlEncryptRuleConfiguration actual) {
diff --git 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskRuleConfigurationYamlUnmarshalIT.java
 
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskRuleConfigurationYamlUnmarshalIT.java
index c4a22dd880c..7ba93af6f62 100644
--- 
a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskRuleConfigurationYamlUnmarshalIT.java
@@ -17,13 +17,24 @@
 
 package org.apache.shardingsphere.mask.it;
 
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
 import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.mask.config.MaskRuleConfiguration;
+import org.apache.shardingsphere.mask.config.rule.MaskColumnRuleConfiguration;
+import org.apache.shardingsphere.mask.config.rule.MaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
 import 
org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -32,12 +43,23 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 class MaskRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     MaskRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/mask-rule.yaml");
+        super("yaml/mask-rule.yaml", getExpectedRuleConfiguration());
+    }
+    
+    private static MaskRuleConfiguration getExpectedRuleConfiguration() {
+        Collection<MaskTableRuleConfiguration> tables = 
Collections.singletonList(new MaskTableRuleConfiguration("t_user",
+                Arrays.asList(new MaskColumnRuleConfiguration("telephone", 
"keep_first_n_last_m_mask"), new MaskColumnRuleConfiguration("password", 
"md5_mask"))));
+        Map<String, AlgorithmConfiguration> maskAlgorithms = new 
LinkedHashMap<>(2, 1F);
+        maskAlgorithms.put("keep_first_n_last_m_mask",
+                new AlgorithmConfiguration("KEEP_FIRST_N_LAST_M", 
PropertiesBuilder.build(new Property("first-n", 3), new 
Property("replace-char", "*"), new Property("last-m", 4))));
+        maskAlgorithms.put("md5_mask", new AlgorithmConfiguration("MD5", new 
Properties()));
+        return new MaskRuleConfiguration(tables, maskAlgorithms);
     }
     
     @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertMaskRule((YamlMaskRuleConfiguration) 
actual.getRules().iterator().next());
+    protected boolean assertYamlConfiguration(final YamlRuleConfiguration 
actual) {
+        assertMaskRule((YamlMaskRuleConfiguration) actual);
+        return true;
     }
     
     private void assertMaskRule(final YamlMaskRuleConfiguration actual) {
diff --git 
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingRuleConfigurationYamlUnmarshalIT.java
 
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingRuleConfigurationYamlUnmarshalIT.java
index 9fd07c530da..100826bef05 100644
--- 
a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingRuleConfigurationYamlUnmarshalIT.java
@@ -17,22 +17,42 @@
 
 package org.apache.shardingsphere.readwritesplitting.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.readwritesplitting.config.ReadwriteSplittingRuleConfiguration;
+import 
org.apache.shardingsphere.readwritesplitting.config.rule.ReadwriteSplittingDataSourceGroupRuleConfiguration;
 import 
org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 
 class ReadwriteSplittingRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     ReadwriteSplittingRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/readwrite-splitting-rule.yaml");
+        super("yaml/readwrite-splitting-rule.yaml", 
getExpectedRuleConfiguration());
+    }
+    
+    private static ReadwriteSplittingRuleConfiguration 
getExpectedRuleConfiguration() {
+        Collection<ReadwriteSplittingDataSourceGroupRuleConfiguration> 
dataSourceGroups = Arrays.asList(
+                new ReadwriteSplittingDataSourceGroupRuleConfiguration("ds_0", 
"write_ds_0", Arrays.asList("write_ds_0_read_0", "write_ds_0_read_1"), 
"roundRobin"),
+                new ReadwriteSplittingDataSourceGroupRuleConfiguration("ds_1", 
"write_ds_1", Arrays.asList("write_ds_1_read_0", "write_ds_1_read_1"), 
"random"));
+        Map<String, AlgorithmConfiguration> loadBalancers = new 
LinkedHashMap<>(2, 1F);
+        loadBalancers.put("random", new AlgorithmConfiguration("RANDOM", new 
Properties()));
+        loadBalancers.put("roundRobin", new 
AlgorithmConfiguration("ROUND_ROBIN", new Properties()));
+        return new ReadwriteSplittingRuleConfiguration(dataSourceGroups, 
loadBalancers);
     }
     
     @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertReadwriteSplittingRule((YamlReadwriteSplittingRuleConfiguration) 
actual.getRules().iterator().next());
+    protected boolean assertYamlConfiguration(final YamlRuleConfiguration 
actual) {
+        assertReadwriteSplittingRule((YamlReadwriteSplittingRuleConfiguration) 
actual);
+        return true;
     }
     
     private void assertReadwriteSplittingRule(final 
YamlReadwriteSplittingRuleConfiguration actual) {
diff --git 
a/features/shadow/api/src/main/java/org/apache/shardingsphere/shadow/config/datasource/ShadowDataSourceConfiguration.java
 
b/features/shadow/api/src/main/java/org/apache/shardingsphere/shadow/config/datasource/ShadowDataSourceConfiguration.java
index 0ff5c48d764..41611c5491b 100644
--- 
a/features/shadow/api/src/main/java/org/apache/shardingsphere/shadow/config/datasource/ShadowDataSourceConfiguration.java
+++ 
b/features/shadow/api/src/main/java/org/apache/shardingsphere/shadow/config/datasource/ShadowDataSourceConfiguration.java
@@ -24,9 +24,9 @@ import lombok.Setter;
 /**
  * Shadow data source mapper configuration.
  */
+@RequiredArgsConstructor
 @Getter
 @Setter
-@RequiredArgsConstructor
 public final class ShadowDataSourceConfiguration {
     
     private final String name;
diff --git 
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationYamlUnmarshalIT.java
 
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationYamlUnmarshalIT.java
index de4970fe764..e357e200175 100644
--- 
a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationYamlUnmarshalIT.java
@@ -17,101 +17,40 @@
 
 package org.apache.shardingsphere.shadow.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import 
org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import org.apache.shardingsphere.shadow.config.ShadowRuleConfiguration;
+import 
org.apache.shardingsphere.shadow.config.datasource.ShadowDataSourceConfiguration;
+import org.apache.shardingsphere.shadow.config.table.ShadowTableConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
 import java.util.Arrays;
-import java.util.Optional;
-import java.util.Properties;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Collections;
 
 class ShadowRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     ShadowRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/shadow-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        Optional<YamlShadowRuleConfiguration> shadowRuleConfig = 
actual.getRules().stream()
-                .filter(each -> each instanceof 
YamlShadowRuleConfiguration).findFirst().map(optional -> 
(YamlShadowRuleConfiguration) optional);
-        assertTrue(shadowRuleConfig.isPresent());
-        assertThat(shadowRuleConfig.get().getTables().size(), is(3));
-        assertTOrder(shadowRuleConfig.get());
-        assertTOrderItem(shadowRuleConfig.get());
-        assertTAddress(shadowRuleConfig.get());
-        assertThat(shadowRuleConfig.get().getDefaultShadowAlgorithmName(), 
is("sql-hint-algorithm"));
-        assertThat(shadowRuleConfig.get().getShadowAlgorithms().size(), is(4));
-        assertUserIdInsertMatchAlgorithm(shadowRuleConfig.get());
-        assertUserIdUpdateMatchAlgorithm(shadowRuleConfig.get());
-        assertUserIdSelectMatchAlgorithm(shadowRuleConfig.get());
-        assertSqlHintAlgorithm(shadowRuleConfig.get());
-    }
-    
-    private void assertTOrder(final YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getTables().get("t_order").getDataSourceNames().iterator().next(),
 is("shadowDataSource"));
-        
assertThat(actual.getTables().get("t_order").getShadowAlgorithmNames().size(), 
is(2));
-        
assertTrue(actual.getTables().get("t_order").getShadowAlgorithmNames().containsAll(Arrays.asList("user-id-insert-match-algorithm",
 "user-id-select-match-algorithm")));
-    }
-    
-    private void assertTOrderItem(final YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getTables().get("t_order_item").getDataSourceNames().iterator().next(),
 is("shadowDataSource"));
-        
assertThat(actual.getTables().get("t_order_item").getShadowAlgorithmNames().size(),
 is(3));
-        
assertTrue(actual.getTables().get("t_order_item").getShadowAlgorithmNames().containsAll(
-                Arrays.asList("user-id-insert-match-algorithm", 
"user-id-update-match-algorithm", "user-id-select-match-algorithm")));
-    }
-    
-    private void assertTAddress(final YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getTables().get("t_address").getDataSourceNames().iterator().next(),
 is("shadowDataSource"));
-        
assertThat(actual.getTables().get("t_address").getShadowAlgorithmNames().size(),
 is(3));
-        
assertTrue(actual.getTables().get("t_address").getShadowAlgorithmNames().containsAll(Arrays.asList("user-id-insert-match-algorithm",
 "user-id-select-match-algorithm", "sql-hint-algorithm")));
-    }
-    
-    private void assertUserIdInsertMatchAlgorithm(final 
YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getShadowAlgorithms().get("user-id-insert-match-algorithm").getType(),
 is("REGEX_MATCH"));
-        Properties props = 
actual.getShadowAlgorithms().get("user-id-insert-match-algorithm").getProps();
-        assertThat(props.size(), is(3));
-        assertTrue(props.containsKey("operation"));
-        assertThat(props.getProperty("operation"), is("insert"));
-        assertTrue(props.containsKey("column"));
-        assertThat(props.getProperty("column"), is("user_id"));
-        assertTrue(props.containsKey("regex"));
-        assertThat(props.getProperty("regex"), is("[1]"));
-    }
-    
-    private void assertUserIdUpdateMatchAlgorithm(final 
YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getShadowAlgorithms().get("user-id-update-match-algorithm").getType(),
 is("REGEX_MATCH"));
-        Properties props = 
actual.getShadowAlgorithms().get("user-id-update-match-algorithm").getProps();
-        assertThat(props.size(), is(3));
-        assertTrue(props.containsKey("operation"));
-        assertThat(props.getProperty("operation"), is("update"));
-        assertTrue(props.containsKey("column"));
-        assertThat(props.getProperty("column"), is("user_id"));
-        assertTrue(props.containsKey("regex"));
-        assertThat(props.getProperty("regex"), is("[1]"));
-    }
-    
-    private void assertUserIdSelectMatchAlgorithm(final 
YamlShadowRuleConfiguration actual) {
-        
assertThat(actual.getShadowAlgorithms().get("user-id-select-match-algorithm").getType(),
 is("REGEX_MATCH"));
-        Properties props = 
actual.getShadowAlgorithms().get("user-id-select-match-algorithm").getProps();
-        assertThat(props.size(), is(3));
-        assertTrue(props.containsKey("operation"));
-        assertThat(props.getProperty("operation"), is("select"));
-        assertTrue(props.containsKey("column"));
-        assertThat(props.getProperty("column"), is("user_id"));
-        assertTrue(props.containsKey("regex"));
-        assertThat(props.getProperty("regex"), is("[1]"));
-    }
-    
-    private void assertSqlHintAlgorithm(final YamlShadowRuleConfiguration 
actual) {
-        
assertThat(actual.getShadowAlgorithms().get("sql-hint-algorithm").getType(), 
is("SQL_HINT"));
-        Properties props = 
actual.getShadowAlgorithms().get("sql-hint-algorithm").getProps();
-        assertThat(props.size(), is(2));
-        assertTrue((boolean) props.get("shadow"));
-        assertThat(props.getProperty("foo"), is("bar"));
+        super("yaml/shadow-rule.yaml", getExpectedRuleConfiguration());
+    }
+    
+    private static ShadowRuleConfiguration getExpectedRuleConfiguration() {
+        ShadowRuleConfiguration result = new ShadowRuleConfiguration();
+        result.getDataSources().add(new 
ShadowDataSourceConfiguration("shadowDataSource", "ds", "ds_shadow"));
+        result.getTables().put("t_order", new ShadowTableConfiguration(
+                Collections.singletonList("shadowDataSource"), 
Arrays.asList("user-id-insert-match-algorithm", 
"user-id-select-match-algorithm")));
+        result.getTables().put("t_order_item", new ShadowTableConfiguration(
+                Collections.singletonList("shadowDataSource"), 
Arrays.asList("user-id-insert-match-algorithm", 
"user-id-update-match-algorithm", "user-id-select-match-algorithm")));
+        result.getTables().put("t_address", new ShadowTableConfiguration(
+                Collections.singletonList("shadowDataSource"), 
Arrays.asList("user-id-insert-match-algorithm", 
"user-id-select-match-algorithm", "sql-hint-algorithm")));
+        result.getShadowAlgorithms().put("user-id-insert-match-algorithm", new 
AlgorithmConfiguration("REGEX_MATCH",
+                PropertiesBuilder.build(new Property("regex", "[1]"), new 
Property("column", "user_id"), new Property("operation", "insert"))));
+        result.getShadowAlgorithms().put("user-id-update-match-algorithm", new 
AlgorithmConfiguration("REGEX_MATCH",
+                PropertiesBuilder.build(new Property("regex", "[1]"), new 
Property("column", "user_id"), new Property("operation", "update"))));
+        result.getShadowAlgorithms().put("user-id-select-match-algorithm", new 
AlgorithmConfiguration("REGEX_MATCH",
+                PropertiesBuilder.build(new Property("regex", "[1]"), new 
Property("column", "user_id"), new Property("operation", "select"))));
+        result.getShadowAlgorithms().put("sql-hint-algorithm", new 
AlgorithmConfiguration("SQL_HINT", PropertiesBuilder.build(new 
Property("shadow", true), new Property("foo", "bar"))));
+        result.setDefaultShadowAlgorithmName("sql-hint-algorithm");
+        return result;
     }
 }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingConfigurationRepositoryTupleSwapperEngineIT.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingConfigurationRepositoryTupleSwapperEngineIT.java
index 262b6fc6ed6..62540f9163f 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingConfigurationRepositoryTupleSwapperEngineIT.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingConfigurationRepositoryTupleSwapperEngineIT.java
@@ -31,7 +31,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
 class ShardingConfigurationRepositoryTupleSwapperEngineIT extends 
RepositoryTupleSwapperEngineIT {
     
     ShardingConfigurationRepositoryTupleSwapperEngineIT() {
-        super("yaml/sharding-rule.yaml");
+        super("yaml/sharding-rule-for-tuple.yaml");
     }
     
     @Override
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingRuleConfigurationYamlUnmarshalIT.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingRuleConfigurationYamlUnmarshalIT.java
index fd332477bc2..ada4ee8ca10 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingRuleConfigurationYamlUnmarshalIT.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/it/ShardingRuleConfigurationYamlUnmarshalIT.java
@@ -17,14 +17,29 @@
 
 package org.apache.shardingsphere.sharding.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.sharding.api.config.ShardingRuleConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.cache.ShardingCacheOptionsConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableReferenceRuleConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.rule.ShardingTableRuleConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.audit.ShardingAuditStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.keygen.KeyGenerateStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration;
+import 
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.YamlShardingRuleConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheConfiguration;
 import 
org.apache.shardingsphere.sharding.yaml.config.cache.YamlShardingCacheOptionsConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
 import java.util.ArrayList;
-import java.util.Optional;
+import java.util.Collections;
+import java.util.Properties;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -33,22 +48,58 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
 class ShardingRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     ShardingRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/sharding-rule.yaml");
+        super("yaml/sharding-rule.yaml", getExpectedRuleConfiguration());
+    }
+    
+    private static ShardingRuleConfiguration getExpectedRuleConfiguration() {
+        ShardingRuleConfiguration result = new ShardingRuleConfiguration();
+        ShardingTableRuleConfiguration userTableRuleConfig = new 
ShardingTableRuleConfiguration("t_user", "ds_${0..1}.t_user_${0..15}");
+        userTableRuleConfig.setDatabaseShardingStrategy(new 
ComplexShardingStrategyConfiguration("region_id, user_id", 
"core_complex_fixture"));
+        userTableRuleConfig.setTableShardingStrategy(new 
ComplexShardingStrategyConfiguration("region_id, user_id", 
"core_complex_fixture"));
+        result.getTables().add(userTableRuleConfig);
+        ShardingTableRuleConfiguration stockTableRuleConfig = new 
ShardingTableRuleConfiguration("t_stock", "ds_${0..1}.t_stock{0..8}");
+        stockTableRuleConfig.setDatabaseShardingStrategy(new 
HintShardingStrategyConfiguration("core_hint_fixture"));
+        stockTableRuleConfig.setTableShardingStrategy(new 
HintShardingStrategyConfiguration("core_hint_fixture"));
+        result.getTables().add(stockTableRuleConfig);
+        ShardingTableRuleConfiguration orderTableRuleConfig = new 
ShardingTableRuleConfiguration("t_order", "ds_${0..1}.t_order_${0..1}");
+        orderTableRuleConfig.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id", "table_inline"));
+        orderTableRuleConfig.setKeyGenerateStrategy(new 
KeyGenerateStrategyConfiguration("order_id", "snowflake"));
+        result.getTables().add(orderTableRuleConfig);
+        ShardingTableRuleConfiguration orderItemTableRuleConfig = new 
ShardingTableRuleConfiguration("t_order_item", 
"ds_${0..1}.t_order_item_${0..1}");
+        orderItemTableRuleConfig.setTableShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id", "core_standard_fixture"));
+        result.getTables().add(orderItemTableRuleConfig);
+        result.getBindingTableGroups().add(new 
ShardingTableReferenceRuleConfiguration("foo", "t_order, t_order_item"));
+        result.setDefaultDatabaseShardingStrategy(new 
StandardShardingStrategyConfiguration("order_id", "database_inline"));
+        result.setDefaultTableShardingStrategy(new 
NoneShardingStrategyConfiguration());
+        result.setDefaultShardingColumn("order_id");
+        result.setDefaultKeyGenerateStrategy(new 
KeyGenerateStrategyConfiguration("id", "snowflake"));
+        result.setDefaultAuditStrategy(new 
ShardingAuditStrategyConfiguration(Collections.singletonList("sharding_key_required_auditor"),
 true));
+        result.getShardingAlgorithms().put("core_standard_fixture", new 
AlgorithmConfiguration("CORE.STANDARD.FIXTURE", new Properties()));
+        result.getShardingAlgorithms().put("core_complex_fixture", new 
AlgorithmConfiguration("CORE.COMPLEX.FIXTURE", new Properties()));
+        result.getShardingAlgorithms().put("core_hint_fixture", new 
AlgorithmConfiguration("CORE.HINT.FIXTURE", new Properties()));
+        result.getShardingAlgorithms().put("database_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "ds_${order_id % 2}"))));
+        result.getShardingAlgorithms().put("table_inline", new 
AlgorithmConfiguration("INLINE", PropertiesBuilder.build(new 
Property("algorithm-expression", "t_order_${order_id % 2}"))));
+        result.getKeyGenerators().put("snowflake", new 
AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+        result.getAuditors().put("sharding_key_required_auditor", new 
AlgorithmConfiguration("DML_SHARDING_CONDITIONS", new Properties()));
+        result.setShardingCache(new ShardingCacheConfiguration(512, new 
ShardingCacheOptionsConfiguration(true, 65536, 262144)));
+        return result;
     }
     
     @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        Optional<YamlShardingRuleConfiguration> shardingRuleConfig = 
actual.getRules().stream()
-                .filter(each -> each instanceof 
YamlShardingRuleConfiguration).findFirst().map(optional -> 
(YamlShardingRuleConfiguration) optional);
-        assertTrue(shardingRuleConfig.isPresent());
-        assertThat(shardingRuleConfig.get().getTables().size(), is(4));
-        assertTUser(shardingRuleConfig.get());
-        assertTStock(shardingRuleConfig.get());
-        assertTOrder(shardingRuleConfig.get());
-        assertTOrderItem(shardingRuleConfig.get());
-        assertBindingTable(shardingRuleConfig.get());
-        assertShardingCache(shardingRuleConfig.get());
-        assertThat(shardingRuleConfig.get().getDefaultShardingColumn(), 
is("order_id"));
+    protected boolean assertYamlConfiguration(final YamlRuleConfiguration 
actual) {
+        assertShardingRule((YamlShardingRuleConfiguration) actual);
+        return true;
+    }
+    
+    private void assertShardingRule(final YamlShardingRuleConfiguration 
actual) {
+        assertThat(actual.getTables().size(), is(4));
+        assertTUser(actual);
+        assertTStock(actual);
+        assertTOrder(actual);
+        assertTOrderItem(actual);
+        assertBindingTable(actual);
+        assertShardingCache(actual);
+        assertThat(actual.getDefaultShardingColumn(), is("order_id"));
     }
     
     private void assertTUser(final YamlShardingRuleConfiguration actual) {
@@ -81,9 +132,8 @@ class ShardingRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnma
     }
     
     private void assertBindingTable(final YamlShardingRuleConfiguration 
actual) {
-        assertThat(actual.getBindingTables().size(), is(2));
-        assertThat(new ArrayList<>(actual.getBindingTables()).get(0), 
is("t_order, t_order_item"));
-        assertThat(new ArrayList<>(actual.getBindingTables()).get(1), 
is("foo:t_order, t_order_item"));
+        assertThat(actual.getBindingTables().size(), is(1));
+        assertThat(new ArrayList<>(actual.getBindingTables()).get(0), 
is("foo:t_order, t_order_item"));
     }
     
     private void assertShardingCache(final YamlShardingRuleConfiguration 
actual) {
diff --git a/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml 
b/features/sharding/core/src/test/resources/yaml/sharding-rule-for-tuple.yaml
similarity index 97%
copy from features/sharding/core/src/test/resources/yaml/sharding-rule.yaml
copy to 
features/sharding/core/src/test/resources/yaml/sharding-rule-for-tuple.yaml
index 5fc2064d4eb..77e669e608e 100644
--- a/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml
+++ 
b/features/sharding/core/src/test/resources/yaml/sharding-rule-for-tuple.yaml
@@ -52,8 +52,8 @@ rules:
           shardingColumn: order_id
           shardingAlgorithmName: core_standard_fixture
   bindingTables:
-  - t_order, t_order_item
-  - foo:t_order, t_order_item
+    - t_order, t_order_item
+    - foo:t_order, t_order_item
   defaultDatabaseStrategy:
     standard:
       shardingColumn: order_id
@@ -84,7 +84,7 @@ rules:
       type: INLINE
       props:
         algorithm-expression: t_order_${order_id % 2}
-  
+
   keyGenerators:
     snowflake:
       type: SNOWFLAKE
@@ -96,6 +96,6 @@ rules:
   shardingCache:
     allowedMaxSqlLength: 512
     routeCache:
+      softValues: true
       initialCapacity: 65536
       maximumSize: 262144
-      softValues: true
diff --git a/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml 
b/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml
index 5fc2064d4eb..0f2944e4028 100644
--- a/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml
+++ b/features/sharding/core/src/test/resources/yaml/sharding-rule.yaml
@@ -52,8 +52,7 @@ rules:
           shardingColumn: order_id
           shardingAlgorithmName: core_standard_fixture
   bindingTables:
-  - t_order, t_order_item
-  - foo:t_order, t_order_item
+    - foo:t_order, t_order_item
   defaultDatabaseStrategy:
     standard:
       shardingColumn: order_id
@@ -84,7 +83,7 @@ rules:
       type: INLINE
       props:
         algorithm-expression: t_order_${order_id % 2}
-  
+
   keyGenerators:
     snowflake:
       type: SNOWFLAKE
@@ -96,6 +95,6 @@ rules:
   shardingCache:
     allowedMaxSqlLength: 512
     routeCache:
+      softValues: true
       initialCapacity: 65536
       maximumSize: 262144
-      softValues: true
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
index 84cd9d13a9e..349e520d34c 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -46,6 +46,6 @@ public final class YamlRuleConfigurationSwapperFixture 
implements YamlRuleConfig
     
     @Override
     public int getOrder() {
-        return 3;
+        return -300;
     }
 }
diff --git 
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationYamlUnmarshalIT.java
index 82a2ae56a1d..4372e3c61c1 100644
--- 
a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationYamlUnmarshalIT.java
@@ -17,61 +17,24 @@
 
 package org.apache.shardingsphere.authority.it;
 
-import 
org.apache.shardingsphere.authority.yaml.config.YamlAuthorityRuleConfiguration;
-import org.apache.shardingsphere.authority.yaml.config.YamlUserConfiguration;
-import 
org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import org.apache.shardingsphere.authority.config.AuthorityRuleConfiguration;
+import 
org.apache.shardingsphere.infra.algorithm.core.config.AlgorithmConfiguration;
+import org.apache.shardingsphere.infra.metadata.user.ShardingSphereUser;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
 
 class AuthorityRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     AuthorityRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/authority-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertAuthorityRule((YamlAuthorityRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertAuthorityRule(final YamlAuthorityRuleConfiguration 
actual) {
-        assertUsers(new ArrayList<>(actual.getUsers()));
-        assertPrivilege(actual.getPrivilege());
-        assertAuthenticators(actual.getAuthenticators());
-        assertDefaultAuthenticator(actual.getDefaultAuthenticator());
-    }
-    
-    private void assertUsers(final List<YamlUserConfiguration> actual) {
-        assertThat(actual.size(), is(2));
-        assertThat(actual.get(0).getUser(), is("root@%"));
-        assertThat(actual.get(0).getPassword(), is("root"));
-        assertTrue(actual.get(0).isAdmin());
-        assertThat(actual.get(1).getUser(), is("sharding@"));
-        assertThat(actual.get(1).getPassword(), is("sharding"));
-        assertFalse(actual.get(1).isAdmin());
-    }
-    
-    private void assertPrivilege(final YamlAlgorithmConfiguration actual) {
-        assertThat(actual.getType(), is("ALL_PERMITTED"));
-        assertTrue(actual.getProps().isEmpty());
-    }
-    
-    private void assertAuthenticators(final Map<String, 
YamlAlgorithmConfiguration> actual) {
-        assertThat(actual.size(), is(1));
-        assertThat(actual.get("fixture").getType(), is("FIXTURE"));
-        assertTrue(actual.get("fixture").getProps().isEmpty());
+        super("yaml/authority-rule.yaml", getExpectedRuleConfiguration());
     }
     
-    private void assertDefaultAuthenticator(final String actual) {
-        assertThat(actual, is("fixture"));
+    private static AuthorityRuleConfiguration getExpectedRuleConfiguration() {
+        return new AuthorityRuleConfiguration(
+                Arrays.asList(new ShardingSphereUser("root", "root", "%", 
null, true), new ShardingSphereUser("sharding", "sharding", "%", null, false)),
+                new AlgorithmConfiguration("ALL_PERMITTED", new Properties()), 
Collections.singletonMap("fixture", new AlgorithmConfiguration("FIXTURE", new 
Properties())), "fixture");
     }
 }
diff --git a/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml 
b/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml
index c0afd337893..e5472d6299a 100644
--- a/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml
+++ b/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml
@@ -21,7 +21,7 @@ rules:
     - user: root@%
       password: root
       admin: true
-    - user: sharding@
+    - user: sharding@%
       password: sharding
       admin: false
   privilege:
diff --git 
a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationYamlUnmarshalIT.java
index 624ff57c60a..825c1211575 100644
--- 
a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationYamlUnmarshalIT.java
@@ -17,31 +17,14 @@
 
 package org.apache.shardingsphere.globalclock.it;
 
-import 
org.apache.shardingsphere.globalclock.yaml.config.YamlGlobalClockRuleConfiguration;
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.globalclock.config.GlobalClockRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
 class GlobalClockRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     GlobalClockRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/global-clock-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertGlobalClockRule((YamlGlobalClockRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertGlobalClockRule(final YamlGlobalClockRuleConfiguration 
actual) {
-        assertThat(actual.getType(), is("FIXTURE"));
-        assertThat(actual.getProvider(), is("FIXTURE"));
-        assertTrue(actual.isEnabled());
-        assertThat(actual.getProps().size(), is(2));
-        assertThat(actual.getProps().getProperty("k0"), is("v0"));
-        assertThat(actual.getProps().getProperty("k1"), is("v1"));
+        super("yaml/global-clock-rule.yaml", new 
GlobalClockRuleConfiguration("FIXTURE", "FIXTURE", true, 
PropertiesBuilder.build(new Property("k0", "v0"), new Property("k1", "v1"))));
     }
 }
diff --git 
a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationYamlUnmarshalIT.java
index b722f96c183..83f0dc27fef 100644
--- 
a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationYamlUnmarshalIT.java
@@ -17,51 +17,25 @@
 
 package org.apache.shardingsphere.logging.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import org.apache.shardingsphere.logging.yaml.config.YamlAppenderConfiguration;
-import org.apache.shardingsphere.logging.yaml.config.YamlLoggerConfiguration;
-import 
org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
+import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
+import org.apache.shardingsphere.logging.logger.ShardingSphereAppender;
+import org.apache.shardingsphere.logging.logger.ShardingSphereLogger;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import java.util.Collections;
 
 class LoggingRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     LoggingRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/logging-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertLoggingRule((YamlLoggingRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertLoggingRule(final YamlLoggingRuleConfiguration actual) {
-        assertLoggers(actual.getLoggers());
-        assertAppenders(actual.getAppenders());
-    }
-    
-    private void assertLoggers(final Collection<YamlLoggerConfiguration> 
actual) {
-        assertThat(actual.size(), is(1));
-        assertThat(new ArrayList<>(actual).get(0).getLoggerName(), 
is("foo_logger"));
-        assertThat(new ArrayList<>(actual).get(0).getLevel(), is("INFO"));
-        assertTrue(new ArrayList<>(actual).get(0).getAdditivity());
-        assertThat(new ArrayList<>(actual).get(0).getAppenderName(), 
is("foo_appender"));
-        assertThat(new ArrayList<>(actual).get(0).getProps().size(), is(2));
-        assertThat(new 
ArrayList<>(actual).get(0).getProps().getProperty("k0"), is("v0"));
-        assertThat(new 
ArrayList<>(actual).get(0).getProps().getProperty("k1"), is("v1"));
+        super("yaml/logging-rule.yaml", getExpectedRuleConfiguration());
     }
     
-    private void assertAppenders(final Collection<YamlAppenderConfiguration> 
actual) {
-        assertThat(actual.size(), is(1));
-        assertThat(new ArrayList<>(actual).get(0).getAppenderName(), 
is("foo_appender"));
-        assertThat(new ArrayList<>(actual).get(0).getAppenderClass(), 
is("foo_appender_class"));
-        assertThat(new ArrayList<>(actual).get(0).getPattern(), is("sss"));
-        assertThat(new ArrayList<>(actual).get(0).getFile(), is("foo_file"));
+    private static LoggingRuleConfiguration getExpectedRuleConfiguration() {
+        ShardingSphereLogger logger = new ShardingSphereLogger("foo_logger", 
"INFO", true, "foo_appender");
+        logger.getProps().put("k0", "v0");
+        logger.getProps().put("k1", "v1");
+        ShardingSphereAppender appender = new 
ShardingSphereAppender("foo_appender", "foo_appender_class", "sss");
+        appender.setFile("foo_file");
+        return new LoggingRuleConfiguration(Collections.singletonList(logger), 
Collections.singletonList(appender));
     }
 }
diff --git 
a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/yaml/swapper/YamlLoggingRuleConfigurationSwapperTest.java
 
b/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/yaml/swapper/YamlLoggingRuleConfigurationSwapperTest.java
deleted file mode 100644
index a15e73b75e8..00000000000
--- 
a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/yaml/swapper/YamlLoggingRuleConfigurationSwapperTest.java
+++ /dev/null
@@ -1,65 +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.logging.yaml.swapper;
-
-import org.apache.shardingsphere.logging.config.LoggingRuleConfiguration;
-import org.apache.shardingsphere.logging.logger.ShardingSphereAppender;
-import org.apache.shardingsphere.logging.logger.ShardingSphereLogger;
-import 
org.apache.shardingsphere.logging.yaml.config.YamlLoggingRuleConfiguration;
-import org.junit.jupiter.api.Test;
-
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class YamlLoggingRuleConfigurationSwapperTest {
-    
-    private final YamlLoggingRuleConfigurationSwapper swapper = new 
YamlLoggingRuleConfigurationSwapper();
-    
-    private final YamlLoggerSwapper loggerSwapper = new YamlLoggerSwapper();
-    
-    private final YamlAppenderSwapper appenderSwapper = new 
YamlAppenderSwapper();
-    
-    @Test
-    void assertSwapToYamlConfiguration() {
-        YamlLoggingRuleConfiguration yamlLoggingRuleConfig = 
swapper.swapToYamlConfiguration(createLoggingRuleConfiguration());
-        assertThat(yamlLoggingRuleConfig.getLoggers().size(), is(1));
-        assertThat(yamlLoggingRuleConfig.getAppenders().size(), is(1));
-    }
-    
-    private LoggingRuleConfiguration createLoggingRuleConfiguration() {
-        return new LoggingRuleConfiguration(Collections.singleton(new 
ShardingSphereLogger("ROOT", "INFO", true, "console")),
-                Collections.singleton(new ShardingSphereAppender("console", 
"ch.qos.logback.core.ConsoleAppender", "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} 
[%thread] %logger{36} - %msg%n")));
-    }
-    
-    @Test
-    void assertSwapToObject() {
-        LoggingRuleConfiguration loggingRuleConfig = 
swapper.swapToObject(createYamlLoggingRuleConfiguration());
-        assertThat(loggingRuleConfig.getLoggers().size(), is(1));
-        assertThat(loggingRuleConfig.getAppenders().size(), is(1));
-    }
-    
-    private YamlLoggingRuleConfiguration createYamlLoggingRuleConfiguration() {
-        YamlLoggingRuleConfiguration result = new 
YamlLoggingRuleConfiguration();
-        
result.setLoggers(Collections.singleton(loggerSwapper.swapToYamlConfiguration(new
 ShardingSphereLogger("ROOT", "INFO", true, "console"))));
-        
result.setAppenders(Collections.singleton(appenderSwapper.swapToYamlConfiguration(
-                new ShardingSphereAppender("console", 
"ch.qos.logback.core.ConsoleAppender", "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} 
[%thread] %logger{36} - %msg%n"))));
-        return result;
-    }
-}
diff --git 
a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
 
b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
index e9a1b168014..f13eb66b5a6 100644
--- 
a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
+++ 
b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/fixture/YamlRuleConfigurationSwapperFixture.java
@@ -47,6 +47,6 @@ public final class YamlRuleConfigurationSwapperFixture 
implements YamlRuleConfig
     
     @Override
     public int getOrder() {
-        return 3;
+        return -400;
     }
 }
diff --git 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationYamlUnmarshalIT.java
index 44a0133eec8..e58f3041602 100644
--- 
a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationYamlUnmarshalIT.java
@@ -17,28 +17,19 @@
 
 package org.apache.shardingsphere.single.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import 
org.apache.shardingsphere.single.yaml.config.pojo.YamlSingleRuleConfiguration;
+import org.apache.shardingsphere.single.config.SingleRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import java.util.Collections;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 class SingleRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     SingleRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/single-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertSingleRule((YamlSingleRuleConfiguration) 
actual.getRules().iterator().next());
+        super("yaml/single-rule.yaml", getExpectedRuleConfiguration());
     }
     
-    private void assertSingleRule(final YamlSingleRuleConfiguration actual) {
-        assertThat(actual.getTables(), 
is(Collections.singletonList("foo_tbl")));
-        assertThat(actual.getDefaultDataSource(), is("foo_ds"));
+    private static SingleRuleConfiguration getExpectedRuleConfiguration() {
+        SingleRuleConfiguration result = new SingleRuleConfiguration();
+        result.getTables().add("foo_tbl");
+        result.setDefaultDataSource("foo_ds");
+        return result;
     }
 }
diff --git 
a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationYamlUnmarshalIT.java
index f5a6c8e921f..08b9da410c1 100644
--- 
a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationYamlUnmarshalIT.java
@@ -17,34 +17,13 @@
 
 package org.apache.shardingsphere.sqlfederation.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import 
org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationExecutionPlanCacheRuleConfiguration;
-import 
org.apache.shardingsphere.sqlfederation.yaml.config.YamlSQLFederationRuleConfiguration;
+import org.apache.shardingsphere.sql.parser.api.CacheOption;
+import 
org.apache.shardingsphere.sqlfederation.config.SQLFederationRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
 class SQLFederationRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     SQLFederationRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/sql-federation-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertSQLFederationRule((YamlSQLFederationRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertSQLFederationRule(final 
YamlSQLFederationRuleConfiguration actual) {
-        assertTrue(actual.isSqlFederationEnabled());
-        assertTrue(actual.isAllQueryUseSQLFederation());
-        assertExecutionPlanCache(actual.getExecutionPlanCache());
-    }
-    
-    private void assertExecutionPlanCache(final 
YamlSQLFederationExecutionPlanCacheRuleConfiguration actual) {
-        assertThat(actual.getInitialCapacity(), is(128));
-        assertThat(actual.getMaximumSize(), is(1024L));
+        super("yaml/sql-federation-rule.yaml", new 
SQLFederationRuleConfiguration(true, true, new CacheOption(128, 1024)));
     }
 }
diff --git 
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlUnmarshalIT.java
index 65f54296466..909dc59eab6 100644
--- 
a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationYamlUnmarshalIT.java
@@ -17,37 +17,13 @@
 
 package org.apache.shardingsphere.parser.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import 
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserCacheOptionRuleConfiguration;
-import 
org.apache.shardingsphere.parser.yaml.config.YamlSQLParserRuleConfiguration;
+import org.apache.shardingsphere.parser.config.SQLParserRuleConfiguration;
+import org.apache.shardingsphere.sql.parser.api.CacheOption;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
 class SQLParserRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     SQLParserRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/sql-parser-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertSQLParserRule((YamlSQLParserRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertSQLParserRule(final YamlSQLParserRuleConfiguration 
actual) {
-        assertSQLStatementCache(actual.getSqlStatementCache());
-        assertSQLParseTreeCache(actual.getParseTreeCache());
-    }
-    
-    private void assertSQLStatementCache(final 
YamlSQLParserCacheOptionRuleConfiguration actual) {
-        assertThat(actual.getInitialCapacity(), is(256));
-        assertThat(actual.getMaximumSize(), is(4096L));
-    }
-    
-    private void assertSQLParseTreeCache(final 
YamlSQLParserCacheOptionRuleConfiguration actual) {
-        assertThat(actual.getInitialCapacity(), is(128));
-        assertThat(actual.getMaximumSize(), is(1024L));
+        super("yaml/sql-parser-rule.yaml", new SQLParserRuleConfiguration(new 
CacheOption(128, 1024), new CacheOption(256, 4096)));
     }
 }
diff --git 
a/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml 
b/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
index 168ce49e551..9eace8f0797 100644
--- a/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
+++ b/kernel/sql-parser/core/src/test/resources/yaml/sql-parser-rule.yaml
@@ -17,9 +17,9 @@
 
 rules:
 - !SQL_PARSER
-  sqlStatementCache:
-    initialCapacity: 256
-    maximumSize: 4096
   parseTreeCache:
     initialCapacity: 128
     maximumSize: 1024
+  sqlStatementCache:
+    initialCapacity: 256
+    maximumSize: 4096
diff --git a/kernel/sql-translator/core/pom.xml 
b/kernel/sql-translator/core/pom.xml
index 1519ed8a290..7877b996fcf 100644
--- a/kernel/sql-translator/core/pom.xml
+++ b/kernel/sql-translator/core/pom.xml
@@ -38,6 +38,12 @@
             <version>${project.version}</version>
         </dependency>
         
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-test-util</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-test-it-yaml</artifactId>
diff --git 
a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationYamlUnmarshalIT.java
index f5c10a3a6d3..c8639b29fa9 100644
--- 
a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationYamlUnmarshalIT.java
@@ -17,30 +17,14 @@
 
 package org.apache.shardingsphere.sqltranslator.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
-import 
org.apache.shardingsphere.sqltranslator.yaml.config.YamlSQLTranslatorRuleConfiguration;
+import 
org.apache.shardingsphere.sqltranslator.config.SQLTranslatorRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
 
 class SQLTranslatorRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     SQLTranslatorRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/sql-translator-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertSQLTranslatorRule((YamlSQLTranslatorRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertSQLTranslatorRule(final 
YamlSQLTranslatorRuleConfiguration actual) {
-        assertThat(actual.getType(), is("FIXTURE"));
-        assertThat(actual.getProps().size(), is(2));
-        assertThat(actual.getProps().getProperty("k0"), is("v0"));
-        assertThat(actual.getProps().getProperty("k1"), is("v1"));
-        assertTrue(actual.isUseOriginalSQLWhenTranslatingFailed());
+        super("yaml/sql-translator-rule.yaml", new 
SQLTranslatorRuleConfiguration("FIXTURE", PropertiesBuilder.build(new 
Property("k0", "v0"), new Property("k1", "v1")), true));
     }
 }
diff --git 
a/kernel/sql-translator/core/src/test/resources/yaml/sql-translator-rule.yaml 
b/kernel/sql-translator/core/src/test/resources/yaml/sql-translator-rule.yaml
index e91c78a05be..e31adde7ce9 100644
--- 
a/kernel/sql-translator/core/src/test/resources/yaml/sql-translator-rule.yaml
+++ 
b/kernel/sql-translator/core/src/test/resources/yaml/sql-translator-rule.yaml
@@ -18,7 +18,7 @@
 rules:
 - !SQL_TRANSLATOR
   type: FIXTURE
+  useOriginalSQLWhenTranslatingFailed: true
   props:
     k0: v0
     k1: v1
-  useOriginalSQLWhenTranslatingFailed: true
diff --git a/kernel/transaction/core/pom.xml b/kernel/transaction/core/pom.xml
index f8de584f354..4cc7e3b090b 100644
--- a/kernel/transaction/core/pom.xml
+++ b/kernel/transaction/core/pom.xml
@@ -38,6 +38,12 @@
             <version>${project.parent.version}</version>
         </dependency>
         
+        <dependency>
+            <groupId>org.apache.shardingsphere</groupId>
+            <artifactId>shardingsphere-test-util</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere</groupId>
             <artifactId>shardingsphere-test-fixture-database</artifactId>
diff --git 
a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationYamlUnmarshalIT.java
 
b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationYamlUnmarshalIT.java
index d51cc1b78b6..2c1244472a8 100644
--- 
a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationYamlUnmarshalIT.java
+++ 
b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationYamlUnmarshalIT.java
@@ -17,29 +17,14 @@
 
 package org.apache.shardingsphere.transaction.it;
 
-import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
 import org.apache.shardingsphere.test.it.yaml.YamlRuleConfigurationUnmarshalIT;
-import 
org.apache.shardingsphere.transaction.yaml.config.YamlTransactionRuleConfiguration;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
+import org.apache.shardingsphere.test.util.PropertiesBuilder;
+import org.apache.shardingsphere.test.util.PropertiesBuilder.Property;
+import 
org.apache.shardingsphere.transaction.config.TransactionRuleConfiguration;
 
 class TransactionRuleConfigurationYamlUnmarshalIT extends 
YamlRuleConfigurationUnmarshalIT {
     
     TransactionRuleConfigurationYamlUnmarshalIT() {
-        super("yaml/transaction-rule.yaml");
-    }
-    
-    @Override
-    protected void assertYamlRootConfiguration(final YamlRootConfiguration 
actual) {
-        assertSQLTranslatorRule((YamlTransactionRuleConfiguration) 
actual.getRules().iterator().next());
-    }
-    
-    private void assertSQLTranslatorRule(final 
YamlTransactionRuleConfiguration actual) {
-        assertThat(actual.getDefaultType(), is("XA"));
-        assertThat(actual.getProviderType(), is("FIXTURE"));
-        assertThat(actual.getProps().size(), is(2));
-        assertThat(actual.getProps().getProperty("k0"), is("v0"));
-        assertThat(actual.getProps().getProperty("k1"), is("v1"));
+        super("yaml/transaction-rule.yaml", new 
TransactionRuleConfiguration("XA", "FIXTURE", PropertiesBuilder.build(new 
Property("k0", "v0"), new Property("k1", "v1"))));
     }
 }
diff --git 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationUnmarshalIT.java
 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationUnmarshalIT.java
index 5881d7c3e1f..69d88d0a9dd 100644
--- 
a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationUnmarshalIT.java
+++ 
b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/YamlRuleConfigurationUnmarshalIT.java
@@ -17,52 +17,80 @@
 
 package org.apache.shardingsphere.test.it.yaml;
 
-import lombok.RequiredArgsConstructor;
+import com.cedarsoftware.util.DeepEquals;
+import org.apache.shardingsphere.infra.config.rule.RuleConfiguration;
+import org.apache.shardingsphere.infra.spi.type.ordered.OrderedSPILoader;
 import org.apache.shardingsphere.infra.util.yaml.YamlEngine;
 import org.apache.shardingsphere.infra.yaml.config.pojo.YamlRootConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import 
org.apache.shardingsphere.infra.yaml.config.swapper.rule.YamlRuleConfigurationSwapper;
 import org.junit.jupiter.api.Test;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.stream.Collectors;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
-@RequiredArgsConstructor
 public abstract class YamlRuleConfigurationUnmarshalIT {
     
     private final String yamlFile;
     
+    private final RuleConfiguration expectedRuleConfig;
+    
+    @SuppressWarnings("rawtypes")
+    private final YamlRuleConfigurationSwapper swapper;
+    
+    public YamlRuleConfigurationUnmarshalIT(final String yamlFile, final 
RuleConfiguration expectedRuleConfig) {
+        this.yamlFile = yamlFile;
+        this.expectedRuleConfig = expectedRuleConfig;
+        swapper = 
OrderedSPILoader.getServices(YamlRuleConfigurationSwapper.class, 
Collections.singleton(expectedRuleConfig)).get(expectedRuleConfig);
+    }
+    
+    @Test
+    void assertUnmarshal() throws IOException, URISyntaxException {
+        URL url = 
Thread.currentThread().getContextClassLoader().getResource(yamlFile);
+        assertNotNull(url);
+        YamlRootConfiguration yamlRootConfigFromFile = 
YamlEngine.unmarshal(new File(url.getFile()), YamlRootConfiguration.class);
+        YamlRootConfiguration yamlRootConfigFromBytes = YamlEngine.unmarshal(
+                
Files.readAllLines(Paths.get(url.toURI())).stream().collect(Collectors.joining(System.lineSeparator())).getBytes(),
 YamlRootConfiguration.class);
+        assertTrue(DeepEquals.deepEquals(yamlRootConfigFromFile, 
yamlRootConfigFromBytes));
+    }
+    
+    @SuppressWarnings("unchecked")
     @Test
-    void assertUnmarshalWithYamlFile() throws IOException {
+    void assertSwapToYamlConfiguration() throws IOException {
         URL url = 
Thread.currentThread().getContextClassLoader().getResource(yamlFile);
         assertNotNull(url);
         YamlRootConfiguration actual = YamlEngine.unmarshal(new 
File(url.getFile()), YamlRootConfiguration.class);
         assertThat(actual.getRules().size(), is(1));
-        assertYamlRootConfiguration(actual);
+        YamlRuleConfiguration actualYAMLRuleConfig = 
actual.getRules().iterator().next();
+        YamlRuleConfiguration expectedYAMLRuleConfig = (YamlRuleConfiguration) 
swapper.swapToYamlConfiguration(expectedRuleConfig);
+        if (!assertYamlConfiguration(actualYAMLRuleConfig)) {
+            assertTrue(DeepEquals.deepEquals(actualYAMLRuleConfig, 
expectedYAMLRuleConfig));
+        }
     }
     
+    @SuppressWarnings("unchecked")
     @Test
-    void assertUnmarshalWithYamlBytes() throws IOException, URISyntaxException 
{
+    void assertSwapToObject() throws IOException {
         URL url = 
Thread.currentThread().getContextClassLoader().getResource(yamlFile);
         assertNotNull(url);
-        StringBuilder yamlContent = new StringBuilder();
-        try (BufferedReader reader = 
Files.newBufferedReader(Paths.get(url.toURI()))) {
-            String line;
-            while (null != (line = reader.readLine())) {
-                yamlContent.append(line).append(System.lineSeparator());
-            }
-        }
-        YamlRootConfiguration actual = 
YamlEngine.unmarshal(yamlContent.toString().getBytes(), 
YamlRootConfiguration.class);
-        assertThat(actual.getRules().size(), is(1));
-        assertYamlRootConfiguration(actual);
+        YamlRootConfiguration actual = YamlEngine.unmarshal(new 
File(url.getFile()), YamlRootConfiguration.class);
+        RuleConfiguration actualRuleConfig = (RuleConfiguration) 
swapper.swapToObject(actual.getRules().iterator().next());
+        assertTrue(DeepEquals.deepEquals(actualRuleConfig, 
expectedRuleConfig));
     }
     
-    protected abstract void assertYamlRootConfiguration(YamlRootConfiguration 
actual);
+    // TODO should remove the method when yaml rule swapper fixed by map's key
+    protected boolean assertYamlConfiguration(final YamlRuleConfiguration 
actual) {
+        return false;
+    }
 }
diff --git 
a/test/util/src/main/java/org/apache/shardingsphere/test/util/PropertiesBuilder.java
 
b/test/util/src/main/java/org/apache/shardingsphere/test/util/PropertiesBuilder.java
index f289a827e4a..81e8f6c0422 100644
--- 
a/test/util/src/main/java/org/apache/shardingsphere/test/util/PropertiesBuilder.java
+++ 
b/test/util/src/main/java/org/apache/shardingsphere/test/util/PropertiesBuilder.java
@@ -38,7 +38,12 @@ public final class PropertiesBuilder {
     public static Properties build(final Property... props) {
         Properties result = new Properties();
         for (Property each : props) {
-            result.setProperty(each.key, each.value);
+            if (each.value instanceof String) {
+                result.setProperty(each.key, each.value.toString());
+            } else {
+                result.put(each.key, each.value);
+            }
+            
         }
         return result;
     }
@@ -51,6 +56,6 @@ public final class PropertiesBuilder {
         
         private final String key;
         
-        private final String value;
+        private final Object value;
     }
 }

Reply via email to