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 b19f9a16e21 Add coverage for infra yaml row statistics swapper (#37655)
b19f9a16e21 is described below

commit b19f9a16e2150f25b288030a6d993df019be6850
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Jan 6 14:35:32 2026 +0800

    Add coverage for infra yaml row statistics swapper (#37655)
    
    * Add coverage for infra yaml row statistics swapper
    
    * Add coverage for infra yaml row statistics swapper
---
 .../manager/DialectSystemSchemaManagerTest.java    | 111 +++++++++++++++++
 .../infra/rule/attribute/RuleAttributesTest.java   |  62 ++++++++++
 .../YamlQualifiedDataSourceStateSwapperTest.java   |  42 +++++++
 .../data/swapper/YamlRowStatisticsSwapperTest.java |  89 +++++++++++++
 .../yaml/schema/swapper/YamlColumnSwapperTest.java |  68 ++++++++++
 .../schema/swapper/YamlConstraintSwapperTest.java  |  48 ++++++++
 .../yaml/schema/swapper/YamlIndexSwapperTest.java  |  56 +++++++++
 .../src/test/resources/dialect-system-resource.txt |   1 +
 .../metadata/HikariDataSourcePoolMetaDataTest.java |  76 ++++++++++++
 .../sql/process/lock/ProcessOperationLockTest.java |  45 +++++++
 .../stream/IteratorStreamMergedResultTest.java     | 137 +++++++++++++++++++++
 .../common/pojo/generic/ColumnDefinitionToken.java |  10 +-
 .../pojo/generic/ColumnDefinitionTokenTest.java}   |  45 +++----
 .../SubstituteColumnDefinitionTokenTest.java}      |  46 +++----
 .../MySQLToBeRemovedSegmentsProviderTest.java      |  81 ++++++++++++
 .../processor/DefaultYamlTupleProcessor.java       |   4 +-
 .../util/file/SystemResourceFileUtilsTest.java     |  39 ++++++
 .../processor/DefaultYamlTupleProcessorTest.java   |  76 ++++++++++++
 .../src/test/resources/system-resource-file.txt    |   2 +
 19 files changed, 975 insertions(+), 63 deletions(-)

diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/DialectSystemSchemaManagerTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/DialectSystemSchemaManagerTest.java
new file mode 100644
index 00000000000..b7c10297775
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/manager/DialectSystemSchemaManagerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.metadata.database.schema.manager;
+
+import lombok.SneakyThrows;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class DialectSystemSchemaManagerTest {
+    
+    @Test
+    void assertSystemTableFoundWithoutSchema() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putTable("information_schema", "tbl");
+        assertTrue(manager.isSystemTable(null, "tbl"));
+    }
+    
+    @Test
+    void assertSystemTableMissingWithoutSchema() {
+        assertFalse(new DialectSystemSchemaManager().isSystemTable(null, 
"absent"));
+    }
+    
+    @Test
+    void assertSystemTableFoundWithSchema() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putTable("public", "t_order");
+        assertTrue(manager.isSystemTable("public", "t_order"));
+    }
+    
+    @Test
+    void assertSystemTableMissingWithSchema() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putTable("public", "t_order");
+        assertFalse(manager.isSystemTable("public", "t_user"));
+    }
+    
+    @Test
+    void assertAllTablesExistInCollection() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putTable("public", "t_order");
+        manager.putTable("public", "t_user");
+        assertTrue(manager.isSystemTable("public", Arrays.asList("t_order", 
"t_user")));
+    }
+    
+    @Test
+    void assertMissingTableDetectedInCollection() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putTable("public", "t_order");
+        assertFalse(manager.isSystemTable("public", Arrays.asList("t_order", 
"t_user")));
+    }
+    
+    @Test
+    void assertEmptyTablesForAbsentSchema() {
+        assertTrue(new 
DialectSystemSchemaManager().getTables("absent").isEmpty());
+    }
+    
+    @Test
+    void assertLoadInputStreamsFromResources() {
+        DialectSystemSchemaManager manager = new DialectSystemSchemaManager();
+        manager.putResource("public", "dialect-system-resource.txt");
+        List<String> actual = 
manager.getAllInputStreams("public").stream().map(this::readString).collect(Collectors.toList());
+        assertThat(actual.get(0).trim(), is("resource-content"));
+    }
+    
+    @Test
+    void assertEmptyInputStreamListForAbsentResource() {
+        assertThat(new 
DialectSystemSchemaManager().getAllInputStreams("absent"), 
is(Collections.emptyList()));
+    }
+    
+    @SneakyThrows(IOException.class)
+    private String readString(final InputStream inputStream) {
+        try (
+                InputStream in = inputStream;
+                ByteArrayOutputStream out = new ByteArrayOutputStream()) {
+            byte[] buffer = new byte[128];
+            int length;
+            while (-1 != (length = in.read(buffer))) {
+                out.write(buffer, 0, length);
+            }
+            return new String(out.toByteArray(), StandardCharsets.UTF_8);
+        }
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/attribute/RuleAttributesTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/attribute/RuleAttributesTest.java
new file mode 100644
index 00000000000..e661645cb70
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/rule/attribute/RuleAttributesTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.rule.attribute;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Optional;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+
+class RuleAttributesTest {
+    
+    @Test
+    void assertFindsAttribute() {
+        RuleAttribute attribute = mock(RuleAttribute.class);
+        RuleAttributes attributes = new RuleAttributes(attribute);
+        assertTrue(attributes.findAttribute(RuleAttribute.class).isPresent());
+    }
+    
+    @Test
+    void assertEmptyWhenAttributeMissing() {
+        RuleAttributes attributes = new RuleAttributes();
+        Optional<RuleAttribute> actual = 
attributes.findAttribute(RuleAttribute.class);
+        assertFalse(actual.isPresent());
+    }
+    
+    @Test
+    void assertGetsAttribute() {
+        RuleAttribute attribute = mock(RuleAttribute.class);
+        RuleAttributes attributes = new RuleAttributes(attribute);
+        RuleAttribute actual = attributes.getAttribute(RuleAttribute.class);
+        assertThat(actual, instanceOf(RuleAttribute.class));
+    }
+    
+    @Test
+    void assertThrowsWhenAttributeMissing() {
+        RuleAttributes attributes = new RuleAttributes();
+        IllegalStateException actual = 
assertThrows(IllegalStateException.class, () -> 
attributes.getAttribute(RuleAttribute.class));
+        assertThat(actual.getMessage(), is("Can not find rule attribute: 
interface org.apache.shardingsphere.infra.rule.attribute.RuleAttribute"));
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/state/datasource/qualified/yaml/YamlQualifiedDataSourceStateSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/state/datasource/qualified/yaml/YamlQualifiedDataSourceStateSwapperTest.java
new file mode 100644
index 00000000000..d73af5ddec1
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/state/datasource/qualified/yaml/YamlQualifiedDataSourceStateSwapperTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.state.datasource.qualified.yaml;
+
+import org.apache.shardingsphere.infra.state.datasource.DataSourceState;
+import 
org.apache.shardingsphere.infra.state.datasource.qualified.QualifiedDataSourceState;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class YamlQualifiedDataSourceStateSwapperTest {
+    
+    private final YamlQualifiedDataSourceStateSwapper swapper = new 
YamlQualifiedDataSourceStateSwapper();
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        assertThat(swapper.swapToYamlConfiguration(new 
QualifiedDataSourceState(DataSourceState.ENABLED)).getState(), is("ENABLED"));
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlQualifiedDataSourceState yamlConfig = new 
YamlQualifiedDataSourceState();
+        yamlConfig.setState("DISABLED");
+        assertThat(swapper.swapToObject(yamlConfig).getState(), 
is(DataSourceState.DISABLED));
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
new file mode 100644
index 00000000000..fe0c0d63b2c
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/data/swapper/YamlRowStatisticsSwapperTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.data.swapper;
+
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
+import org.apache.shardingsphere.infra.metadata.statistics.RowStatistics;
+import org.apache.shardingsphere.infra.yaml.data.pojo.YamlRowStatistics;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.sql.Types;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
+class YamlRowStatisticsSwapperTest {
+    
+    @Test
+    void assertSwapToYamlConfigurationWithNullRows() {
+        YamlRowStatisticsSwapper swapper = new 
YamlRowStatisticsSwapper(Collections.emptyList());
+        YamlRowStatistics actual = swapper.swapToYamlConfiguration(new 
RowStatistics("uk", null));
+        assertThat(actual.getRows(), is(empty()));
+        assertThat(actual.getUniqueKey(), is("uk"));
+    }
+    
+    @Test
+    void assertConvertSpecialTypesWhenSwappingToYaml() {
+        List<ShardingSphereColumn> columns = Arrays.asList(
+                new ShardingSphereColumn("decimal_col", Types.DECIMAL, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("bigint_col", Types.BIGINT, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("decimal_null", Types.DECIMAL, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("varchar_col", Types.VARCHAR, false, 
false, false, true, false, true));
+        List<Object> rows = Arrays.asList(null, 5L, new BigDecimal("7.5"), 
"raw");
+        YamlRowStatisticsSwapper swapper = new 
YamlRowStatisticsSwapper(columns);
+        assertThat(swapper.swapToYamlConfiguration(new RowStatistics("uk", 
rows)).getRows(), contains(nullValue(), is("5"), is("7.5"), is("raw")));
+    }
+    
+    @Test
+    void assertSwapToObjectWithNullRows() {
+        assertThat(new 
YamlRowStatisticsSwapper(Collections.emptyList()).swapToObject(new 
YamlRowStatistics()).getRows(), is(empty()));
+    }
+    
+    @Test
+    void assertSwapToObjectWithEmptyRows() {
+        List<ShardingSphereColumn> columns = Collections.singletonList(new 
ShardingSphereColumn("col", Types.VARCHAR, false, false, false, true, false, 
true));
+        YamlRowStatistics yamlConfig = new YamlRowStatistics();
+        yamlConfig.setRows(Collections.emptyList());
+        assertThat(new 
YamlRowStatisticsSwapper(columns).swapToObject(yamlConfig).getRows(), 
is(empty()));
+    }
+    
+    @Test
+    void assertConvertDataTypesWhenSwappingToObject() {
+        List<ShardingSphereColumn> columns = Arrays.asList(
+                new ShardingSphereColumn("decimal_col", Types.DECIMAL, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("bigint_col", Types.BIGINT, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("real_col", Types.REAL, false, false, 
false, true, false, true),
+                new ShardingSphereColumn("float_col", Types.FLOAT, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("varchar_col", Types.VARCHAR, false, 
false, false, true, false, true),
+                new ShardingSphereColumn("decimal_null", Types.DECIMAL, false, 
false, false, true, false, true));
+        YamlRowStatistics yamlConfig = new YamlRowStatistics();
+        yamlConfig.setUniqueKey("uk");
+        yamlConfig.setRows(Arrays.asList("1.5", "2", "3.3", "4.4", "text", 
null));
+        YamlRowStatisticsSwapper swapper = new 
YamlRowStatisticsSwapper(columns);
+        RowStatistics actual = swapper.swapToObject(yamlConfig);
+        assertThat(actual.getUniqueKey(), is("uk"));
+        assertThat(actual.getRows(), contains(new BigDecimal("1.5"), 2L, 
Float.parseFloat("3.3"), Float.parseFloat("4.4"), "text", null));
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlColumnSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlColumnSwapperTest.java
new file mode 100644
index 00000000000..b7e5179546b
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlColumnSwapperTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.schema.swapper;
+
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn;
+import 
org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereColumn;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class YamlColumnSwapperTest {
+    
+    private final YamlColumnSwapper swapper = new YamlColumnSwapper();
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        ShardingSphereColumn column = new ShardingSphereColumn("id", 1, true, 
false, true, true, false, false);
+        YamlShardingSphereColumn actual = 
swapper.swapToYamlConfiguration(column);
+        assertThat(actual.getName(), is("id"));
+        assertThat(actual.getDataType(), is(1));
+        assertTrue(actual.isPrimaryKey());
+        assertFalse(actual.isGenerated());
+        assertTrue(actual.isCaseSensitive());
+        assertTrue(actual.isVisible());
+        assertFalse(actual.isUnsigned());
+        assertFalse(actual.isNullable());
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlShardingSphereColumn yamlColumn = new YamlShardingSphereColumn();
+        yamlColumn.setName("id");
+        yamlColumn.setDataType(2);
+        yamlColumn.setPrimaryKey(false);
+        yamlColumn.setGenerated(true);
+        yamlColumn.setCaseSensitive(false);
+        yamlColumn.setVisible(false);
+        yamlColumn.setUnsigned(true);
+        yamlColumn.setNullable(true);
+        ShardingSphereColumn actual = swapper.swapToObject(yamlColumn);
+        assertThat(actual.getName(), is("id"));
+        assertThat(actual.getDataType(), is(2));
+        assertFalse(actual.isPrimaryKey());
+        assertTrue(actual.isGenerated());
+        assertFalse(actual.isCaseSensitive());
+        assertFalse(actual.isVisible());
+        assertTrue(actual.isUnsigned());
+        assertTrue(actual.isNullable());
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlConstraintSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlConstraintSwapperTest.java
new file mode 100644
index 00000000000..aa48faedc85
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlConstraintSwapperTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.schema.swapper;
+
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereConstraint;
+import 
org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereConstraint;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class YamlConstraintSwapperTest {
+    
+    private final YamlConstraintSwapper swapper = new YamlConstraintSwapper();
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        ShardingSphereConstraint constraint = new 
ShardingSphereConstraint("fk_user", "t_user");
+        YamlShardingSphereConstraint actual = 
swapper.swapToYamlConfiguration(constraint);
+        assertThat(actual.getName(), is("fk_user"));
+        assertThat(actual.getReferencedTableName(), is("t_user"));
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlShardingSphereConstraint yamlConstraint = new 
YamlShardingSphereConstraint();
+        yamlConstraint.setName("fk_order");
+        yamlConstraint.setReferencedTableName("t_order");
+        ShardingSphereConstraint actual = swapper.swapToObject(yamlConstraint);
+        assertThat(actual.getName(), is("fk_order"));
+        assertThat(actual.getReferencedTableName(), is("t_order"));
+    }
+}
diff --git 
a/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlIndexSwapperTest.java
 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlIndexSwapperTest.java
new file mode 100644
index 00000000000..cd0a00fecf5
--- /dev/null
+++ 
b/infra/common/src/test/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlIndexSwapperTest.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.yaml.schema.swapper;
+
+import 
org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex;
+import 
org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereIndex;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class YamlIndexSwapperTest {
+    
+    private final YamlIndexSwapper swapper = new YamlIndexSwapper();
+    
+    @Test
+    void assertSwapToYamlConfiguration() {
+        ShardingSphereIndex index = new ShardingSphereIndex("idx_user", 
Arrays.asList("id", "name"), true);
+        YamlShardingSphereIndex actual = 
swapper.swapToYamlConfiguration(index);
+        assertThat(actual.getName(), is("idx_user"));
+        assertThat(actual.getColumns(), contains("id", "name"));
+        assertTrue(actual.isUnique());
+    }
+    
+    @Test
+    void assertSwapToObject() {
+        YamlShardingSphereIndex yamlIndex = new YamlShardingSphereIndex();
+        yamlIndex.setName("idx_order");
+        yamlIndex.getColumns().addAll(Arrays.asList("order_id", "user_id"));
+        yamlIndex.setUnique(false);
+        ShardingSphereIndex actual = swapper.swapToObject(yamlIndex);
+        assertThat(actual.getName(), is("idx_order"));
+        assertThat(actual.getColumns(), contains("order_id", "user_id"));
+        assertFalse(actual.isUnique());
+    }
+}
diff --git a/infra/common/src/test/resources/dialect-system-resource.txt 
b/infra/common/src/test/resources/dialect-system-resource.txt
new file mode 100644
index 00000000000..5d7409f62e2
--- /dev/null
+++ b/infra/common/src/test/resources/dialect-system-resource.txt
@@ -0,0 +1 @@
+resource-content
diff --git 
a/infra/data-source-pool/type/hikari/src/test/java/org/apache/shardingsphere/infra/datasource/pool/hikari/metadata/HikariDataSourcePoolMetaDataTest.java
 
b/infra/data-source-pool/type/hikari/src/test/java/org/apache/shardingsphere/infra/datasource/pool/hikari/metadata/HikariDataSourcePoolMetaDataTest.java
new file mode 100644
index 00000000000..54279c6b0cc
--- /dev/null
+++ 
b/infra/data-source-pool/type/hikari/src/test/java/org/apache/shardingsphere/infra/datasource/pool/hikari/metadata/HikariDataSourcePoolMetaDataTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.datasource.pool.hikari.metadata;
+
+import 
org.apache.shardingsphere.infra.datasource.pool.metadata.DataSourcePoolMetaData;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import org.junit.jupiter.api.Test;
+
+import java.util.Map;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasEntry;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.isA;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class HikariDataSourcePoolMetaDataTest {
+    
+    private final DataSourcePoolMetaData metaData = 
TypedSPILoader.getService(DataSourcePoolMetaData.class, 
"com.zaxxer.hikari.HikariDataSource");
+    
+    @Test
+    void assertGetDefaultProperties() {
+        Map<String, Object> actual = metaData.getDefaultProperties();
+        assertThat(actual, hasEntry("connectionTimeout", 30L * 1000L));
+        assertThat(actual, hasEntry("idleTimeout", 60L * 1000L));
+        assertThat(actual, hasEntry("maxLifetime", 30L * 70L * 1000L));
+        assertThat(actual, hasEntry("maximumPoolSize", 50));
+        assertThat(actual, hasEntry("minimumIdle", 1));
+        assertThat(actual, hasEntry("readOnly", false));
+        assertThat(actual, hasEntry("keepaliveTime", 0));
+        assertTrue(metaData.isDefault());
+    }
+    
+    @Test
+    void assertGetSkippedProperties() {
+        Map<String, Object> actual = metaData.getSkippedProperties();
+        assertThat(actual, hasEntry("minimumIdle", -1));
+        assertThat(actual, hasEntry("maximumPoolSize", -1));
+    }
+    
+    @Test
+    void assertGetPropertySynonyms() {
+        Map<String, String> actual = metaData.getPropertySynonyms();
+        assertThat(actual, hasEntry("url", "jdbcUrl"));
+        assertThat(actual, hasEntry("connectionTimeoutMilliseconds", 
"connectionTimeout"));
+        assertThat(actual, hasEntry("idleTimeoutMilliseconds", "idleTimeout"));
+        assertThat(actual, hasEntry("maxLifetimeMilliseconds", "maxLifetime"));
+        assertThat(actual, hasEntry("maxPoolSize", "maximumPoolSize"));
+        assertThat(actual, hasEntry("minPoolSize", "minimumIdle"));
+    }
+    
+    @Test
+    void assertGetTransientFieldNames() {
+        assertThat(metaData.getTransientFieldNames(), hasItems("running", 
"poolName", "closed"));
+    }
+    
+    @Test
+    void assertGetFieldMetaData() {
+        assertThat(metaData.getFieldMetaData(), 
isA(HikariDataSourcePoolFieldMetaData.class));
+    }
+}
diff --git 
a/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
 
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
new file mode 100644
index 00000000000..57736a2bb1f
--- /dev/null
+++ 
b/infra/executor/src/test/java/org/apache/shardingsphere/infra/executor/sql/process/lock/ProcessOperationLockTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.executor.sql.process.lock;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.time.Duration;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class ProcessOperationLockTest {
+    
+    @Test
+    void assertAwaitReturnsWhenReadyToRelease() {
+        assertTrue(new ProcessOperationLock(1).awaitDefaultTime(() -> true));
+    }
+    
+    @Test
+    void assertAwaitAndBeReleasedByNotify() {
+        ProcessOperationLock lock = new ProcessOperationLock(1);
+        AtomicBoolean result = new AtomicBoolean(false);
+        Thread awaitingThread = new Thread(() -> 
result.set(lock.awaitDefaultTime(() -> false)));
+        awaitingThread.start();
+        lock.doNotify();
+        Assertions.assertTimeoutPreemptively(Duration.ofSeconds(1), () -> 
awaitingThread.join());
+        assertTrue(result.get());
+    }
+}
diff --git 
a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/stream/IteratorStreamMergedResultTest.java
 
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/stream/IteratorStreamMergedResultTest.java
new file mode 100644
index 00000000000..77edff9d83e
--- /dev/null
+++ 
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/stream/IteratorStreamMergedResultTest.java
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.merge.result.impl.stream;
+
+import 
org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
+import org.junit.jupiter.api.Test;
+import org.mockito.internal.configuration.plugins.Plugins;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+class IteratorStreamMergedResultTest {
+    
+    @Test
+    void assertNextWhenCurrentHasRow() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        when(queryResult.next()).thenReturn(true);
+        assertTrue(new 
IteratorStreamMergedResult(Collections.singletonList(queryResult)).next());
+    }
+    
+    @Test
+    void assertNextWhenNoResults() throws SQLException {
+        assertFalse(new 
IteratorStreamMergedResult(Collections.singletonList(mock(QueryResult.class))).next());
+    }
+    
+    @Test
+    void assertNextWithSwitchToFollowingResult() throws SQLException {
+        QueryResult first = mock(QueryResult.class);
+        QueryResult second = mock(QueryResult.class);
+        when(second.next()).thenReturn(true);
+        assertTrue(new IteratorStreamMergedResult(Arrays.asList(first, 
second)).next());
+    }
+    
+    @Test
+    void assertNextUntilDataFound() throws SQLException {
+        QueryResult first = mock(QueryResult.class);
+        QueryResult second = mock(QueryResult.class);
+        QueryResult third = mock(QueryResult.class);
+        when(third.next()).thenReturn(true);
+        assertTrue(new IteratorStreamMergedResult(Arrays.asList(first, second, 
third)).next());
+    }
+    
+    @Test
+    void assertNextFalseWhenAllEmpty() throws SQLException {
+        assertFalse(new 
IteratorStreamMergedResult(Arrays.asList(mock(QueryResult.class), 
mock(QueryResult.class))).next());
+    }
+    
+    @Test
+    void assertGetValueAndTrackWasNull() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        when(queryResult.getValue(1, String.class)).thenReturn("v");
+        when(queryResult.wasNull()).thenReturn(true);
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        Object actual = mergedResult.getValue(1, String.class);
+        assertThat(actual, is("v"));
+        assertTrue(mergedResult.wasNull());
+    }
+    
+    @Test
+    void assertGetCalendarValueAndTrackWasNull() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        Calendar calendar = Calendar.getInstance();
+        when(queryResult.getCalendarValue(1, String.class, 
calendar)).thenReturn("v");
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        Object actual = mergedResult.getCalendarValue(1, String.class, 
calendar);
+        assertThat(actual, is("v"));
+        assertFalse(mergedResult.wasNull());
+    }
+    
+    @Test
+    void assertGetInputStreamAndTrackWasNull() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(new 
byte[]{1});
+        when(queryResult.getInputStream(1, "stream")).thenReturn(inputStream);
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        ByteArrayInputStream actual = (ByteArrayInputStream) 
mergedResult.getInputStream(1, "stream");
+        assertThat(actual, is(inputStream));
+        assertFalse(mergedResult.wasNull());
+    }
+    
+    @Test
+    void assertGetCharacterStreamAndTrackWasNull() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        Reader reader = new InputStreamReader(new ByteArrayInputStream(new 
byte[0]));
+        when(queryResult.getCharacterStream(1)).thenReturn(reader);
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        assertThat(mergedResult.getCharacterStream(1), is(reader));
+        assertFalse(mergedResult.wasNull());
+    }
+    
+    @Test
+    void assertThrowWhenCurrentQueryResultIsNull() throws 
ReflectiveOperationException {
+        QueryResult queryResult = mock(QueryResult.class);
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        
Plugins.getMemberAccessor().set(StreamMergedResult.class.getDeclaredField("currentQueryResult"),
 mergedResult, null);
+        SQLException actual = assertThrows(SQLException.class, () -> 
mergedResult.getValue(1, Object.class));
+        assertThat(actual.getMessage(), is("Current ResultSet is null, 
ResultSet perhaps end of next"));
+    }
+    
+    @Test
+    void assertWasNull() throws SQLException {
+        QueryResult queryResult = mock(QueryResult.class);
+        when(queryResult.wasNull()).thenReturn(true);
+        IteratorStreamMergedResult mergedResult = new 
IteratorStreamMergedResult(Collections.singletonList(queryResult));
+        assertNull(mergedResult.getCharacterStream(1));
+        assertTrue(mergedResult.wasNull());
+    }
+}
diff --git 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
 
b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
index bb873743422..04340862355 100644
--- 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
+++ 
b/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
@@ -37,6 +37,11 @@ public final class ColumnDefinitionToken extends SQLToken {
         this.dataType = dataType;
     }
     
+    @Override
+    public int getStopIndex() {
+        return getStartIndex();
+    }
+    
     @Override
     public String toString() {
         if (Strings.isNullOrEmpty(dataType)) {
@@ -47,9 +52,4 @@ public final class ColumnDefinitionToken extends SQLToken {
         }
         return columnName + " " + dataType;
     }
-    
-    @Override
-    public int getStopIndex() {
-        return getStartIndex();
-    }
 }
diff --git 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
 
b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionTokenTest.java
similarity index 51%
copy from 
infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
copy to 
infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionTokenTest.java
index bb873743422..cda35d67bd0 100644
--- 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
+++ 
b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionTokenTest.java
@@ -17,39 +17,30 @@
 
 package org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.generic;
 
-import com.google.common.base.Strings;
-import lombok.Getter;
-import org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.SQLToken;
+import org.junit.jupiter.api.Test;
 
-/**
- * Column definition token.
- */
-@Getter
-public final class ColumnDefinitionToken extends SQLToken {
-    
-    private final String columnName;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class ColumnDefinitionTokenTest {
     
-    private final String dataType;
+    @Test
+    void assertGetStopIndex() {
+        assertThat(new ColumnDefinitionToken("id", "VARCHAR", 
7).getStopIndex(), is(7));
+    }
     
-    public ColumnDefinitionToken(final String columnName, final String 
dataType, final int startIndex) {
-        super(startIndex);
-        this.columnName = columnName;
-        this.dataType = dataType;
+    @Test
+    void assertToStringWhenDataTypeIsEmpty() {
+        assertThat(new ColumnDefinitionToken("id", "", 5).toString(), 
is("id"));
     }
     
-    @Override
-    public String toString() {
-        if (Strings.isNullOrEmpty(dataType)) {
-            return columnName;
-        }
-        if (Strings.isNullOrEmpty(columnName)) {
-            return dataType;
-        }
-        return columnName + " " + dataType;
+    @Test
+    void assertToStringWhenColumnNameIsEmpty() {
+        assertThat(new ColumnDefinitionToken("", "VARCHAR", 3).toString(), 
is("VARCHAR"));
     }
     
-    @Override
-    public int getStopIndex() {
-        return getStartIndex();
+    @Test
+    void assertToStringWithFullDefinition() {
+        assertThat(new ColumnDefinitionToken("id", "VARCHAR", 2).toString(), 
is("id VARCHAR"));
     }
 }
diff --git 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
 
b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstituteColumnDefinitionTokenTest.java
similarity index 53%
copy from 
infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
copy to 
infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstituteColumnDefinitionTokenTest.java
index bb873743422..a971edc08a3 100644
--- 
a/infra/rewrite/core/src/main/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/ColumnDefinitionToken.java
+++ 
b/infra/rewrite/core/src/test/java/org/apache/shardingsphere/infra/rewrite/sql/token/common/pojo/generic/SubstituteColumnDefinitionTokenTest.java
@@ -17,39 +17,27 @@
 
 package org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.generic;
 
-import com.google.common.base.Strings;
-import lombok.Getter;
 import org.apache.shardingsphere.infra.rewrite.sql.token.common.pojo.SQLToken;
+import org.junit.jupiter.api.Test;
 
-/**
- * Column definition token.
- */
-@Getter
-public final class ColumnDefinitionToken extends SQLToken {
-    
-    private final String columnName;
-    
-    private final String dataType;
-    
-    public ColumnDefinitionToken(final String columnName, final String 
dataType, final int startIndex) {
-        super(startIndex);
-        this.columnName = columnName;
-        this.dataType = dataType;
-    }
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+class SubstituteColumnDefinitionTokenTest {
     
-    @Override
-    public String toString() {
-        if (Strings.isNullOrEmpty(dataType)) {
-            return columnName;
-        }
-        if (Strings.isNullOrEmpty(columnName)) {
-            return dataType;
-        }
-        return columnName + " " + dataType;
+    @Test
+    void assertToStringForRemoveTrailingDelimiterForLastColumn() {
+        Collection<SQLToken> tokens = Arrays.asList(new 
ColumnDefinitionToken("id", "INT", 0), new ColumnDefinitionToken("name", 
"VARCHAR", 4));
+        assertThat(new SubstituteColumnDefinitionToken(0, 1, true, 
tokens).toString(), is("id INT, name VARCHAR"));
     }
     
-    @Override
-    public int getStopIndex() {
-        return getStartIndex();
+    @Test
+    void assertToStringWhenNotLastColumn() {
+        Collection<SQLToken> tokens = Collections.singleton(new 
ColumnDefinitionToken("id", "INT", 0));
+        assertThat(new SubstituteColumnDefinitionToken(0, 0, false, 
tokens).toString(), is("id INT, "));
     }
 }
diff --git 
a/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
 
b/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
new file mode 100644
index 00000000000..ea8429d892e
--- /dev/null
+++ 
b/infra/rewrite/dialect/mysql/src/test/java/org/apache/shardingsphere/infra/rewrite/mysql/MySQLToBeRemovedSegmentsProviderTest.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.rewrite.mysql;
+
+import 
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import 
org.apache.shardingsphere.infra.rewrite.sql.token.common.generator.generic.DialectToBeRemovedSegmentsProvider;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.dal.FromDatabaseSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.DatabaseSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.SimpleTableSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.segment.generic.table.TableNameSegment;
+import 
org.apache.shardingsphere.sql.parser.statement.core.value.identifier.IdentifierValue;
+import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.column.MySQLShowColumnsStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.index.MySQLShowIndexStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQLShowTableStatusStatement;
+import 
org.apache.shardingsphere.sql.parser.statement.mysql.dal.show.table.MySQLShowTablesStatement;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.empty;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+class MySQLToBeRemovedSegmentsProviderTest {
+    
+    private final DatabaseType databaseType = 
TypedSPILoader.getService(DatabaseType.class, "MySQL");
+    
+    private final DialectToBeRemovedSegmentsProvider provider = 
DatabaseTypedSPILoader.getService(DialectToBeRemovedSegmentsProvider.class, 
databaseType);
+    
+    @Test
+    void assertGetToBeRemovedSQLSegmentsFromShowTables() {
+        FromDatabaseSegment fromDatabase = createFromDatabaseSegment();
+        MySQLShowTablesStatement statement = new 
MySQLShowTablesStatement(mock(DatabaseType.class), fromDatabase, null, false);
+        assertThat(provider.getToBeRemovedSQLSegments(statement), 
contains(fromDatabase));
+    }
+    
+    @Test
+    void assertGetToBeRemovedSQLSegmentsWhenShowColumnsWithoutFromDatabase() {
+        MySQLShowColumnsStatement statement = new 
MySQLShowColumnsStatement(mock(DatabaseType.class), createSimpleTableSegment(), 
null, null);
+        assertThat(provider.getToBeRemovedSQLSegments(statement), is(empty()));
+    }
+    
+    @Test
+    void assertGetToBeRemovedSQLSegmentsFromShowIndex() {
+        FromDatabaseSegment fromDatabase = createFromDatabaseSegment();
+        MySQLShowIndexStatement statement = new 
MySQLShowIndexStatement(mock(DatabaseType.class), createSimpleTableSegment(), 
fromDatabase);
+        assertThat(provider.getToBeRemovedSQLSegments(statement), 
contains(fromDatabase));
+    }
+    
+    @Test
+    void assertGetToBeRemovedSQLSegmentsFromShowTableStatus() {
+        FromDatabaseSegment fromDatabase = createFromDatabaseSegment();
+        MySQLShowTableStatusStatement statement = new 
MySQLShowTableStatusStatement(mock(DatabaseType.class), fromDatabase, null);
+        assertThat(provider.getToBeRemovedSQLSegments(statement), 
contains(fromDatabase));
+    }
+    
+    private FromDatabaseSegment createFromDatabaseSegment() {
+        return new FromDatabaseSegment(0, new DatabaseSegment(0, 0, new 
IdentifierValue("db")));
+    }
+    
+    private SimpleTableSegment createSimpleTableSegment() {
+        return new SimpleTableSegment(new TableNameSegment(0, 0, new 
IdentifierValue("tbl")));
+    }
+}
diff --git 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessor.java
 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessor.java
index 856b7fbc896..faa1c6c6d91 100644
--- 
a/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessor.java
+++ 
b/infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessor.java
@@ -56,7 +56,7 @@ public final class DefaultYamlTupleProcessor {
     }
     
     private boolean isEmptyMappingNode(final Node valueNode) {
-        return Tag.MAP.equals(valueNode.getTag()) && (((MappingNode) 
valueNode).getValue().isEmpty()
-                || ((MappingNode) valueNode).getValue().stream().anyMatch(each 
-> Tag.NULL.equals(each.getValueNode().getTag())));
+        return Tag.MAP.equals(valueNode.getTag()) && (((MappingNode) 
valueNode).getValue().isEmpty() || ((MappingNode) valueNode).getValue()
+                .stream().anyMatch(each -> 
Tag.NULL.equals(each.getValueNode().getTag())));
     }
 }
diff --git 
a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/file/SystemResourceFileUtilsTest.java
 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/file/SystemResourceFileUtilsTest.java
new file mode 100644
index 00000000000..428354138f8
--- /dev/null
+++ 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/file/SystemResourceFileUtilsTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.util.file;
+
+import org.junit.jupiter.api.Test;
+
+import java.nio.file.Files;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class SystemResourceFileUtilsTest {
+    
+    @Test
+    void assertGetPath() {
+        
assertTrue(Files.exists(SystemResourceFileUtils.getPath("system-resource-file.txt")));
+    }
+    
+    @Test
+    void assertReadFile() {
+        
assertThat(SystemResourceFileUtils.readFile("system-resource-file.txt"), 
containsString("line-one" + System.lineSeparator() + "line-two"));
+    }
+}
diff --git 
a/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessorTest.java
 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessorTest.java
new file mode 100644
index 00000000000..103600f71d6
--- /dev/null
+++ 
b/infra/util/src/test/java/org/apache/shardingsphere/infra/util/yaml/representer/processor/DefaultYamlTupleProcessorTest.java
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.infra.util.yaml.representer.processor;
+
+import org.junit.jupiter.api.Test;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+import java.util.Collections;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class DefaultYamlTupleProcessorTest {
+    
+    private final DefaultYamlTupleProcessor processor = new 
DefaultYamlTupleProcessor();
+    
+    @Test
+    void assertProcessWhenValueIsNullNode() {
+        assertNull(processor.process(new NodeTuple(createScalar("key"), new 
ScalarNode(Tag.NULL, "null", null, null, DumperOptions.ScalarStyle.PLAIN))));
+    }
+    
+    @Test
+    void assertProcessWhenValueIsEmptySequence() {
+        assertNull(processor.process(new NodeTuple(createScalar("key"), new 
SequenceNode(Tag.SEQ, Collections.emptyList(), 
DumperOptions.FlowStyle.BLOCK))));
+    }
+    
+    @Test
+    void assertProcessWhenValueIsEmptyMapping() {
+        assertNull(processor.process(new NodeTuple(createScalar("key"), new 
MappingNode(Tag.MAP, Collections.emptyList(), DumperOptions.FlowStyle.BLOCK))));
+    }
+    
+    @Test
+    void assertProcessWhenMappingContainsNullValue() {
+        NodeTuple mappingTuple = new NodeTuple(createScalar("inner"), new 
ScalarNode(Tag.NULL, "null", null, null, DumperOptions.ScalarStyle.PLAIN));
+        MappingNode mappingNode = new MappingNode(Tag.MAP, 
Collections.singletonList(mappingTuple), DumperOptions.FlowStyle.BLOCK);
+        assertNull(processor.process(new NodeTuple(createScalar("key"), 
mappingNode)));
+    }
+    
+    @Test
+    void assertProcessWhenValueIsNotUnset() {
+        NodeTuple tuple = new NodeTuple(createScalar("key"), 
createScalar("value"));
+        assertThat(processor.process(tuple), is(tuple));
+    }
+    
+    @Test
+    void assertProcessWhenSequenceNotEmpty() {
+        SequenceNode sequenceNode = new SequenceNode(Tag.SEQ, 
Collections.singletonList(createScalar("v")), DumperOptions.FlowStyle.BLOCK);
+        NodeTuple tuple = new NodeTuple(createScalar("key"), sequenceNode);
+        assertThat(processor.process(tuple), is(tuple));
+    }
+    
+    private ScalarNode createScalar(final String value) {
+        return new ScalarNode(Tag.STR, value, null, null, 
DumperOptions.ScalarStyle.PLAIN);
+    }
+}
diff --git a/infra/util/src/test/resources/system-resource-file.txt 
b/infra/util/src/test/resources/system-resource-file.txt
new file mode 100644
index 00000000000..0eabd516bd4
--- /dev/null
+++ b/infra/util/src/test/resources/system-resource-file.txt
@@ -0,0 +1,2 @@
+line-one
+line-two

Reply via email to