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 7bc09f65abe Refactor test methods to improve readability and reduce 
duplication (#37167)
7bc09f65abe is described below

commit 7bc09f65abe778657fd81d8c1343f232a6dc9e47
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Nov 23 16:24:34 2025 +0800

    Refactor test methods to improve readability and reduce duplication (#37167)
    
    * Refactor test methods to improve readability and reduce duplication
    
    * Refactor test methods to improve readability and reduce duplication
---
 .../EncryptOrderByItemSupportedCheckerTest.java    | 13 ++++++---
 .../EncryptShowCreateTableMergedResultTest.java    | 18 +++++++-----
 .../EncryptGroupByItemTokenGeneratorTest.java      | 15 ++++++----
 .../yaml/EncryptRuleConfigurationYamlIT.java       | 17 ++++++++----
 ...yptRuleConfigurationToDistSQLConverterTest.java | 25 +++++++++++------
 .../merge/dql/ShardingDQLResultMergerTest.java     | 20 ++++++--------
 .../sharding/rule/ShardingTableTest.java           | 14 ++++++----
 .../type/dml/UpdateStatementContextTest.java       | 23 ++++++++++------
 .../dal/AnalyzeTableStatementBinderTest.java       | 14 ++++++----
 .../YamlDataSourceConfigurationSwapperTest.java    | 24 +++++++++-------
 .../sql/context/ExecutionContextBuilderTest.java   | 20 ++++++++------
 .../table/MatchingTableInventoryChecker.java       | 13 ++++++---
 .../YamlCDCJobConfigurationSwapperTest.java        | 23 ++++++++++------
 .../tuple/YamlRuleNodeTupleSwapperEngineTest.java  | 32 ++++++++++++----------
 .../core/extractor/ExpressionExtractorTest.java    | 24 ++++++++++------
 .../core/extractor/WhereExtractorTest.java         | 17 ++++++++----
 ...irebirdPrepareStatementCommandExecutorTest.java | 15 ++++++----
 .../prepare/MySQLComStmtPrepareExecutorTest.java   | 12 ++++----
 .../query/MySQLComQueryPacketExecutorTest.java     | 12 ++++----
 .../command/query/extended/PortalTest.java         | 21 +++++++-------
 .../parse/PostgreSQLComParseExecutorTest.java      | 15 ++++++----
 ...lineProcessConfigurationPersistServiceTest.java | 23 ++++++++++------
 22 files changed, 250 insertions(+), 160 deletions(-)

diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
index 4c2885062b5..600faab9162 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/checker/sql/orderby/EncryptOrderByItemSupportedCheckerTest.java
@@ -117,10 +117,7 @@ class EncryptOrderByItemSupportedCheckerTest {
     private SelectStatementContext mockSelectStatementContext(final String 
tableName) {
         SimpleTableSegment simpleTableSegment = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue(tableName)));
         simpleTableSegment.setAlias(new AliasSegment(0, 0, new 
IdentifierValue("a")));
-        ColumnSegment columnSegment = new ColumnSegment(0, 0, new 
IdentifierValue("foo_col"));
-        columnSegment.setOwner(new OwnerSegment(0, 0, new 
IdentifierValue("a")));
-        TableSegmentBoundInfo tableSegmentBoundInfo = new 
TableSegmentBoundInfo(new IdentifierValue("foo_db"), new 
IdentifierValue("foo_db"));
-        columnSegment.setColumnBoundInfo(new 
ColumnSegmentBoundInfo(tableSegmentBoundInfo, new IdentifierValue(tableName), 
new IdentifierValue("foo_col"), TableSourceType.TEMPORARY_TABLE));
+        ColumnSegment columnSegment = getColumnSegment(tableName);
         SelectStatementContext result = mock(SelectStatementContext.class, 
RETURNS_DEEP_STUBS);
         
when(result.getSqlStatement().getDatabaseType()).thenReturn(databaseType);
         ColumnOrderByItemSegment columnOrderByItemSegment = new 
ColumnOrderByItemSegment(columnSegment, OrderDirection.ASC, 
NullsOrderType.FIRST);
@@ -131,4 +128,12 @@ class EncryptOrderByItemSupportedCheckerTest {
         when(result.getTablesContext()).thenReturn(new 
TablesContext(Collections.singleton(simpleTableSegment)));
         return result;
     }
+    
+    private ColumnSegment getColumnSegment(final String tableName) {
+        ColumnSegment result = new ColumnSegment(0, 0, new 
IdentifierValue("foo_col"));
+        result.setOwner(new OwnerSegment(0, 0, new IdentifierValue("a")));
+        TableSegmentBoundInfo tableSegmentBoundInfo = new 
TableSegmentBoundInfo(new IdentifierValue("foo_db"), new 
IdentifierValue("foo_db"));
+        result.setColumnBoundInfo(new 
ColumnSegmentBoundInfo(tableSegmentBoundInfo, new IdentifierValue(tableName), 
new IdentifierValue("foo_col"), TableSourceType.TEMPORARY_TABLE));
+        return result;
+    }
 }
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
index b74f2d3df45..67826f7afd6 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/merge/dal/show/EncryptShowCreateTableMergedResultTest.java
@@ -145,17 +145,21 @@ class EncryptShowCreateTableMergedResultTest {
         String actualSQL = "CREATE TABLE `foo_tbl` (`id` INT NOT NULL, 
`user_id_cipher` VARCHAR(100) NOT NULL, `user_id_like` VARCHAR(100) NOT NULL, "
                 + "`order_id_cipher` VARCHAR(30) NOT NULL, `order_id_like` 
VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT 
CHARSET=utf8mb4;";
         when(mergedResult.getValue(2, String.class)).thenReturn(actualSQL);
-        Collection<EncryptColumnRuleConfiguration> columns = new 
LinkedList<>();
+        EncryptShowCreateTableMergedResult actual = 
createMergedResult(mergedResult, "foo_tbl", 
mockEncryptRule(getEncryptColumnRuleConfigurations()));
+        assertTrue(actual.next());
+        String expectedSQL = "CREATE TABLE `foo_tbl` (`id` INT NOT NULL, 
`user_id` VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL, PRIMARY KEY 
(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
+        assertThat(actual.getValue(2, String.class), is(expectedSQL));
+    }
+    
+    private Collection<EncryptColumnRuleConfiguration> 
getEncryptColumnRuleConfigurations() {
+        Collection<EncryptColumnRuleConfiguration> result = new LinkedList<>();
         EncryptColumnRuleConfiguration userIdColumnConfig = new 
EncryptColumnRuleConfiguration("user_id", new 
EncryptColumnItemRuleConfiguration("user_id_cipher", "foo_encryptor"));
         userIdColumnConfig.setLikeQuery(new 
EncryptColumnItemRuleConfiguration("user_id_like", "foo_like_encryptor"));
-        columns.add(userIdColumnConfig);
+        result.add(userIdColumnConfig);
         EncryptColumnRuleConfiguration orderIdColumnConfig = new 
EncryptColumnRuleConfiguration("order_id", new 
EncryptColumnItemRuleConfiguration("order_id_cipher", "foo_encryptor"));
         orderIdColumnConfig.setLikeQuery(new 
EncryptColumnItemRuleConfiguration("order_id_like", "foo_like_encryptor"));
-        columns.add(orderIdColumnConfig);
-        EncryptShowCreateTableMergedResult actual = 
createMergedResult(mergedResult, "foo_tbl", mockEncryptRule(columns));
-        assertTrue(actual.next());
-        String expectedSQL = "CREATE TABLE `foo_tbl` (`id` INT NOT NULL, 
`user_id` VARCHAR(100) NOT NULL, `order_id` VARCHAR(30) NOT NULL, PRIMARY KEY 
(`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;";
-        assertThat(actual.getValue(2, String.class), is(expectedSQL));
+        result.add(orderIdColumnConfig);
+        return result;
     }
     
     @Test
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
index f6892d9fabb..d94bfca6a07 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/rewrite/token/generator/select/EncryptGroupByItemTokenGeneratorTest.java
@@ -79,18 +79,21 @@ class EncryptGroupByItemTokenGeneratorTest {
     private SelectStatementContext buildSelectStatementContext() {
         SimpleTableSegment simpleTableSegment = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("t_encrypt")));
         simpleTableSegment.setAlias(new AliasSegment(0, 0, new 
IdentifierValue("a")));
-        ColumnSegment columnSegment = new ColumnSegment(0, 0, new 
IdentifierValue("certificate_number"));
-        TableSegmentBoundInfo tableSegmentBoundInfo = new 
TableSegmentBoundInfo(new IdentifierValue("foo_db"), new 
IdentifierValue("foo_db"));
-        columnSegment
-                .setColumnBoundInfo(new 
ColumnSegmentBoundInfo(tableSegmentBoundInfo, new IdentifierValue("t_encrypt"), 
new IdentifierValue("certificate_number"), TableSourceType.TEMPORARY_TABLE));
-        columnSegment.setOwner(new OwnerSegment(0, 0, new 
IdentifierValue("a")));
         SelectStatementContext result = mock(SelectStatementContext.class, 
RETURNS_DEEP_STUBS);
         
when(result.getSqlStatement().getDatabaseType()).thenReturn(databaseType);
-        ColumnOrderByItemSegment columnOrderByItemSegment = new 
ColumnOrderByItemSegment(columnSegment, OrderDirection.ASC, 
NullsOrderType.FIRST);
+        ColumnOrderByItemSegment columnOrderByItemSegment = new 
ColumnOrderByItemSegment(getColumnSegment(), OrderDirection.ASC, 
NullsOrderType.FIRST);
         OrderByItem orderByItem = new OrderByItem(columnOrderByItemSegment);
         
when(result.getGroupByContext().getItems()).thenReturn(Collections.singleton(orderByItem));
         
when(result.getSubqueryContexts().values()).thenReturn(Collections.emptyList());
         when(result.getTablesContext()).thenReturn(new 
TablesContext(Collections.singleton(simpleTableSegment)));
         return result;
     }
+    
+    private ColumnSegment getColumnSegment() {
+        ColumnSegment result = new ColumnSegment(0, 0, new 
IdentifierValue("certificate_number"));
+        TableSegmentBoundInfo tableSegmentBoundInfo = new 
TableSegmentBoundInfo(new IdentifierValue("foo_db"), new 
IdentifierValue("foo_db"));
+        result.setColumnBoundInfo(new 
ColumnSegmentBoundInfo(tableSegmentBoundInfo, new IdentifierValue("t_encrypt"), 
new IdentifierValue("certificate_number"), TableSourceType.TEMPORARY_TABLE));
+        result.setOwner(new OwnerSegment(0, 0, new IdentifierValue("a")));
+        return result;
+    }
 }
diff --git 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
index 026b359f1a7..be3a0a23ab9 100644
--- 
a/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
+++ 
b/features/encrypt/core/src/test/java/org/apache/shardingsphere/encrypt/yaml/EncryptRuleConfigurationYamlIT.java
@@ -45,15 +45,22 @@ class EncryptRuleConfigurationYamlIT extends 
YamlRuleConfigurationIT {
     }
     
     private static EncryptRuleConfiguration getExpectedRuleConfiguration() {
+        return new 
EncryptRuleConfiguration(getEncryptTableRuleConfigurations(), 
createAlgorithmConfigurationMap());
+    }
+    
+    private static Collection<EncryptTableRuleConfiguration> 
getEncryptTableRuleConfigurations() {
         EncryptColumnRuleConfiguration encryptColumnRuleConfig = new 
EncryptColumnRuleConfiguration("username",
                 new EncryptColumnItemRuleConfiguration("username_cipher", 
"aes_encryptor"));
         encryptColumnRuleConfig.setAssistedQuery(new 
EncryptColumnItemRuleConfiguration("assisted_query_username", 
"assisted_encryptor"));
         EncryptTableRuleConfiguration tableRuleConfig = new 
EncryptTableRuleConfiguration("t_user", 
Collections.singletonList(encryptColumnRuleConfig));
-        Collection<EncryptTableRuleConfiguration> tables = 
Collections.singletonList(tableRuleConfig);
-        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);
+        return Collections.singletonList(tableRuleConfig);
+    }
+    
+    private static Map<String, AlgorithmConfiguration> 
createAlgorithmConfigurationMap() {
+        Map<String, AlgorithmConfiguration> result = new LinkedHashMap<>(2, 
1F);
+        result.put("aes_encryptor", new AlgorithmConfiguration("AES", 
PropertiesBuilder.build(new Property("aes-key-value", "123456abc"), new 
Property("digest-algorithm-name", "SHA-1"))));
+        result.put("assisted_encryptor", new AlgorithmConfiguration("AES", 
PropertiesBuilder.build(new Property("aes-key-value", "123456abc"), new 
Property("digest-algorithm-name", "SHA-1"))));
+        return result;
     }
     
     @Override
diff --git 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleConfigurationToDistSQLConverterTest.java
 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleConfigurationToDistSQLConverterTest.java
index 2fc425be5e1..ae06ad76ff4 100644
--- 
a/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleConfigurationToDistSQLConverterTest.java
+++ 
b/features/encrypt/distsql/handler/src/test/java/org/apache/shardingsphere/encrypt/distsql/handler/converter/EncryptRuleConfigurationToDistSQLConverterTest.java
@@ -47,7 +47,7 @@ class EncryptRuleConfigurationToDistSQLConverterTest {
     
     @Test
     void assertConvert() {
-        EncryptRuleConfiguration ruleConfig = getEncryptRuleConfiguration();
+        EncryptRuleConfiguration ruleConfig = createEncryptRuleConfiguration();
         assertThat(converter.convert(ruleConfig),
                 is("CREATE ENCRYPT RULE foo_tbl ("
                         + System.lineSeparator()
@@ -69,15 +69,24 @@ class EncryptRuleConfigurationToDistSQLConverterTest {
                         + "));"));
     }
     
-    private EncryptRuleConfiguration getEncryptRuleConfiguration() {
+    private EncryptRuleConfiguration createEncryptRuleConfiguration() {
         EncryptColumnRuleConfiguration encryptColumnRuleConfig1 = new 
EncryptColumnRuleConfiguration("foo_col", new 
EncryptColumnItemRuleConfiguration("foo_col_cipher", "test"));
-        EncryptColumnRuleConfiguration encryptColumnRuleConfig2 = new 
EncryptColumnRuleConfiguration("bar_col", new 
EncryptColumnItemRuleConfiguration("bar_col_cipher", "test"));
-        encryptColumnRuleConfig2.setAssistedQuery(new 
EncryptColumnItemRuleConfiguration("bar_col_assisted", 
"bar_assist_query_encryptor"));
-        encryptColumnRuleConfig2.setLikeQuery(new 
EncryptColumnItemRuleConfiguration("bar_col_like", "bar_like_encryptor"));
-        EncryptTableRuleConfiguration encryptTableRuleConfig = new 
EncryptTableRuleConfiguration("foo_tbl", new 
LinkedList<>(Arrays.asList(encryptColumnRuleConfig1, 
encryptColumnRuleConfig2)));
+        EncryptColumnRuleConfiguration encryptColumnRuleConfig2 = 
createEncryptColumnRuleConfiguration();
+        EncryptTableRuleConfiguration encryptTableRuleConfig = 
createEncryptTableRuleConfiguration(encryptColumnRuleConfig1, 
encryptColumnRuleConfig2);
         AlgorithmConfiguration shardingSphereAlgorithmConfig = new 
AlgorithmConfiguration("md5", new Properties());
-        return new EncryptRuleConfiguration(
-                new LinkedList<>(Arrays.asList(encryptTableRuleConfig, new 
EncryptTableRuleConfiguration("t_encrypt_another", 
Collections.singleton(encryptColumnRuleConfig1)))),
+        return new 
EncryptRuleConfiguration(Arrays.asList(encryptTableRuleConfig, new 
EncryptTableRuleConfiguration("t_encrypt_another", 
Collections.singleton(encryptColumnRuleConfig1))),
                 Collections.singletonMap("test", 
shardingSphereAlgorithmConfig));
     }
+    
+    private EncryptTableRuleConfiguration 
createEncryptTableRuleConfiguration(final EncryptColumnRuleConfiguration 
encryptColumnRuleConfig1,
+                                                                              
final EncryptColumnRuleConfiguration encryptColumnRuleConfig2) {
+        return new EncryptTableRuleConfiguration("foo_tbl", new 
LinkedList<>(Arrays.asList(encryptColumnRuleConfig1, 
encryptColumnRuleConfig2)));
+    }
+    
+    private EncryptColumnRuleConfiguration 
createEncryptColumnRuleConfiguration() {
+        EncryptColumnRuleConfiguration result = new 
EncryptColumnRuleConfiguration("bar_col", new 
EncryptColumnItemRuleConfiguration("bar_col_cipher", "test"));
+        result.setAssistedQuery(new 
EncryptColumnItemRuleConfiguration("bar_col_assisted", 
"bar_assist_query_encryptor"));
+        result.setLikeQuery(new 
EncryptColumnItemRuleConfiguration("bar_col_like", "bar_like_encryptor"));
+        return result;
+    }
 }
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
index 3d440745d0b..4fd579156aa 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/merge/dql/ShardingDQLResultMergerTest.java
@@ -474,23 +474,21 @@ class ShardingDQLResultMergerTest {
     }
     
     private ShardingSphereDatabase createDatabase() {
-        ShardingSphereColumn column1 = new ShardingSphereColumn("col1", 0, 
false, false, false, true, false, false);
-        ShardingSphereColumn column2 = new ShardingSphereColumn("col2", 0, 
false, false, false, true, false, false);
-        ShardingSphereColumn column3 = new ShardingSphereColumn("col3", 0, 
false, false, false, true, false, false);
-        ShardingSphereTable table = new ShardingSphereTable("tbl", 
Arrays.asList(column1, column2, column3), Collections.emptyList(), 
Collections.emptyList());
-        ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", 
Collections.singleton(table), Collections.emptyList());
-        return new ShardingSphereDatabase("foo_db", mysqlDatabaseType, 
mock(ResourceMetaData.class),
-                mock(RuleMetaData.class), Collections.singleton(schema));
+        ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", 
Collections.singleton(createTable()), Collections.emptyList());
+        return new ShardingSphereDatabase("foo_db", mysqlDatabaseType, 
mock(ResourceMetaData.class), mock(RuleMetaData.class), 
Collections.singleton(schema));
     }
     
     private ShardingSphereDatabase createSQLServerDatabase() {
+        ShardingSphereSchema schema = new ShardingSphereSchema("dbo", 
Collections.singleton(createTable()), Collections.emptyList());
+        return new ShardingSphereDatabase(
+                "foo_db", TypedSPILoader.getService(DatabaseType.class, 
"SQLServer"), mock(ResourceMetaData.class), mock(RuleMetaData.class), 
Collections.singleton(schema));
+    }
+    
+    private ShardingSphereTable createTable() {
         ShardingSphereColumn column1 = new ShardingSphereColumn("col1", 0, 
false, false, false, true, false, false);
         ShardingSphereColumn column2 = new ShardingSphereColumn("col2", 0, 
false, false, false, true, false, false);
         ShardingSphereColumn column3 = new ShardingSphereColumn("col3", 0, 
false, false, false, true, false, false);
-        ShardingSphereTable table = new ShardingSphereTable("tbl", 
Arrays.asList(column1, column2, column3), Collections.emptyList(), 
Collections.emptyList());
-        ShardingSphereSchema schema = new ShardingSphereSchema("dbo", 
Collections.singleton(table), Collections.emptyList());
-        return new ShardingSphereDatabase(
-                "foo_db", TypedSPILoader.getService(DatabaseType.class, 
"SQLServer"), mock(ResourceMetaData.class), mock(RuleMetaData.class), 
Collections.singleton(schema));
+        return new ShardingSphereTable("tbl", Arrays.asList(column1, column2, 
column3), Collections.emptyList(), Collections.emptyList());
     }
     
     private SelectStatement buildSelectStatement(final SelectStatement result) 
{
diff --git 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
index 0c53e38435c..01f420a5924 100644
--- 
a/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
+++ 
b/features/sharding/core/src/test/java/org/apache/shardingsphere/sharding/rule/ShardingTableTest.java
@@ -60,11 +60,7 @@ class ShardingTableTest {
     
     @Test
     void assertCreateFullShardingTable() {
-        ShardingTableRuleConfiguration shardingTableRuleConfig = new 
ShardingTableRuleConfiguration("LOGIC_TABLE", "ds${0..1}.table_${0..2}");
-        shardingTableRuleConfig.setDatabaseShardingStrategy(new 
NoneShardingStrategyConfiguration());
-        shardingTableRuleConfig.setTableShardingStrategy(new 
NoneShardingStrategyConfiguration());
-        shardingTableRuleConfig.setKeyGenerateStrategy(new 
KeyGenerateStrategyConfiguration("col_1", "increment"));
-        ShardingTable actual = new ShardingTable(shardingTableRuleConfig, 
Arrays.asList("ds0", "ds1"), null);
+        ShardingTable actual = createShardingTable();
         assertThat(actual.getLogicTable(), is("LOGIC_TABLE"));
         assertThat(actual.getActualDataNodes().size(), is(6));
         assertTrue(actual.getActualDataNodes().contains(new DataNode("ds0", 
(String) null, "table_0")));
@@ -78,6 +74,14 @@ class ShardingTableTest {
         assertThat(actual.getKeyGeneratorName(), is("increment"));
     }
     
+    private ShardingTable createShardingTable() {
+        ShardingTableRuleConfiguration shardingTableRuleConfig = new 
ShardingTableRuleConfiguration("LOGIC_TABLE", "ds${0..1}.table_${0..2}");
+        shardingTableRuleConfig.setDatabaseShardingStrategy(new 
NoneShardingStrategyConfiguration());
+        shardingTableRuleConfig.setTableShardingStrategy(new 
NoneShardingStrategyConfiguration());
+        shardingTableRuleConfig.setKeyGenerateStrategy(new 
KeyGenerateStrategyConfiguration("col_1", "increment"));
+        return new ShardingTable(shardingTableRuleConfig, Arrays.asList("ds0", 
"ds1"), null);
+    }
+    
     @Test
     void assertCreateAutoTableRuleWithModAlgorithm() {
         ShardingAutoTableRuleConfiguration shardingAutoTableRuleConfig = new 
ShardingAutoTableRuleConfiguration("LOGIC_TABLE", "ds0,ds1");
diff --git 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
 
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
index 9a523fd63cf..80d24584d3e 100644
--- 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
+++ 
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/context/statement/type/dml/UpdateStatementContextTest.java
@@ -67,19 +67,24 @@ class UpdateStatementContextTest {
         tableNameSegment1.setTableBoundInfo(new TableSegmentBoundInfo(new 
IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
         TableNameSegment tableNameSegment2 = new TableNameSegment(0, 0, new 
IdentifierValue("tbl_2"));
         tableNameSegment2.setTableBoundInfo(new TableSegmentBoundInfo(new 
IdentifierValue("foo_db"), new IdentifierValue("foo_schema")));
-        SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
-        SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
-        JoinTableSegment joinTableSegment = new JoinTableSegment();
-        joinTableSegment.setLeft(table1);
-        joinTableSegment.setRight(table2);
-        UpdateStatement updateStatement = new UpdateStatement(databaseType);
-        updateStatement.setWhere(whereSegment);
-        updateStatement.setTable(joinTableSegment);
-        updateStatement.setSetAssignment(new SetAssignmentSegment(0, 0, 
Collections.emptyList()));
+        UpdateStatement updateStatement = 
createUpdateStatement(tableNameSegment1, tableNameSegment2);
         UpdateStatementContext actual = new 
UpdateStatementContext(updateStatement);
         assertThat(actual.getTablesContext().getTableNames(), is(new 
HashSet<>(Arrays.asList("tbl_1", "tbl_2"))));
         assertThat(actual.getWhereSegments(), 
is(Collections.singletonList(whereSegment)));
         
assertThat(actual.getTablesContext().getSimpleTables().stream().map(each -> 
each.getTableName().getIdentifier().getValue()).collect(Collectors.toList()),
                 is(Arrays.asList("tbl_1", "tbl_2", "tbl_2")));
     }
+    
+    private UpdateStatement createUpdateStatement(final TableNameSegment 
tableNameSegment1, final TableNameSegment tableNameSegment2) {
+        SimpleTableSegment table1 = new SimpleTableSegment(tableNameSegment1);
+        SimpleTableSegment table2 = new SimpleTableSegment(tableNameSegment2);
+        JoinTableSegment joinTableSegment = new JoinTableSegment();
+        joinTableSegment.setLeft(table1);
+        joinTableSegment.setRight(table2);
+        UpdateStatement result = new UpdateStatement(databaseType);
+        result.setWhere(whereSegment);
+        result.setTable(joinTableSegment);
+        result.setSetAssignment(new SetAssignmentSegment(0, 0, 
Collections.emptyList()));
+        return result;
+    }
 }
diff --git 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/AnalyzeTableStatementBinderTest.java
 
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/AnalyzeTableStatementBinderTest.java
index 3eebc99e832..c7cf5e0de28 100644
--- 
a/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/AnalyzeTableStatementBinderTest.java
+++ 
b/infra/binder/core/src/test/java/org/apache/shardingsphere/infra/binder/engine/statement/dal/AnalyzeTableStatementBinderTest.java
@@ -61,15 +61,19 @@ class AnalyzeTableStatementBinderTest {
         when(metaData.getDatabase("foo_db")).thenReturn(database);
         when(database.containsSchema("foo_db")).thenReturn(true);
         when(database.getSchema("foo_db")).thenReturn(schema);
+        AnalyzeTableStatement actual = getAnalyzeTableStatement();
+        Collection<SimpleTableSegment> actualTables = actual.getTables();
+        assertThat(actualTables.size(), is(1));
+        
assertThat(actualTables.iterator().next().getTableName().getIdentifier().getValue(),
 is("DUAL"));
+    }
+    
+    private AnalyzeTableStatement getAnalyzeTableStatement() {
         HintValueContext hintValueContext = new HintValueContext();
         hintValueContext.setSkipMetadataValidate(true);
         SimpleTableSegment tableSegment = new SimpleTableSegment(new 
TableNameSegment(0, 0, new IdentifierValue("DUAL")));
-        AnalyzeTableStatement original = new 
AnalyzeTableStatement(databaseType, Collections.singletonList(tableSegment));
+        AnalyzeTableStatement original = new 
AnalyzeTableStatement(databaseType, Collections.singleton(tableSegment));
         SQLStatementBinderContext binderContext = new 
SQLStatementBinderContext(metaData, "foo_db", hintValueContext, original);
-        AnalyzeTableStatement actual = new 
AnalyzeTableStatementBinder().bind(original, binderContext);
-        Collection<SimpleTableSegment> actualTables = actual.getTables();
-        assertThat(actualTables.size(), is(1));
-        
assertThat(actualTables.iterator().next().getTableName().getIdentifier().getValue(),
 is("DUAL"));
+        return new AnalyzeTableStatementBinder().bind(original, binderContext);
     }
     
     @Test
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
index 614af8e18ee..6a7d8d03de5 100644
--- 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/config/swapper/resource/YamlDataSourceConfigurationSwapperTest.java
@@ -122,16 +122,7 @@ class YamlDataSourceConfigurationSwapperTest {
     
     @Test
     void assertSwapToDataSourcePoolPropertiesWithCustomPoolProps() {
-        Map<String, Object> yamlConfig = new HashMap<>(5, 1F);
-        yamlConfig.put("dataSourceClassName", 
MockedDataSource.class.getName());
-        yamlConfig.put("url", "jdbc:test:memory:");
-        yamlConfig.put("username", "test");
-        yamlConfig.put("password", "test");
-        Map<String, Object> customProps = new HashMap<>(2, 1F);
-        customProps.put("customKey1", "customValue1");
-        customProps.put("customKey2", "customValue2");
-        yamlConfig.put("customPoolProps", customProps);
-        DataSourcePoolProperties actual = 
swapper.swapToDataSourcePoolProperties(yamlConfig);
+        DataSourcePoolProperties actual = 
swapper.swapToDataSourcePoolProperties(createYamlConfiguration());
         assertThat(actual.getPoolClassName(), 
is(MockedDataSource.class.getName()));
         assertThat(actual.getAllLocalProperties().get("url").toString(), 
is("jdbc:test:memory:"));
         assertThat(actual.getAllLocalProperties().get("username").toString(), 
is("test"));
@@ -139,4 +130,17 @@ class YamlDataSourceConfigurationSwapperTest {
         
assertThat(actual.getAllLocalProperties().get("customKey2").toString(), 
is("customValue2"));
         
assertFalse(actual.getAllLocalProperties().containsKey("customPoolProps"));
     }
+    
+    private Map<String, Object> createYamlConfiguration() {
+        Map<String, Object> result = new HashMap<>(5, 1F);
+        result.put("dataSourceClassName", MockedDataSource.class.getName());
+        result.put("url", "jdbc:test:memory:");
+        result.put("username", "test");
+        result.put("password", "test");
+        Map<String, Object> customProps = new HashMap<>(2, 1F);
+        customProps.put("customKey1", "customValue1");
+        customProps.put("customKey2", "customValue2");
+        result.put("customPoolProps", customProps);
+        return result;
+    }
 }
diff --git 
a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
 
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
index 015ae73cf59..0b83a841d56 100644
--- 
a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
+++ 
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/context/ExecutionContextBuilderTest.java
@@ -92,17 +92,10 @@ class ExecutionContextBuilderTest {
     
     @Test
     void assertBuildRouteSQLRewriteResult() {
-        RouteUnit routeUnit1 = new RouteUnit(new RouteMapper("foo_db_1", 
"actual_db_1"), Collections.singletonList(new RouteMapper("foo_tbl", 
"actual_tbl")));
-        SQLRewriteUnit sqlRewriteUnit1 = new SQLRewriteUnit("sql1", 
Collections.singletonList("parameter1"));
-        RouteUnit routeUnit2 = new RouteUnit(new RouteMapper("foo_db_2", 
"actual_db_2"), Collections.singletonList(new RouteMapper("foo_tbl", 
"actual_tbl")));
-        SQLRewriteUnit sqlRewriteUnit2 = new SQLRewriteUnit("sql2", 
Collections.singletonList("parameter2"));
-        Map<RouteUnit, SQLRewriteUnit> sqlRewriteUnits = new HashMap<>(2, 1F);
-        sqlRewriteUnits.put(routeUnit1, sqlRewriteUnit1);
-        sqlRewriteUnits.put(routeUnit2, sqlRewriteUnit2);
         ResourceMetaData resourceMetaData = new 
ResourceMetaData(Collections.emptyMap());
         RuleMetaData ruleMetaData = new RuleMetaData(Collections.emptyList());
         ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db", 
mock(DatabaseType.class), resourceMetaData, ruleMetaData, buildSchemas());
-        Collection<ExecutionUnit> actual = 
ExecutionContextBuilder.build(database, new 
RouteSQLRewriteResult(sqlRewriteUnits), mock(SQLStatementContext.class));
+        Collection<ExecutionUnit> actual = 
ExecutionContextBuilder.build(database, new 
RouteSQLRewriteResult(createRouteUnitSQLRewriteUnitMap()), 
mock(SQLStatementContext.class));
         ExecutionUnit expectedUnit1 = new ExecutionUnit("actual_db_1", new 
SQLUnit("sql1", Collections.singletonList("parameter1")));
         ExecutionUnit expectedUnit2 = new ExecutionUnit("actual_db_2", new 
SQLUnit("sql2", Collections.singletonList("parameter2")));
         Collection<ExecutionUnit> expected = new LinkedHashSet<>(2, 1F);
@@ -111,6 +104,17 @@ class ExecutionContextBuilderTest {
         assertThat(actual, is(expected));
     }
     
+    private Map<RouteUnit, SQLRewriteUnit> createRouteUnitSQLRewriteUnitMap() {
+        RouteUnit routeUnit1 = new RouteUnit(new RouteMapper("foo_db_1", 
"actual_db_1"), Collections.singletonList(new RouteMapper("foo_tbl", 
"actual_tbl")));
+        SQLRewriteUnit sqlRewriteUnit1 = new SQLRewriteUnit("sql1", 
Collections.singletonList("parameter1"));
+        RouteUnit routeUnit2 = new RouteUnit(new RouteMapper("foo_db_2", 
"actual_db_2"), Collections.singletonList(new RouteMapper("foo_tbl", 
"actual_tbl")));
+        SQLRewriteUnit sqlRewriteUnit2 = new SQLRewriteUnit("sql2", 
Collections.singletonList("parameter2"));
+        Map<RouteUnit, SQLRewriteUnit> result = new HashMap<>(2, 1F);
+        result.put(routeUnit1, sqlRewriteUnit1);
+        result.put(routeUnit2, sqlRewriteUnit2);
+        return result;
+    }
+    
     @Test
     void assertBuildRouteSQLRewriteResultWithEmptyPrimaryKeyMeta() {
         RouteUnit routeUnit2 = new RouteUnit(new RouteMapper("logicName2", 
"actualName2"), Collections.singletonList(new RouteMapper("logicName2", 
"actualName2")));
diff --git 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java
 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java
index 71857630204..368ac96c2ee 100644
--- 
a/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java
+++ 
b/kernel/data-pipeline/core/src/main/java/org/apache/shardingsphere/data/pipeline/core/consistencycheck/table/MatchingTableInventoryChecker.java
@@ -79,10 +79,7 @@ public abstract class MatchingTableInventoryChecker 
implements TableInventoryChe
         TableCheckRangePosition checkRangePosition = 
param.getProgressContext().getTableCheckRangePositions().get(param.getSplittingItem());
         sourceParam.setQueryRange(new QueryRange(null != 
checkRangePosition.getSourcePosition() ? checkRangePosition.getSourcePosition() 
: checkRangePosition.getSourceRange().getBeginValue(),
                 true, checkRangePosition.getSourceRange().getEndValue()));
-        TableInventoryCalculateParameter targetParam = new 
TableInventoryCalculateParameter(param.getTargetDataSource(), 
param.getTargetTable(),
-                param.getColumnNames(), param.getUniqueKeys(), 
QueryType.RANGE_QUERY, param.getQueryCondition());
-        targetParam.setQueryRange(new QueryRange(null != 
checkRangePosition.getTargetPosition() ? checkRangePosition.getTargetPosition() 
: checkRangePosition.getTargetRange().getBeginValue(),
-                true, checkRangePosition.getTargetRange().getEndValue()));
+        TableInventoryCalculateParameter targetParam = 
getTableInventoryCalculateParameter(param, checkRangePosition);
         TableInventoryCalculator<TableInventoryCheckCalculatedResult> 
sourceCalculator = buildSingleTableInventoryCalculator();
         this.sourceCalculator = sourceCalculator;
         TableInventoryCalculator<TableInventoryCheckCalculatedResult> 
targetCalculator = buildSingleTableInventoryCalculator();
@@ -132,6 +129,14 @@ public abstract class MatchingTableInventoryChecker 
implements TableInventoryChe
         return new 
YamlTableDataConsistencyCheckResultSwapper().swapToObject(checkResult);
     }
     
+    private TableInventoryCalculateParameter 
getTableInventoryCalculateParameter(final TableInventoryCheckParameter param, 
final TableCheckRangePosition checkRangePosition) {
+        TableInventoryCalculateParameter result = new 
TableInventoryCalculateParameter(param.getTargetDataSource(), 
param.getTargetTable(),
+                param.getColumnNames(), param.getUniqueKeys(), 
QueryType.RANGE_QUERY, param.getQueryCondition());
+        result.setQueryRange(new QueryRange(null != 
checkRangePosition.getTargetPosition() ? checkRangePosition.getTargetPosition() 
: checkRangePosition.getTargetRange().getBeginValue(),
+                true, checkRangePosition.getTargetRange().getEndValue()));
+        return result;
+    }
+    
     protected abstract 
TableInventoryCalculator<TableInventoryCheckCalculatedResult> 
buildSingleTableInventoryCalculator();
     
     @Override
diff --git 
a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
 
b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
index c4cb9f20dbb..288f7351037 100644
--- 
a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
+++ 
b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/config/yaml/swapper/YamlCDCJobConfigurationSwapperTest.java
@@ -39,15 +39,7 @@ class YamlCDCJobConfigurationSwapperTest {
     
     @Test
     void assertSwapToObject() {
-        YamlCDCJobConfiguration yamlJobConfig = new YamlCDCJobConfiguration();
-        yamlJobConfig.setJobId("j0302p00007a8bf46da145dc155ba25c710b550220");
-        yamlJobConfig.setDatabaseName("test_db");
-        yamlJobConfig.setSchemaTableNames(Arrays.asList("test.t_order", 
"t_order_item"));
-        yamlJobConfig.setFull(true);
-        yamlJobConfig.setSourceDatabaseType("MySQL");
-        YamlSinkConfiguration sinkConfig = new YamlSinkConfiguration();
-        sinkConfig.setSinkType(CDCSinkType.SOCKET.name());
-        yamlJobConfig.setSinkConfig(sinkConfig);
+        YamlCDCJobConfiguration yamlJobConfig = 
createYamlCDCJobConfiguration();
         CDCJobConfiguration actual = new 
YamlCDCJobConfigurationSwapper().swapToObject(yamlJobConfig);
         assertThat(actual.getJobId(), 
is("j0302p00007a8bf46da145dc155ba25c710b550220"));
         assertThat(actual.getDatabaseName(), is("test_db"));
@@ -55,6 +47,19 @@ class YamlCDCJobConfigurationSwapperTest {
         assertTrue(actual.isFull());
     }
     
+    private YamlCDCJobConfiguration createYamlCDCJobConfiguration() {
+        YamlCDCJobConfiguration result = new YamlCDCJobConfiguration();
+        result.setJobId("j0302p00007a8bf46da145dc155ba25c710b550220");
+        result.setDatabaseName("test_db");
+        result.setSchemaTableNames(Arrays.asList("test.t_order", 
"t_order_item"));
+        result.setFull(true);
+        result.setSourceDatabaseType("MySQL");
+        YamlSinkConfiguration sinkConfig = new YamlSinkConfiguration();
+        sinkConfig.setSinkType(CDCSinkType.SOCKET.name());
+        result.setSinkConfig(sinkConfig);
+        return result;
+    }
+    
     @Test
     void assertSwapToYamlConfig() {
         CDCJobConfiguration jobConfig = new 
CDCJobConfiguration("j0302p00007a8bf46da145dc155ba25c710b550220", "test_db", 
Arrays.asList("t_order", "t_order_item"), true, databaseType,
diff --git 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
index 3811adc1d89..8f183460abb 100644
--- 
a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
+++ 
b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/rule/tuple/YamlRuleNodeTupleSwapperEngineTest.java
@@ -51,20 +51,7 @@ class YamlRuleNodeTupleSwapperEngineTest {
     
     @Test
     void assertSwapToTuplesWithNodeYamlRuleConfiguration() {
-        YamlNodeRuleConfiguration yamlRuleConfig = new 
YamlNodeRuleConfiguration();
-        yamlRuleConfig.setMapValue(Collections.singletonMap("k", new 
YamlLeafRuleConfiguration("v")));
-        yamlRuleConfig.setCollectionValue(Collections.singletonList(new 
YamlLeafRuleConfiguration("foo")));
-        yamlRuleConfig.setStringValue("str");
-        yamlRuleConfig.setBooleanValue(true);
-        yamlRuleConfig.setIntegerValue(1);
-        yamlRuleConfig.setLongValue(10L);
-        yamlRuleConfig.setEnumValue(YamlNodeRuleConfigurationEnum.FOO);
-        YamlLeafRuleConfiguration leaf = new YamlLeafRuleConfiguration();
-        leaf.setValue("leaf");
-        yamlRuleConfig.setLeaf(leaf);
-        yamlRuleConfig.setGens(Collections.singleton("value"));
-        yamlRuleConfig.setGen("single_gen");
-        List<RuleNodeTuple> actual = new ArrayList<>(new 
YamlRuleNodeTupleSwapperEngine().swapToTuples("foo_db", yamlRuleConfig));
+        List<RuleNodeTuple> actual = new ArrayList<>(new 
YamlRuleNodeTupleSwapperEngine().swapToTuples("foo_db", 
createYamlNodeRuleConfiguration()));
         assertThat(actual.size(), is(10));
         assertThat(actual.get(0).getPath(), 
is("/metadata/foo_db/rules/node/map_value/k"));
         assertThat(actual.get(0).getContent(), is("value: v" + 
System.lineSeparator()));
@@ -88,6 +75,23 @@ class YamlRuleNodeTupleSwapperEngineTest {
         assertThat(actual.get(9).getContent(), is("single_gen"));
     }
     
+    private YamlNodeRuleConfiguration createYamlNodeRuleConfiguration() {
+        YamlNodeRuleConfiguration result = new YamlNodeRuleConfiguration();
+        result.setMapValue(Collections.singletonMap("k", new 
YamlLeafRuleConfiguration("v")));
+        result.setCollectionValue(Collections.singletonList(new 
YamlLeafRuleConfiguration("foo")));
+        result.setStringValue("str");
+        result.setBooleanValue(true);
+        result.setIntegerValue(1);
+        result.setLongValue(10L);
+        result.setEnumValue(YamlNodeRuleConfigurationEnum.FOO);
+        YamlLeafRuleConfiguration leaf = new YamlLeafRuleConfiguration();
+        leaf.setValue("leaf");
+        result.setLeaf(leaf);
+        result.setGens(Collections.singleton("value"));
+        result.setGen("single_gen");
+        return result;
+    }
+    
     @Test
     void assertSwapToYamlRuleConfigurationWithEmptyNodeYamlRuleConfiguration() 
{
         DatabaseRuleNodePath databaseRuleNodePath = new 
DatabaseRuleNodePath("foo_db", "node", new DatabaseRuleItem("string_value"));
diff --git 
a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/ExpressionExtractorTest.java
 
b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/ExpressionExtractorTest.java
index 74b951a437c..6490d3e0693 100644
--- 
a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/ExpressionExtractorTest.java
+++ 
b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/ExpressionExtractorTest.java
@@ -94,14 +94,7 @@ class ExpressionExtractorTest {
     void assertExtractAndPredicatesOrAndCondition() {
         ColumnSegment statusColumn = new ColumnSegment(0, 0, new 
IdentifierValue("status"));
         ParameterMarkerExpressionSegment statusParameterExpression = new 
ParameterMarkerExpressionSegment(0, 0, 0);
-        ExpressionSegment leftExpression = new BinaryOperationExpression(0, 0, 
statusColumn, statusParameterExpression, "=", "status=?");
-        ColumnSegment countColumn = new ColumnSegment(0, 0, new 
IdentifierValue("count"));
-        ParameterMarkerExpressionSegment countParameterExpression = new 
ParameterMarkerExpressionSegment(0, 0, 1);
-        ExpressionSegment subLeftExpression = new BinaryOperationExpression(0, 
0, statusColumn, statusParameterExpression, "=", "status=?");
-        ExpressionSegment subRightExpression = new 
BinaryOperationExpression(0, 0, countColumn, countParameterExpression, "=", 
"count=?");
-        BinaryOperationExpression rightExpression = new 
BinaryOperationExpression(0, 0, subLeftExpression, subRightExpression, "AND", 
"status=? AND count=?");
-        BinaryOperationExpression expression = new 
BinaryOperationExpression(0, 0, leftExpression, rightExpression, "OR", 
"status=? OR status=? AND count=?");
-        Collection<AndPredicate> actual = 
ExpressionExtractor.extractAndPredicates(expression);
+        Collection<AndPredicate> actual = 
ExpressionExtractor.extractAndPredicates(createBinaryOperationExpression(statusColumn,
 statusParameterExpression));
         assertThat(actual.size(), is(2));
         Iterator<AndPredicate> iterator = actual.iterator();
         AndPredicate andPredicate1 = iterator.next();
@@ -110,6 +103,21 @@ class ExpressionExtractorTest {
         assertThat(andPredicate2.getPredicates().size(), is(2));
     }
     
+    private BinaryOperationExpression createBinaryOperationExpression(final 
ColumnSegment statusColumn, final ParameterMarkerExpressionSegment 
statusParameterExpression) {
+        ExpressionSegment leftExpression = new BinaryOperationExpression(0, 0, 
statusColumn, statusParameterExpression, "=", "status=?");
+        ColumnSegment countColumn = new ColumnSegment(0, 0, new 
IdentifierValue("count"));
+        BinaryOperationExpression rightExpression = 
createBinaryOperationExpression(statusColumn, statusParameterExpression, 
countColumn);
+        return new BinaryOperationExpression(0, 0, leftExpression, 
rightExpression, "OR", "status=? OR status=? AND count=?");
+    }
+    
+    private BinaryOperationExpression createBinaryOperationExpression(final 
ColumnSegment statusColumn,
+                                                                      final 
ParameterMarkerExpressionSegment statusParameterExpression, final ColumnSegment 
countColumn) {
+        ParameterMarkerExpressionSegment countParameterExpression = new 
ParameterMarkerExpressionSegment(0, 0, 1);
+        ExpressionSegment subLeftExpression = new BinaryOperationExpression(0, 
0, statusColumn, statusParameterExpression, "=", "status=?");
+        ExpressionSegment subRightExpression = new 
BinaryOperationExpression(0, 0, countColumn, countParameterExpression, "=", 
"count=?");
+        return new BinaryOperationExpression(0, 0, subLeftExpression, 
subRightExpression, "AND", "status=? AND count=?");
+    }
+    
     @Test
     void assertExtractAllExpressionsWithAndOperation() {
         BinaryOperationExpression expression1 =
diff --git 
a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/WhereExtractorTest.java
 
b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/WhereExtractorTest.java
index 7c6b7814c5d..74e5ed23845 100644
--- 
a/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/WhereExtractorTest.java
+++ 
b/parser/sql/statement/core/src/test/java/org/apache/shardingsphere/sql/parser/statement/core/extractor/WhereExtractorTest.java
@@ -81,12 +81,7 @@ class WhereExtractorTest {
     
     @Test
     void assertGetWhereSegmentsFromSubQueryJoin() {
-        JoinTableSegment joinTableSegment = new JoinTableSegment();
-        joinTableSegment.setLeft(new SimpleTableSegment(new 
TableNameSegment(37, 39, new IdentifierValue("t_order"))));
-        joinTableSegment.setRight(new SimpleTableSegment(new 
TableNameSegment(54, 56, new IdentifierValue("t_order_item"))));
-        joinTableSegment.setJoinType("INNER");
-        joinTableSegment.setCondition(new BinaryOperationExpression(63, 83, 
new ColumnSegment(63, 71, new IdentifierValue("order_id")),
-                new ColumnSegment(75, 83, new IdentifierValue("order_id")), 
"=", "oi.order_id = o.order_id"));
+        JoinTableSegment joinTableSegment = createJoinTableSegment();
         SelectStatement subQuerySelectStatement = mock(SelectStatement.class);
         
when(subQuerySelectStatement.getFrom()).thenReturn(Optional.of(joinTableSegment));
         SelectStatement selectStatement = mock(SelectStatement.class);
@@ -95,4 +90,14 @@ class WhereExtractorTest {
         WhereSegment actual = subqueryWhereSegments.iterator().next();
         assertThat(actual.getExpr(), is(joinTableSegment.getCondition()));
     }
+    
+    private JoinTableSegment createJoinTableSegment() {
+        JoinTableSegment result = new JoinTableSegment();
+        result.setLeft(new SimpleTableSegment(new TableNameSegment(37, 39, new 
IdentifierValue("t_order"))));
+        result.setRight(new SimpleTableSegment(new TableNameSegment(54, 56, 
new IdentifierValue("t_order_item"))));
+        result.setJoinType("INNER");
+        result.setCondition(new BinaryOperationExpression(63, 83, new 
ColumnSegment(63, 71, new IdentifierValue("order_id")),
+                new ColumnSegment(75, 83, new IdentifierValue("order_id")), 
"=", "oi.order_id = o.order_id"));
+        return result;
+    }
 }
diff --git 
a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
 
b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
index 0ced05298ce..38663ea7913 100644
--- 
a/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
+++ 
b/proxy/frontend/dialect/firebird/src/test/java/org/apache/shardingsphere/proxy/frontend/firebird/command/query/statement/prepare/FirebirdPrepareStatementCommandExecutorTest.java
@@ -85,15 +85,18 @@ class FirebirdPrepareStatementCommandExecutorTest {
         when(packet.getStatementId()).thenReturn(1);
         when(packet.nextItem()).thenReturn(true, false);
         
when(packet.getCurrentItem()).thenReturn(FirebirdSQLInfoPacketType.STMT_TYPE);
+        
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts()).thenReturn(createMetaDataContexts());
+    }
+    
+    private MetaDataContexts createMetaDataContexts() {
         SQLParserRule parserRule = new SQLParserRule(new 
SQLParserRuleConfiguration(new CacheOption(128, 1024L), new CacheOption(128, 
1024L)));
         RuleMetaData globalRuleMetaData = new 
RuleMetaData(Collections.singleton(parserRule));
         ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", 
Collections.emptyList(), Collections.emptyList());
-        ShardingSphereDatabase database =
-                new ShardingSphereDatabase("foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
-        ShardingSphereMetaData metaData =
-                new ShardingSphereMetaData(Collections.singleton(database), 
new ResourceMetaData(Collections.emptyMap()), globalRuleMetaData, new 
ConfigurationProperties(new Properties()));
-        MetaDataContexts metaDataContexts = new MetaDataContexts(metaData, new 
ShardingSphereStatistics());
-        
when(ProxyContext.getInstance().getContextManager().getMetaDataContexts()).thenReturn(metaDataContexts);
+        ShardingSphereDatabase database = new ShardingSphereDatabase(
+                "foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
+        ShardingSphereMetaData metaData = new ShardingSphereMetaData(
+                Collections.singleton(database), new 
ResourceMetaData(Collections.emptyMap()), globalRuleMetaData, new 
ConfigurationProperties(new Properties()));
+        return new MetaDataContexts(metaData, new ShardingSphereStatistics());
     }
     
     @Test
diff --git 
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
 
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
index 37b292c74d9..110fd4107e3 100644
--- 
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
+++ 
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/binary/prepare/MySQLComStmtPrepareExecutorTest.java
@@ -230,14 +230,16 @@ class MySQLComStmtPrepareExecutorTest {
         
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData().getSingleRule(SQLParserRule.class))
                 .thenReturn(new SQLParserRule(new 
SQLParserRuleConfiguration(cacheOption, cacheOption)));
         
when(result.getMetaDataContexts().getMetaData().getDatabase(connectionSession.getUsedDatabaseName()).getProtocolType()).thenReturn(databaseType);
+        
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(createDatabase());
+        
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
+        return result;
+    }
+    
+    private ShardingSphereDatabase createDatabase() {
         ShardingSphereTable table = new ShardingSphereTable("user", 
Arrays.asList(new ShardingSphereColumn("id", Types.BIGINT, true, false, false, 
false, true, false),
                 new ShardingSphereColumn("name", Types.VARCHAR, false, false, 
false, false, false, false),
                 new ShardingSphereColumn("age", Types.SMALLINT, false, false, 
false, false, true, false)), Collections.emptyList(), Collections.emptyList());
         ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", 
Collections.singleton(table), Collections.emptyList());
-        ShardingSphereDatabase database = new ShardingSphereDatabase(
-                "foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
-        
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database);
-        
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
-        return result;
+        return new ShardingSphereDatabase("foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
     }
 }
diff --git 
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
 
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
index 51d4037d72e..a4e23a9c707 100644
--- 
a/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
+++ 
b/proxy/frontend/dialect/mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/command/query/text/query/MySQLComQueryPacketExecutorTest.java
@@ -166,14 +166,16 @@ class MySQLComQueryPacketExecutorTest {
         
when(result.getMetaData().getGlobalRuleMetaData()).thenReturn(globalRuleMetaData);
         
when(result.getMetaData().getProps().<Integer>getValue(ConfigurationPropertyKey.KERNEL_EXECUTOR_SIZE)).thenReturn(1);
         
when(result.getMetaData().getProps().<Boolean>getValue(ConfigurationPropertyKey.SQL_SHOW)).thenReturn(false);
+        
when(result.getMetaData().getDatabase("foo_db")).thenReturn(createDatabase());
+        when(result.getMetaData().containsDatabase("foo_db")).thenReturn(true);
+        return result;
+    }
+    
+    private ShardingSphereDatabase createDatabase() {
         ShardingSphereTable table = new ShardingSphereTable("t", 
Arrays.asList(new ShardingSphereColumn("id", Types.BIGINT, true, false, false, 
false, true, false),
                 new ShardingSphereColumn("v", Types.INTEGER, false, false, 
false, false, true, false)), Collections.emptyList(), Collections.emptyList());
         ShardingSphereSchema schema = new ShardingSphereSchema("foo_db", 
Collections.singleton(table), Collections.emptyList());
-        ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
-                databaseType, new ResourceMetaData(Collections.emptyMap()), 
new RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
-        when(result.getMetaData().getDatabase("foo_db")).thenReturn(database);
-        when(result.getMetaData().containsDatabase("foo_db")).thenReturn(true);
-        return result;
+        return new ShardingSphereDatabase("foo_db", databaseType, new 
ResourceMetaData(Collections.emptyMap()), new 
RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
     }
     
     @Test
diff --git 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
index 43c62af5172..4fc967dbf43 100644
--- 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
+++ 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/PortalTest.java
@@ -161,11 +161,7 @@ class PortalTest {
         SelectStatementContext sqlStatementContext = 
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
         when(sqlStatementContext.getSqlStatement()).thenReturn(new 
SelectStatement(databaseType));
         
when(sqlStatementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
-        PostgreSQLServerPreparedStatement preparedStatement =
-                new PostgreSQLServerPreparedStatement("", sqlStatementContext, 
new HintValueContext(), Collections.emptyList(), Collections.emptyList());
-        List<PostgreSQLValueFormat> resultFormats = new 
ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, 
PostgreSQLValueFormat.BINARY));
-        Portal portal = new Portal("", preparedStatement, 
Collections.emptyList(), resultFormats, databaseConnectionManager);
-        portal.bind();
+        Portal portal = createPortal(sqlStatementContext);
         PostgreSQLPacket portalDescription = portal.describe();
         assertThat(portalDescription, 
isA(PostgreSQLRowDescriptionPacket.class));
         Collection<PostgreSQLColumnDescription> columnDescriptions = 
(Collection<PostgreSQLColumnDescription>) Plugins.getMemberAccessor()
@@ -196,11 +192,7 @@ class PortalTest {
         SelectStatementContext selectStatementContext = 
mock(SelectStatementContext.class, RETURNS_DEEP_STUBS);
         when(selectStatementContext.getSqlStatement()).thenReturn(new 
SelectStatement(databaseType));
         
when(selectStatementContext.getTablesContext().getDatabaseName()).thenReturn(Optional.empty());
-        PostgreSQLServerPreparedStatement preparedStatement = new 
PostgreSQLServerPreparedStatement("", selectStatementContext, new 
HintValueContext(), Collections.emptyList(),
-                Collections.emptyList());
-        List<PostgreSQLValueFormat> resultFormats = new 
ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, 
PostgreSQLValueFormat.BINARY));
-        Portal portal = new Portal("", preparedStatement, 
Collections.emptyList(), resultFormats, databaseConnectionManager);
-        portal.bind();
+        Portal portal = createPortal(selectStatementContext);
         assertThat(portal.describe(), 
isA(PostgreSQLRowDescriptionPacket.class));
         List<DatabasePacket> actualPackets = portal.execute(2);
         assertThat(actualPackets.size(), is(3));
@@ -210,6 +202,15 @@ class PortalTest {
         assertThat(actualPacketsIterator.next(), 
isA(PostgreSQLPortalSuspendedPacket.class));
     }
     
+    private Portal createPortal(final SelectStatementContext 
selectStatementContext) throws SQLException {
+        PostgreSQLServerPreparedStatement preparedStatement = new 
PostgreSQLServerPreparedStatement(
+                "", selectStatementContext, new HintValueContext(), 
Collections.emptyList(), Collections.emptyList());
+        List<PostgreSQLValueFormat> resultFormats = new 
ArrayList<>(Arrays.asList(PostgreSQLValueFormat.TEXT, 
PostgreSQLValueFormat.BINARY));
+        Portal result = new Portal("", preparedStatement, 
Collections.emptyList(), resultFormats, databaseConnectionManager);
+        result.bind();
+        return result;
+    }
+    
     @Test
     void assertExecuteUpdate() throws SQLException {
         
when(proxyBackendHandler.execute()).thenReturn(mock(UpdateResponseHeader.class));
diff --git 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
index a241b09b25a..b2240b79b06 100644
--- 
a/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
+++ 
b/proxy/frontend/dialect/postgresql/src/test/java/org/apache/shardingsphere/proxy/frontend/postgresql/command/query/extended/parse/PostgreSQLComParseExecutorTest.java
@@ -189,6 +189,14 @@ class PostgreSQLComParseExecutorTest {
         
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db").getProtocolType()).thenReturn(databaseType);
         
when(result.getMetaDataContexts().getMetaData().getGlobalRuleMetaData())
                 .thenReturn(new RuleMetaData(Collections.singleton(new 
SQLParserRule(new DefaultSQLParserRuleConfigurationBuilder().build()))));
+        ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
+                databaseType, new ResourceMetaData(Collections.emptyMap()), 
new RuleMetaData(Collections.emptyList()), 
Collections.singleton(createSchema()));
+        
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database);
+        
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
+        return result;
+    }
+    
+    private ShardingSphereSchema createSchema() {
         ShardingSphereTable testTable = new ShardingSphereTable("t_test", 
Arrays.asList(new ShardingSphereColumn("id", Types.BIGINT, true, false, false, 
false, true, false),
                 new ShardingSphereColumn("name", Types.VARCHAR, false, false, 
false, false, false, false),
                 new ShardingSphereColumn("age", Types.SMALLINT, false, false, 
false, false, true, false),
@@ -197,11 +205,6 @@ class PostgreSQLComParseExecutorTest {
                 new ShardingSphereColumn("k", Types.VARCHAR, false, false, 
false, false, false, false),
                 new ShardingSphereColumn("c", Types.VARCHAR, false, false, 
false, false, true, false),
                 new ShardingSphereColumn("pad", Types.VARCHAR, false, false, 
false, false, true, false)), Collections.emptyList(), Collections.emptyList());
-        ShardingSphereSchema schema = new ShardingSphereSchema("public", 
Arrays.asList(testTable, sbTestTable), Collections.emptyList());
-        ShardingSphereDatabase database = new ShardingSphereDatabase("foo_db",
-                databaseType, new ResourceMetaData(Collections.emptyMap()), 
new RuleMetaData(Collections.emptyList()), Collections.singleton(schema));
-        
when(result.getMetaDataContexts().getMetaData().getDatabase("foo_db")).thenReturn(database);
-        
when(result.getMetaDataContexts().getMetaData().containsDatabase("foo_db")).thenReturn(true);
-        return result;
+        return new ShardingSphereSchema("public", Arrays.asList(testTable, 
sbTestTable), Collections.emptyList());
     }
 }
diff --git 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/PipelineProcessConfigurationPersistServiceTest.java
 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/PipelineProcessConfigurationPersistServiceTest.java
index 3a19079d14f..ceab68d907e 100644
--- 
a/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/PipelineProcessConfigurationPersistServiceTest.java
+++ 
b/test/it/pipeline/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/PipelineProcessConfigurationPersistServiceTest.java
@@ -40,15 +40,7 @@ class PipelineProcessConfigurationPersistServiceTest {
     
     @Test
     void assertLoadAndPersist() {
-        YamlPipelineProcessConfiguration yamlProcessConfig = new 
YamlPipelineProcessConfiguration();
-        YamlPipelineReadConfiguration yamlReadConfig = new 
YamlPipelineReadConfiguration();
-        yamlReadConfig.setShardingSize(10);
-        yamlProcessConfig.setRead(yamlReadConfig);
-        YamlPipelineWriteConfiguration yamlWriteConfig = new 
YamlPipelineWriteConfiguration();
-        yamlProcessConfig.setWrite(yamlWriteConfig);
-        YamlAlgorithmConfiguration yamlStreamChannel = new 
YamlAlgorithmConfiguration();
-        yamlStreamChannel.setType("MEMORY");
-        yamlProcessConfig.setStreamChannel(yamlStreamChannel);
+        YamlPipelineProcessConfiguration yamlProcessConfig = 
createYamlPipelineProcessConfiguration();
         String expectedYamlText = YamlEngine.marshal(yamlProcessConfig);
         PipelineProcessConfiguration processConfig = new 
YamlPipelineProcessConfigurationSwapper().swapToObject(yamlProcessConfig);
         PipelineProcessConfigurationPersistService persistService = new 
PipelineProcessConfigurationPersistService();
@@ -56,4 +48,17 @@ class PipelineProcessConfigurationPersistServiceTest {
         String actualYamlText = YamlEngine.marshal(new 
YamlPipelineProcessConfigurationSwapper().swapToYamlConfiguration(persistService.load(PipelineContextUtils.getContextKey(),
 "MIGRATION")));
         assertThat(actualYamlText, is(expectedYamlText));
     }
+    
+    private YamlPipelineProcessConfiguration 
createYamlPipelineProcessConfiguration() {
+        YamlPipelineProcessConfiguration result = new 
YamlPipelineProcessConfiguration();
+        YamlPipelineReadConfiguration yamlReadConfig = new 
YamlPipelineReadConfiguration();
+        yamlReadConfig.setShardingSize(10);
+        result.setRead(yamlReadConfig);
+        YamlPipelineWriteConfiguration yamlWriteConfig = new 
YamlPipelineWriteConfiguration();
+        result.setWrite(yamlWriteConfig);
+        YamlAlgorithmConfiguration yamlStreamChannel = new 
YamlAlgorithmConfiguration();
+        yamlStreamChannel.setType("MEMORY");
+        result.setStreamChannel(yamlStreamChannel);
+        return result;
+    }
 }

Reply via email to