You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2024/05/02 13:52:48 UTC

(shardingsphere) branch master updated: Refactor RepositoryTupleSwapperIT to simplify assertions (#31102)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang 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 2ed75ddbf8a Refactor RepositoryTupleSwapperIT to simplify assertions (#31102)
2ed75ddbf8a is described below

commit 2ed75ddbf8acab94ba9164433c19db57afe7b651
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Thu May 2 21:52:42 2024 +0800

    Refactor RepositoryTupleSwapperIT to simplify assertions (#31102)
---
 ...tRuleConfigurationRepositoryTupleSwapperIT.java | 11 +++--
 ...cryptConfigurationRepositoryTupleSwapperIT.java | 25 +++++-----
 .../core/src/test/resources/yaml/encrypt-rule.yaml | 24 +++++-----
 .../MaskConfigurationRepositoryTupleSwapperIT.java | 24 +++++-----
 .../core/src/test/resources/yaml/mask-rule.yaml    | 16 +++----
 ...ttingConfigurationRepositoryTupleSwapperIT.java | 27 +++++------
 .../resources/yaml/readwrite-splitting-rule.yaml   |  8 ++--
 ...wRuleConfigurationRepositoryTupleSwapperIT.java | 53 ++++++++++------------
 .../core/src/test/resources/yaml/shadow-rule.yaml  | 52 ++++++++++-----------
 ...yRuleConfigurationRepositoryTupleSwapperIT.java | 13 ++----
 .../src/test/resources/yaml/authority-rule.yaml    | 18 ++++----
 ...kRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../src/test/resources/yaml/global-clock-rule.yaml |  4 +-
 ...gRuleConfigurationRepositoryTupleSwapperIT.java | 13 ++----
 .../core/src/test/resources/yaml/logging-rule.yaml | 16 +++----
 ...eRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../core/src/test/resources/yaml/single-rule.yaml  |  2 +-
 ...nRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../test/resources/yaml/sql-federation-rule.yaml   |  2 +-
 ...rRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../src/test/resources/yaml/sql-parser-rule.yaml   |  7 ++-
 ...rRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../test/resources/yaml/sql-translator-rule.yaml   |  2 +-
 ...cRuleConfigurationRepositoryTupleSwapperIT.java | 13 ++----
 .../core/src/test/resources/yaml/traffic-rule.yaml | 16 +++----
 ...nRuleConfigurationRepositoryTupleSwapperIT.java | 12 ++---
 .../src/test/resources/yaml/transaction-rule.yaml  |  2 +-
 .../test/it/yaml/RepositoryTupleSwapperIT.java     | 29 +++++++++---
 28 files changed, 203 insertions(+), 246 deletions(-)

diff --git a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationRepositoryTupleSwapperIT.java b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationRepositoryTupleSwapperIT.java
index 1f8589faca1..d489ce32976 100644
--- a/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/features/broadcast/core/src/test/java/org/apache/shardingsphere/broadcast/it/BroadcastRuleConfigurationRepositoryTupleSwapperIT.java
@@ -17,8 +17,10 @@
 
 package org.apache.shardingsphere.broadcast.it;
 
+import org.apache.shardingsphere.broadcast.yaml.config.YamlBroadcastRuleConfiguration;
 import org.apache.shardingsphere.broadcast.yaml.swapper.BroadcastRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
@@ -34,14 +36,13 @@ class BroadcastRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTuple
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
         Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertTables(iterator.next());
+        assertTables(iterator.next(), ((YamlBroadcastRuleConfiguration) expectedYamlRuleConfig).getTables());
     }
     
-    private void assertTables(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("tables"));
-        assertThat(actual.getValue(), is("- foo_tbl\n- bar_tbl\n"));
+    private void assertTables(final RepositoryTuple actual, final Collection<String> expectedTables) {
+        assertRepositoryTuple(actual, "tables", expectedTables);
     }
 }
diff --git a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptConfigurationRepositoryTupleSwapperIT.java b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptConfigurationRepositoryTupleSwapperIT.java
index 94b06502706..2dccff0f864 100644
--- a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptConfigurationRepositoryTupleSwapperIT.java
+++ b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/it/EncryptConfigurationRepositoryTupleSwapperIT.java
@@ -17,13 +17,18 @@
 
 package org.apache.shardingsphere.encrypt.it;
 
+import org.apache.shardingsphere.encrypt.yaml.config.YamlEncryptRuleConfiguration;
+import org.apache.shardingsphere.encrypt.yaml.config.rule.YamlEncryptTableRuleConfiguration;
 import org.apache.shardingsphere.encrypt.yaml.swapper.EncryptRuleConfigurationRepositoryTupleSwapper;
+import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -35,23 +40,19 @@ class EncryptConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSwappe
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(3));
         List<RepositoryTuple> actual = new ArrayList<>(actualRepositoryTuples);
-        assertEncryptor(actual.subList(0, 2));
-        assertTable(actual.get(2));
+        assertEncryptors(actual.subList(0, 2), ((YamlEncryptRuleConfiguration) expectedYamlRuleConfig).getEncryptors());
+        assertTables(actual.get(2), ((YamlEncryptRuleConfiguration) expectedYamlRuleConfig).getTables());
     }
     
-    private void assertEncryptor(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("encryptors/aes_encryptor"));
-        assertThat(actual.get(0).getValue(), is("props:\n  aes-key-value: 123456abc\ntype: AES\n"));
-        assertThat(actual.get(1).getKey(), is("encryptors/assisted_encryptor"));
-        assertThat(actual.get(1).getValue(), is("props:\n  aes-key-value: 123456abc\ntype: AES\n"));
+    private void assertEncryptors(final List<RepositoryTuple> actual, final Map<String, YamlAlgorithmConfiguration> expectedEncryptors) {
+        assertRepositoryTuple(actual.get(0), "encryptors/aes_encryptor", expectedEncryptors.get("aes_encryptor"));
+        assertRepositoryTuple(actual.get(1), "encryptors/assisted_encryptor", expectedEncryptors.get("assisted_encryptor"));
     }
     
-    private void assertTable(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("tables/t_user"));
-        assertThat(actual.getValue(), is("columns:\n  username:\n"
-                + "    assistedQuery:\n      encryptorName: assisted_encryptor\n      name: assisted_query_username\n    cipher:\n      encryptorName: aes_encryptor\n      name: username_cipher\n"));
+    private void assertTables(final RepositoryTuple actual, final Map<String, YamlEncryptTableRuleConfiguration> expectedTables) {
+        assertRepositoryTuple(actual, "tables/t_user", expectedTables.get("t_user"));
     }
 }
diff --git a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
index 6df297621f9..dd8f745457f 100644
--- a/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
+++ b/features/encrypt/core/src/test/resources/yaml/encrypt-rule.yaml
@@ -17,22 +17,22 @@
 
 rules:
 - !ENCRYPT
+  tables:
+    t_user:
+      columns:
+        username:
+          cipher:
+            name: username_cipher
+            encryptorName: aes_encryptor
+          assistedQuery:
+            name: assisted_query_username
+            encryptorName: assisted_encryptor
   encryptors:
     aes_encryptor:
+      type: AES
       props:
         aes-key-value: 123456abc
-      type: AES
     assisted_encryptor:
+      type: AES
       props:
         aes-key-value: 123456abc
-      type: AES
-  tables:
-    t_user:
-      columns:
-        username:
-          assistedQuery:
-            encryptorName: assisted_encryptor
-            name: assisted_query_username
-          cipher:
-            encryptorName: aes_encryptor
-            name: username_cipher
diff --git a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskConfigurationRepositoryTupleSwapperIT.java b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskConfigurationRepositoryTupleSwapperIT.java
index 38b3e7c869c..2c4541df9a4 100644
--- a/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskConfigurationRepositoryTupleSwapperIT.java
+++ b/features/mask/core/src/test/java/org/apache/shardingsphere/mask/it/MaskConfigurationRepositoryTupleSwapperIT.java
@@ -17,13 +17,18 @@
 
 package org.apache.shardingsphere.mask.it;
 
+import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.mask.yaml.config.YamlMaskRuleConfiguration;
+import org.apache.shardingsphere.mask.yaml.config.rule.YamlMaskTableRuleConfiguration;
 import org.apache.shardingsphere.mask.yaml.swapper.MaskRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -35,22 +40,19 @@ class MaskConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSwapperIT
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(3));
         List<RepositoryTuple> actual = new ArrayList<>(actualRepositoryTuples);
-        assertMaskAlgorithms(actual.subList(0, 2));
-        assertTable(actual.get(2));
+        assertMaskAlgorithms(actual.subList(0, 2), ((YamlMaskRuleConfiguration) expectedYamlRuleConfig).getMaskAlgorithms());
+        assertTable(actual.get(2), ((YamlMaskRuleConfiguration) expectedYamlRuleConfig).getTables());
     }
     
-    private void assertMaskAlgorithms(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("mask_algorithms/keep_first_n_last_m_mask"));
-        assertThat(actual.get(0).getValue(), is("props:\n  first-n: 3\n  replace-char: '*'\n  last-m: 4\ntype: KEEP_FIRST_N_LAST_M\n"));
-        assertThat(actual.get(1).getKey(), is("mask_algorithms/md5_mask"));
-        assertThat(actual.get(1).getValue(), is("type: MD5\n"));
+    private void assertMaskAlgorithms(final List<RepositoryTuple> actual, final Map<String, YamlAlgorithmConfiguration> expectedMaskAlgorithms) {
+        assertRepositoryTuple(actual.get(0), "mask_algorithms/keep_first_n_last_m_mask", expectedMaskAlgorithms.get("keep_first_n_last_m_mask"));
+        assertRepositoryTuple(actual.get(1), "mask_algorithms/md5_mask", expectedMaskAlgorithms.get("md5_mask"));
     }
     
-    private void assertTable(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("tables/t_user"));
-        assertThat(actual.getValue(), is("columns:\n  telephone:\n    maskAlgorithm: keep_first_n_last_m_mask\n  password:\n    maskAlgorithm: md5_mask\n"));
+    private void assertTable(final RepositoryTuple actual, final Map<String, YamlMaskTableRuleConfiguration> expectedTables) {
+        assertRepositoryTuple(actual, "tables/t_user", expectedTables.get("t_user"));
     }
 }
diff --git a/features/mask/core/src/test/resources/yaml/mask-rule.yaml b/features/mask/core/src/test/resources/yaml/mask-rule.yaml
index 2e537a27a42..6d43f43be9a 100644
--- a/features/mask/core/src/test/resources/yaml/mask-rule.yaml
+++ b/features/mask/core/src/test/resources/yaml/mask-rule.yaml
@@ -17,19 +17,19 @@
 
 rules:
 - !MASK
+  tables:
+    t_user:
+      columns:
+        telephone:
+          maskAlgorithm: keep_first_n_last_m_mask
+        password:
+          maskAlgorithm: md5_mask
   maskAlgorithms:
     keep_first_n_last_m_mask:
+      type: KEEP_FIRST_N_LAST_M
       props:
         first-n: 3
         replace-char: '*'
         last-m: 4
-      type: KEEP_FIRST_N_LAST_M
     md5_mask:
       type: MD5
-  tables:
-    t_user:
-      columns:
-        telephone:
-          maskAlgorithm: keep_first_n_last_m_mask
-        password:
-          maskAlgorithm: md5_mask
diff --git a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingConfigurationRepositoryTupleSwapperIT.java b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingConfigurationRepositoryTupleSwapperIT.java
index 07a191a8035..27ad15dbf7a 100644
--- a/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingConfigurationRepositoryTupleSwapperIT.java
+++ b/features/readwrite-splitting/core/src/test/java/org/apache/shardingsphere/readwritesplitting/it/ReadwriteSplittingConfigurationRepositoryTupleSwapperIT.java
@@ -17,13 +17,18 @@
 
 package org.apache.shardingsphere.readwritesplitting.it;
 
+import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.YamlReadwriteSplittingRuleConfiguration;
+import org.apache.shardingsphere.readwritesplitting.yaml.config.rule.YamlReadwriteSplittingDataSourceGroupRuleConfiguration;
 import org.apache.shardingsphere.readwritesplitting.yaml.swapper.ReadwriteSplittingRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -35,24 +40,20 @@ class ReadwriteSplittingConfigurationRepositoryTupleSwapperIT extends Repository
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(4));
         List<RepositoryTuple> actual = new ArrayList<>(actualRepositoryTuples);
-        assertLoadBalancers(actual.subList(0, 2));
-        assertDataSourceGroups(actual.subList(2, 4));
+        assertLoadBalancers(actual.subList(0, 2), ((YamlReadwriteSplittingRuleConfiguration) expectedYamlRuleConfig).getLoadBalancers());
+        assertDataSourceGroups(actual.subList(2, 4), ((YamlReadwriteSplittingRuleConfiguration) expectedYamlRuleConfig).getDataSourceGroups());
     }
     
-    private void assertLoadBalancers(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("load_balancers/random"));
-        assertThat(actual.get(0).getValue(), is("type: RANDOM\n"));
-        assertThat(actual.get(1).getKey(), is("load_balancers/roundRobin"));
-        assertThat(actual.get(1).getValue(), is("type: ROUND_ROBIN\n"));
+    private void assertLoadBalancers(final List<RepositoryTuple> actual, final Map<String, YamlAlgorithmConfiguration> expectedLoadBalancers) {
+        assertRepositoryTuple(actual.get(0), "load_balancers/random", expectedLoadBalancers.get("random"));
+        assertRepositoryTuple(actual.get(1), "load_balancers/roundRobin", expectedLoadBalancers.get("roundRobin"));
     }
     
-    private void assertDataSourceGroups(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("data_sources/ds_0"));
-        assertThat(actual.get(0).getValue(), is("loadBalancerName: roundRobin\nreadDataSourceNames:\n- write_ds_0_read_0\n- write_ds_0_read_1\nwriteDataSourceName: write_ds_0\n"));
-        assertThat(actual.get(1).getKey(), is("data_sources/ds_1"));
-        assertThat(actual.get(1).getValue(), is("loadBalancerName: random\nreadDataSourceNames:\n- write_ds_1_read_0\n- write_ds_1_read_1\nwriteDataSourceName: write_ds_1\n"));
+    private void assertDataSourceGroups(final List<RepositoryTuple> actual, final Map<String, YamlReadwriteSplittingDataSourceGroupRuleConfiguration> expectedDataSourceGroups) {
+        assertRepositoryTuple(actual.get(0), "data_sources/ds_0", expectedDataSourceGroups.get("ds_0"));
+        assertRepositoryTuple(actual.get(1), "data_sources/ds_1", expectedDataSourceGroups.get("ds_1"));
     }
 }
diff --git a/features/readwrite-splitting/core/src/test/resources/yaml/readwrite-splitting-rule.yaml b/features/readwrite-splitting/core/src/test/resources/yaml/readwrite-splitting-rule.yaml
index e980be6e899..79f1e9b7862 100644
--- a/features/readwrite-splitting/core/src/test/resources/yaml/readwrite-splitting-rule.yaml
+++ b/features/readwrite-splitting/core/src/test/resources/yaml/readwrite-splitting-rule.yaml
@@ -19,17 +19,17 @@ rules:
 - !READWRITE_SPLITTING
   dataSourceGroups:
     ds_0:
-      loadBalancerName: roundRobin
+      writeDataSourceName: write_ds_0
       readDataSourceNames:
       - write_ds_0_read_0
       - write_ds_0_read_1
-      writeDataSourceName: write_ds_0
+      loadBalancerName: roundRobin
     ds_1:
-      loadBalancerName: random
+      writeDataSourceName: write_ds_1
       readDataSourceNames:
       - write_ds_1_read_0
       - write_ds_1_read_1
-      writeDataSourceName: write_ds_1
+      loadBalancerName: random
   loadBalancers:
     random:
       type: RANDOM
diff --git a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationRepositoryTupleSwapperIT.java b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationRepositoryTupleSwapperIT.java
index 12db8fd2671..df1b111624a 100644
--- a/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/features/shadow/core/src/test/java/org/apache/shardingsphere/shadow/it/ShadowRuleConfigurationRepositoryTupleSwapperIT.java
@@ -17,13 +17,19 @@
 
 package org.apache.shardingsphere.shadow.it;
 
+import org.apache.shardingsphere.infra.algorithm.core.yaml.YamlAlgorithmConfiguration;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
+import org.apache.shardingsphere.shadow.yaml.config.YamlShadowRuleConfiguration;
+import org.apache.shardingsphere.shadow.yaml.config.datasource.YamlShadowDataSourceConfiguration;
+import org.apache.shardingsphere.shadow.yaml.config.table.YamlShadowTableConfiguration;
 import org.apache.shardingsphere.shadow.yaml.swapper.ShadowRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -35,44 +41,33 @@ class ShadowRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSwa
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(9));
         List<RepositoryTuple> actual = new ArrayList<>(actualRepositoryTuples);
-        assertAlgorithms(actual.subList(0, 4));
-        assertDefaultAlgorithm(actual.get(4));
-        assertDataSources(actual.get(5));
-        assertTables(actual.subList(6, 9));
+        assertAlgorithms(actual.subList(0, 4), ((YamlShadowRuleConfiguration) expectedYamlRuleConfig).getShadowAlgorithms());
+        assertDefaultAlgorithm(actual.get(4), ((YamlShadowRuleConfiguration) expectedYamlRuleConfig).getDefaultShadowAlgorithmName());
+        assertDataSources(actual.get(5), ((YamlShadowRuleConfiguration) expectedYamlRuleConfig).getDataSources());
+        assertTables(actual.subList(6, 9), ((YamlShadowRuleConfiguration) expectedYamlRuleConfig).getTables());
     }
     
-    private void assertAlgorithms(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("algorithms/user-id-insert-match-algorithm"));
-        assertThat(actual.get(0).getValue(), is("props:\n  regex: '[1]'\n  column: user_id\n  operation: insert\ntype: REGEX_MATCH\n"));
-        assertThat(actual.get(1).getKey(), is("algorithms/user-id-update-match-algorithm"));
-        assertThat(actual.get(1).getValue(), is("props:\n  regex: '[1]'\n  column: user_id\n  operation: update\ntype: REGEX_MATCH\n"));
-        assertThat(actual.get(2).getKey(), is("algorithms/user-id-select-match-algorithm"));
-        assertThat(actual.get(2).getValue(), is("props:\n  regex: '[1]'\n  column: user_id\n  operation: select\ntype: REGEX_MATCH\n"));
-        assertThat(actual.get(3).getKey(), is("algorithms/sql-hint-algorithm"));
-        assertThat(actual.get(3).getValue(), is("props:\n  shadow: true\n  foo: bar\ntype: SQL_HINT\n"));
+    private void assertAlgorithms(final List<RepositoryTuple> actual, final Map<String, YamlAlgorithmConfiguration> expectedAlgorithms) {
+        assertRepositoryTuple(actual.get(0), "algorithms/user-id-insert-match-algorithm", expectedAlgorithms.get("user-id-insert-match-algorithm"));
+        assertRepositoryTuple(actual.get(1), "algorithms/user-id-update-match-algorithm", expectedAlgorithms.get("user-id-update-match-algorithm"));
+        assertRepositoryTuple(actual.get(2), "algorithms/user-id-select-match-algorithm", expectedAlgorithms.get("user-id-select-match-algorithm"));
+        assertRepositoryTuple(actual.get(3), "algorithms/sql-hint-algorithm", expectedAlgorithms.get("sql-hint-algorithm"));
     }
     
-    private void assertDefaultAlgorithm(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("default_algorithm_name"));
-        assertThat(actual.getValue(), is("sql-hint-algorithm"));
+    private void assertDefaultAlgorithm(final RepositoryTuple actual, final String expectedDefaultShadowAlgorithmName) {
+        assertRepositoryTuple(actual, "default_algorithm_name", expectedDefaultShadowAlgorithmName);
     }
     
-    private void assertDataSources(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("data_sources/shadowDataSource"));
-        assertThat(actual.getValue(), is("productionDataSourceName: ds\nshadowDataSourceName: ds_shadow\n"));
+    private void assertDataSources(final RepositoryTuple actual, final Map<String, YamlShadowDataSourceConfiguration> expectedDataSources) {
+        assertRepositoryTuple(actual, "data_sources/shadowDataSource", expectedDataSources.get("shadowDataSource"));
     }
     
-    private void assertTables(final List<RepositoryTuple> actual) {
-        assertThat(actual.get(0).getKey(), is("tables/t_order"));
-        assertThat(actual.get(0).getValue(), is("dataSourceNames:\n- shadowDataSource\nshadowAlgorithmNames:\n- user-id-insert-match-algorithm\n- user-id-select-match-algorithm\n"));
-        assertThat(actual.get(1).getKey(), is("tables/t_order_item"));
-        assertThat(actual.get(1).getValue(), is("dataSourceNames:\n- shadowDataSource\n"
-                + "shadowAlgorithmNames:\n- user-id-insert-match-algorithm\n- user-id-update-match-algorithm\n- user-id-select-match-algorithm\n"));
-        assertThat(actual.get(2).getKey(), is("tables/t_address"));
-        assertThat(actual.get(2).getValue(), is("dataSourceNames:\n- shadowDataSource\n"
-                + "shadowAlgorithmNames:\n- user-id-insert-match-algorithm\n- user-id-select-match-algorithm\n- sql-hint-algorithm\n"));
+    private void assertTables(final List<RepositoryTuple> actual, final Map<String, YamlShadowTableConfiguration> expectedTables) {
+        assertRepositoryTuple(actual.get(0), "tables/t_order", expectedTables.get("t_order"));
+        assertRepositoryTuple(actual.get(1), "tables/t_order_item", expectedTables.get("t_order_item"));
+        assertRepositoryTuple(actual.get(2), "tables/t_address", expectedTables.get("t_address"));
     }
 }
diff --git a/features/shadow/core/src/test/resources/yaml/shadow-rule.yaml b/features/shadow/core/src/test/resources/yaml/shadow-rule.yaml
index ac285e5012a..9bb42824f3b 100644
--- a/features/shadow/core/src/test/resources/yaml/shadow-rule.yaml
+++ b/features/shadow/core/src/test/resources/yaml/shadow-rule.yaml
@@ -21,49 +21,49 @@ rules:
     shadowDataSource:
       productionDataSourceName: ds
       shadowDataSourceName: ds_shadow
-  defaultShadowAlgorithmName: sql-hint-algorithm
+  tables:
+    t_order:
+      dataSourceNames:
+        - shadowDataSource
+      shadowAlgorithmNames:
+        - user-id-insert-match-algorithm
+        - user-id-select-match-algorithm
+    t_order_item:
+      dataSourceNames:
+        - shadowDataSource
+      shadowAlgorithmNames:
+        - user-id-insert-match-algorithm
+        - user-id-update-match-algorithm
+        - user-id-select-match-algorithm
+    t_address:
+      dataSourceNames:
+        - shadowDataSource
+      shadowAlgorithmNames:
+        - user-id-insert-match-algorithm
+        - user-id-select-match-algorithm
+        - sql-hint-algorithm
   shadowAlgorithms:
     user-id-insert-match-algorithm:
+      type: REGEX_MATCH
       props:
         regex: '[1]'
         column: user_id
         operation: insert
-      type: REGEX_MATCH
     user-id-update-match-algorithm:
+      type: REGEX_MATCH
       props:
         regex: '[1]'
         column: user_id
         operation: update
-      type: REGEX_MATCH
     user-id-select-match-algorithm:
+      type: REGEX_MATCH
       props:
         regex: '[1]'
         column: user_id
         operation: select
-      type: REGEX_MATCH
     sql-hint-algorithm:
+      type: SQL_HINT
       props:
         shadow: true
         foo: bar
-      type: SQL_HINT
-  tables:
-    t_order:
-      dataSourceNames:
-      - shadowDataSource
-      shadowAlgorithmNames:
-      - user-id-insert-match-algorithm
-      - user-id-select-match-algorithm
-    t_order_item:
-      dataSourceNames:
-      - shadowDataSource
-      shadowAlgorithmNames:
-      - user-id-insert-match-algorithm
-      - user-id-update-match-algorithm
-      - user-id-select-match-algorithm
-    t_address:
-      dataSourceNames:
-      - shadowDataSource
-      shadowAlgorithmNames:
-      - user-id-insert-match-algorithm
-      - user-id-select-match-algorithm
-      - sql-hint-algorithm
+  defaultShadowAlgorithmName: sql-hint-algorithm
diff --git a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationRepositoryTupleSwapperIT.java
index ed0bd76fe07..55af011b59b 100644
--- a/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/authority/core/src/test/java/org/apache/shardingsphere/authority/it/AuthorityRuleConfigurationRepositoryTupleSwapperIT.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.authority.it;
 
 import org.apache.shardingsphere.authority.yaml.swapper.AuthorityRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,15 +34,8 @@ class AuthorityRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTuple
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertAuthority(iterator.next());
-    }
-    
-    private void assertAuthority(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("authority"));
-        assertThat(actual.getValue(), is("authenticators:\n  fixture:\n    type: FIXTURE\ndefaultAuthenticator: fixture\nprivilege:\n  type: ALL_PERMITTED\n"
-                + "users:\n- admin: true\n  password: root\n  user: root@%\n- admin: false\n  password: sharding\n  user: sharding@\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "authority", expectedYamlRuleConfig);
     }
 }
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 b77dd0324c5..c0afd337893 100644
--- a/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml
+++ b/kernel/authority/core/src/test/resources/yaml/authority-rule.yaml
@@ -17,16 +17,16 @@
 
 rules:
 - !AUTHORITY
+  users:
+    - user: root@%
+      password: root
+      admin: true
+    - user: sharding@
+      password: sharding
+      admin: false
+  privilege:
+    type: ALL_PERMITTED
   authenticators:
     fixture:
       type: FIXTURE
   defaultAuthenticator: fixture
-  privilege:
-    type: ALL_PERMITTED
-  users:
-  - admin: true
-    password: root
-    user: root@%
-  - admin: false
-    password: sharding
-    user: sharding@
diff --git a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationRepositoryTupleSwapperIT.java
index 2f3df214929..72fe95bcd3b 100644
--- a/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/global-clock/core/src/test/java/org/apache/shardingsphere/globalclock/it/GlobalClockRuleConfigurationRepositoryTupleSwapperIT.java
@@ -19,10 +19,10 @@ package org.apache.shardingsphere.globalclock.it;
 
 import org.apache.shardingsphere.globalclock.yaml.swapper.GlobalClockRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class GlobalClockRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTup
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertGlobalClock(iterator.next());
-    }
-    
-    private void assertGlobalClock(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("global_clock"));
-        assertThat(actual.getValue(), is("enabled: true\nprops:\n  k0: v0\n  k1: v1\nprovider: FIXTURE\ntype: FIXTURE\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "global_clock", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/global-clock/core/src/test/resources/yaml/global-clock-rule.yaml b/kernel/global-clock/core/src/test/resources/yaml/global-clock-rule.yaml
index 928a8b8ad6e..c45f2595e5a 100644
--- a/kernel/global-clock/core/src/test/resources/yaml/global-clock-rule.yaml
+++ b/kernel/global-clock/core/src/test/resources/yaml/global-clock-rule.yaml
@@ -17,9 +17,9 @@
 
 rules:
 - !GLOBAL_CLOCK
+  type: FIXTURE
+  provider: FIXTURE
   enabled: true
   props:
     k0: v0
     k1: v1
-  provider: FIXTURE
-  type: FIXTURE
diff --git a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationRepositoryTupleSwapperIT.java
index 9e737e7af51..85c6a42ad5b 100644
--- a/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/logging/core/src/test/java/org/apache/shardingsphere/logging/it/LoggingRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.logging.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.logging.yaml.swapper.LoggingRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,15 +34,8 @@ class LoggingRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSw
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertLogging(iterator.next());
-    }
-    
-    private void assertLogging(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("logging"));
-        assertThat(actual.getValue(), is("appenders:\n- appenderClass: foo_appender_class\n  appenderName: foo_appender\n  file: foo_file\n  pattern: sss\n"
-                + "loggers:\n- additivity: true\n  appenderName: foo_appender\n  level: INFO\n  loggerName: foo_logger\n  props:\n    k0: v0\n    k1: v1\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "logging", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/logging/core/src/test/resources/yaml/logging-rule.yaml b/kernel/logging/core/src/test/resources/yaml/logging-rule.yaml
index 07c09451218..24a1e68dd01 100644
--- a/kernel/logging/core/src/test/resources/yaml/logging-rule.yaml
+++ b/kernel/logging/core/src/test/resources/yaml/logging-rule.yaml
@@ -17,16 +17,16 @@
 
 rules:
 - !LOGGING
-  appenders:
-  - appenderClass: foo_appender_class
-    appenderName: foo_appender
-    file: foo_file
-    pattern: sss
   loggers:
-  - additivity: true
-    appenderName: foo_appender
+  - loggerName: foo_logger
     level: INFO
-    loggerName: foo_logger
+    additivity: true
+    appenderName: foo_appender
     props:
       k0: v0
       k1: v1
+  appenders:
+    - appenderName: foo_appender
+      appenderClass: foo_appender_class
+      pattern: sss
+      file: foo_file
diff --git a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperIT.java
index bfa5dd746a8..ec4d5c4ef72 100644
--- a/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/single/core/src/test/java/org/apache/shardingsphere/single/it/SingleRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.single.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.single.yaml.config.swapper.SingleRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class SingleRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSwa
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSingle(iterator.next());
-    }
-    
-    private void assertSingle(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("tables"));
-        assertThat(actual.getValue(), is("defaultDataSource: foo_ds\ntables:\n- foo_tbl\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "tables", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/single/core/src/test/resources/yaml/single-rule.yaml b/kernel/single/core/src/test/resources/yaml/single-rule.yaml
index 89c83612994..8ac6b4609c1 100644
--- a/kernel/single/core/src/test/resources/yaml/single-rule.yaml
+++ b/kernel/single/core/src/test/resources/yaml/single-rule.yaml
@@ -17,6 +17,6 @@
 
 rules:
 - !SINGLE
-  defaultDataSource: foo_ds
   tables:
   - foo_tbl
+  defaultDataSource: foo_ds
diff --git a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationRepositoryTupleSwapperIT.java
index 3afec75e1b5..80fc94fdc86 100644
--- a/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/sql-federation/core/src/test/java/org/apache/shardingsphere/sqlfederation/it/SQLFederationRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.sqlfederation.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.sqlfederation.yaml.swapper.SQLFederationRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class SQLFederationRuleConfigurationRepositoryTupleSwapperIT extends RepositoryT
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSQLFederation(iterator.next());
-    }
-    
-    private void assertSQLFederation(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("sql_federation"));
-        assertThat(actual.getValue(), is("allQueryUseSQLFederation: true\nexecutionPlanCache:\n  initialCapacity: 128\n  maximumSize: 1024\nsqlFederationEnabled: true\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "sql_federation", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/sql-federation/core/src/test/resources/yaml/sql-federation-rule.yaml b/kernel/sql-federation/core/src/test/resources/yaml/sql-federation-rule.yaml
index e3b4af2f693..c6cc78ddf60 100644
--- a/kernel/sql-federation/core/src/test/resources/yaml/sql-federation-rule.yaml
+++ b/kernel/sql-federation/core/src/test/resources/yaml/sql-federation-rule.yaml
@@ -17,8 +17,8 @@
 
 rules:
 - !SQL_FEDERATION
+  sqlFederationEnabled: true
   allQueryUseSQLFederation: true
   executionPlanCache:
     initialCapacity: 128
     maximumSize: 1024
-  sqlFederationEnabled: true
diff --git a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationRepositoryTupleSwapperIT.java
index b167e7178e5..63653d20973 100644
--- a/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/sql-parser/core/src/test/java/org/apache/shardingsphere/parser/it/SQLParserRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.parser.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.parser.yaml.swapper.SQLParserRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class SQLParserRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTuple
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSQLParser(iterator.next());
-    }
-    
-    private void assertSQLParser(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("sql_parser"));
-        assertThat(actual.getValue(), is("parseTreeCache:\n  initialCapacity: 128\n  maximumSize: 1024\nsqlStatementCache:\n  initialCapacity: 256\n  maximumSize: 4096\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "sql_parser", expectedYamlRuleConfig);
     }
 }
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 777f85a5456..168ce49e551 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,10 +17,9 @@
 
 rules:
 - !SQL_PARSER
-  parseTreeCache:
-    initialCapacity: 128
-    maximumSize: 1024
   sqlStatementCache:
     initialCapacity: 256
     maximumSize: 4096
-
+  parseTreeCache:
+    initialCapacity: 128
+    maximumSize: 1024
diff --git a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationRepositoryTupleSwapperIT.java
index 94c9ee60905..3fa48955a90 100644
--- a/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/sql-translator/core/src/test/java/org/apache/shardingsphere/sqltranslator/it/SQLTranslatorRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.sqltranslator.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.sqltranslator.yaml.swapper.SQLTranslatorRuleConfigurationRepositoryTupleSwapper;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class SQLTranslatorRuleConfigurationRepositoryTupleSwapperIT extends RepositoryT
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSQLParser(iterator.next());
-    }
-    
-    private void assertSQLParser(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("sql_translator"));
-        assertThat(actual.getValue(), is("props:\n  k0: v0\n  k1: v1\ntype: FIXTURE\nuseOriginalSQLWhenTranslatingFailed: true\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "sql_translator", expectedYamlRuleConfig);
     }
 }
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 12e33ba9517..e91c78a05be 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
@@ -17,8 +17,8 @@
 
 rules:
 - !SQL_TRANSLATOR
+  type: FIXTURE
   props:
     k0: v0
     k1: v1
-  type: FIXTURE
   useOriginalSQLWhenTranslatingFailed: true
diff --git a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/it/TrafficRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/it/TrafficRuleConfigurationRepositoryTupleSwapperIT.java
index bdb32706e7f..a1efc84e05f 100644
--- a/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/it/TrafficRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/traffic/core/src/test/java/org/apache/shardingsphere/traffic/it/TrafficRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.traffic.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 import org.apache.shardingsphere.traffic.yaml.swapper.TrafficRuleConfigurationRepositoryTupleSwapper;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,15 +34,8 @@ class TrafficRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTupleSw
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSQLParser(iterator.next());
-    }
-    
-    private void assertSQLParser(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("traffic"));
-        assertThat(actual.getValue(), is("loadBalancers:\n  foo_load_balancers:\n    type: LOAD_BALANCER_FIXTURE\ntrafficAlgorithms:\n  foo_traffic:\n    type: TRAFFIC_FIXTURE\n"
-                + "trafficStrategies:\n  foo_strategy:\n    algorithmName: foo_traffic\n    labels:\n    - label_0\n    - label_1\n    loadBalancerName: foo_loadbalancer\n    name: foo_strategy\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "traffic", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/traffic/core/src/test/resources/yaml/traffic-rule.yaml b/kernel/traffic/core/src/test/resources/yaml/traffic-rule.yaml
index 258aba60201..a298353fbc6 100644
--- a/kernel/traffic/core/src/test/resources/yaml/traffic-rule.yaml
+++ b/kernel/traffic/core/src/test/resources/yaml/traffic-rule.yaml
@@ -17,17 +17,17 @@
 
 rules:
 - !TRAFFIC
+  trafficStrategies:
+    foo_strategy:
+      name: foo_strategy
+      labels:
+        - label_0
+        - label_1
+      algorithmName: foo_traffic
+      loadBalancerName: foo_loadbalancer
   loadBalancers:
     foo_load_balancers:
       type: LOAD_BALANCER_FIXTURE
   trafficAlgorithms:
     foo_traffic:
       type: TRAFFIC_FIXTURE
-  trafficStrategies:
-    foo_strategy:
-      algorithmName: foo_traffic
-      labels:
-      - label_0
-      - label_1
-      loadBalancerName: foo_loadbalancer
-      name: foo_strategy
diff --git a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationRepositoryTupleSwapperIT.java b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationRepositoryTupleSwapperIT.java
index 30e7aef4428..60cd8cbcf1d 100644
--- a/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationRepositoryTupleSwapperIT.java
+++ b/kernel/transaction/core/src/test/java/org/apache/shardingsphere/transaction/it/TransactionRuleConfigurationRepositoryTupleSwapperIT.java
@@ -18,11 +18,11 @@
 package org.apache.shardingsphere.transaction.it;
 
 import org.apache.shardingsphere.infra.util.yaml.datanode.RepositoryTuple;
+import org.apache.shardingsphere.infra.yaml.config.pojo.rule.YamlRuleConfiguration;
 import org.apache.shardingsphere.test.it.yaml.RepositoryTupleSwapperIT;
 import org.apache.shardingsphere.transaction.yaml.swapper.TransactionRuleConfigurationRepositoryTupleSwapper;
 
 import java.util.Collection;
-import java.util.Iterator;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -34,14 +34,8 @@ class TransactionRuleConfigurationRepositoryTupleSwapperIT extends RepositoryTup
     }
     
     @Override
-    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples) {
+    protected void assertRepositoryTuples(final Collection<RepositoryTuple> actualRepositoryTuples, final YamlRuleConfiguration expectedYamlRuleConfig) {
         assertThat(actualRepositoryTuples.size(), is(1));
-        Iterator<RepositoryTuple> iterator = actualRepositoryTuples.iterator();
-        assertSQLParser(iterator.next());
-    }
-    
-    private void assertSQLParser(final RepositoryTuple actual) {
-        assertThat(actual.getKey(), is("transaction"));
-        assertThat(actual.getValue(), is("defaultType: XA\nprops:\n  k0: v0\n  k1: v1\nproviderType: FIXTURE\n"));
+        assertRepositoryTuple(actualRepositoryTuples.iterator().next(), "transaction", expectedYamlRuleConfig);
     }
 }
diff --git a/kernel/transaction/core/src/test/resources/yaml/transaction-rule.yaml b/kernel/transaction/core/src/test/resources/yaml/transaction-rule.yaml
index 5eac5cc9e71..d3c99917006 100644
--- a/kernel/transaction/core/src/test/resources/yaml/transaction-rule.yaml
+++ b/kernel/transaction/core/src/test/resources/yaml/transaction-rule.yaml
@@ -18,7 +18,7 @@
 rules:
 - !TRANSACTION
   defaultType: XA
+  providerType: FIXTURE
   props:
     k0: v0
     k1: v1
-  providerType: FIXTURE
diff --git a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
index 5ff294a59e3..c34f55945d6 100644
--- a/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
+++ b/test/it/yaml/src/main/java/org/apache/shardingsphere/test/it/yaml/RepositoryTupleSwapperIT.java
@@ -30,6 +30,7 @@ import java.net.URL;
 import java.nio.file.Files;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Map;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -56,19 +57,29 @@ public abstract class RepositoryTupleSwapperIT {
         this.isGlobalRule = isGlobalRule;
     }
     
+    @SuppressWarnings("unchecked")
     @Test
     void assertSwapToRepositoryTuples() throws IOException {
-        assertRepositoryTuples(getRepositoryTuples());
+        YamlRuleConfiguration yamlRuleConfig = loadYamlRuleConfiguration();
+        assertRepositoryTuples((Collection<RepositoryTuple>) swapper.swapToRepositoryTuples(yamlRuleConfig), yamlRuleConfig);
     }
     
-    @SuppressWarnings("unchecked")
-    private Collection<RepositoryTuple> getRepositoryTuples() throws IOException {
+    private YamlRuleConfiguration loadYamlRuleConfiguration() throws IOException {
         YamlRootConfiguration yamlRootConfig = YamlEngine.unmarshal(yamlFile, YamlRootConfiguration.class);
         assertThat(yamlRootConfig.getRules().size(), is(1));
-        return (Collection<RepositoryTuple>) swapper.swapToRepositoryTuples(yamlRootConfig.getRules().iterator().next());
+        return yamlRootConfig.getRules().iterator().next();
+    }
+    
+    protected abstract void assertRepositoryTuples(Collection<RepositoryTuple> actualRepositoryTuples, YamlRuleConfiguration expectedYamlRuleConfig);
+    
+    protected void assertRepositoryTuple(final RepositoryTuple actual, final String expectedKey, final Object expectedValue) {
+        assertThat(actual.getKey(), is(expectedKey));
+        assertThat(actual.getValue(), is(isSimpleObject(expectedValue) ? expectedValue : YamlEngine.marshal(expectedValue)));
     }
     
-    protected abstract void assertRepositoryTuples(Collection<RepositoryTuple> actualRepositoryTuples);
+    private boolean isSimpleObject(final Object expectedValue) {
+        return expectedValue instanceof Boolean || expectedValue instanceof Integer || expectedValue instanceof Long || expectedValue instanceof String;
+    }
     
     @Test
     void assertSwapToObject() throws IOException {
@@ -77,7 +88,9 @@ public abstract class RepositoryTupleSwapperIT {
     
     @SuppressWarnings("unchecked")
     private String getActualYamlContent() throws IOException {
-        Collection<RepositoryTuple> repositoryTuples = getRepositoryTuples().stream().map(each -> new RepositoryTuple(getRepositoryTupleKey(each), each.getValue())).collect(Collectors.toList());
+        YamlRuleConfiguration yamlRuleConfig = loadYamlRuleConfiguration();
+        Collection<RepositoryTuple> repositoryTuples = ((Collection<RepositoryTuple>) swapper.swapToRepositoryTuples(yamlRuleConfig)).stream()
+                .map(each -> new RepositoryTuple(getRepositoryTupleKey(each), each.getValue())).collect(Collectors.toList());
         Optional<YamlRuleConfiguration> actualYamlRuleConfig = swapper.swapToObject(repositoryTuples);
         assertTrue(actualYamlRuleConfig.isPresent());
         YamlRootConfiguration yamlRootConfig = new YamlRootConfiguration();
@@ -92,6 +105,8 @@ public abstract class RepositoryTupleSwapperIT {
     }
     
     private String getExpectedYamlContent() throws IOException {
-        return Files.readAllLines(yamlFile.toPath()).stream().filter(each -> !each.contains("#") && !each.isEmpty()).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator();
+        String content = Files.readAllLines(yamlFile.toPath()).stream()
+                .filter(each -> !each.contains("#") && !each.isEmpty()).collect(Collectors.joining(System.lineSeparator())) + System.lineSeparator();
+        return YamlEngine.marshal(YamlEngine.unmarshal(content, Map.class));
     }
 }