You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/04/21 11:19:18 UTC

[shardingsphere] branch master updated: add unit test for data node (#15881) (#16970)

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 4354c3df905 add unit test for data node (#15881) (#16970)
4354c3df905 is described below

commit 4354c3df905e38ca749e6ff40217037ffe2533df
Author: galaxy <ga...@tencent.com>
AuthorDate: Thu Apr 21 19:19:12 2022 +0800

    add unit test for data node (#15881) (#16970)
---
 .../infra/datanode/DataNodeTest.java               | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
index b90ae726e08..392ac69dfac 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/datanode/DataNodeTest.java
@@ -93,4 +93,35 @@ public final class DataNodeTest {
         DataNode dataNode = new DataNode(text);
         assertThat(dataNode.getFormattedTextLength(), is(text.length()));
     }
+
+    @Test
+    public void assertNewValidDataNodeIncludeInstance() {
+        DataNode dataNode = new DataNode("ds_0.db_0.tbl_0");
+        assertThat(dataNode.getDataSourceName(), is("ds_0.db_0"));
+        assertThat(dataNode.getTableName(), is("tbl_0"));
+    }
+
+    @Test
+    public void assertHashCodeIncludeInstance() {
+        assertThat(new DataNode("ds_0.db_0.tbl_0").hashCode(), is(new DataNode("ds_0.db_0.tbl_0").hashCode()));
+    }
+
+    @Test
+    public void assertToStringIncludeInstance() {
+        assertThat(new DataNode("ds_0.db_0.tbl_0").toString(), is("DataNode(dataSourceName=ds_0.db_0, tableName=tbl_0, schemaName=null)"));
+    }
+
+    @Test
+    public void assertFormatIncludeInstance() {
+        String expected = "ds_0.db_0.tbl_0";
+        DataNode dataNode = new DataNode(expected);
+        assertThat(dataNode.format(), is(expected));
+    }
+
+    @Test
+    public void assertFormattedTextLengthIncludeInstance() {
+        String text = "ds_0.db_0.tbl_0";
+        DataNode dataNode = new DataNode(text);
+        assertThat(dataNode.getFormattedTextLength(), is(text.length()));
+    }
 }