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

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 1c7b80ff3c3 Add more test cases on DatabaseMetaDataNode (#32971)
1c7b80ff3c3 is described below

commit 1c7b80ff3c3d1c709069f712f0bbfa281f8e1b7a
Author: Liang Zhang <zhangli...@apache.org>
AuthorDate: Tue Sep 24 12:32:13 2024 +0800

    Add more test cases on DatabaseMetaDataNode (#32971)
---
 .../persist/node/DatabaseMetaDataNodeTest.java     | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git 
a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/node/DatabaseMetaDataNodeTest.java
 
b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/node/DatabaseMetaDataNodeTest.java
index 9d03e62b767..6ae6e5134f5 100644
--- 
a/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/node/DatabaseMetaDataNodeTest.java
+++ 
b/kernel/metadata/core/src/test/java/org/apache/shardingsphere/metadata/persist/node/DatabaseMetaDataNodeTest.java
@@ -23,10 +23,31 @@ import java.util.Optional;
 
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 class DatabaseMetaDataNodeTest {
     
+    @Test
+    void assertGetDatabaseNamePath() {
+        assertThat(DatabaseMetaDataNode.getDatabaseNamePath("foo_db"), 
is("/metadata/foo_db"));
+    }
+    
+    @Test
+    void assertGetMetaDataSchemaPath() {
+        assertThat(DatabaseMetaDataNode.getMetaDataSchemaPath("foo_db", 
"foo_schema"), is("/metadata/foo_db/schemas/foo_schema"));
+    }
+    
+    @Test
+    void assertGetMetaDataSchemasPath() {
+        assertThat(DatabaseMetaDataNode.getMetaDataSchemasPath("foo_db"), 
is("/metadata/foo_db/schemas"));
+    }
+    
+    @Test
+    void assertGetMetaDataTablesPath() {
+        assertThat(DatabaseMetaDataNode.getMetaDataTablesPath("foo_db", 
"foo_schema"), is("/metadata/foo_db/schemas/foo_schema/tables"));
+    }
+    
     @Test
     void assertGetDatabaseName() {
         Optional<String> actual = 
DatabaseMetaDataNode.getDatabaseName("/metadata/foo_db");
@@ -34,6 +55,11 @@ class DatabaseMetaDataNodeTest {
         assertThat(actual.get(), is("foo_db"));
     }
     
+    @Test
+    void assertGetDatabaseNameIfNotFound() {
+        
assertFalse(DatabaseMetaDataNode.getDatabaseName("/metadata").isPresent());
+    }
+    
     @Test
     void assertGetDatabaseNameBySchemaNode() {
         Optional<String> actual = 
DatabaseMetaDataNode.getDatabaseNameBySchemaNode("/metadata/foo_db/schemas/foo_schema");
@@ -41,6 +67,11 @@ class DatabaseMetaDataNodeTest {
         assertThat(actual.get(), is("foo_db"));
     }
     
+    @Test
+    void assertGetDatabaseNameBySchemaNodeIfNotFound() {
+        
assertFalse(DatabaseMetaDataNode.getDatabaseNameBySchemaNode("/xxx/foo_db").isPresent());
+    }
+    
     @Test
     void assertGetSchemaName() {
         Optional<String> actual = 
DatabaseMetaDataNode.getSchemaName("/metadata/foo_db/schemas/foo_schema");
@@ -48,10 +79,30 @@ class DatabaseMetaDataNodeTest {
         assertThat(actual.get(), is("foo_schema"));
     }
     
+    @Test
+    void assertGetSchemaNameIfNotFound() {
+        
assertFalse(DatabaseMetaDataNode.getSchemaName("/metadata/foo_db/xxx/foo_schema").isPresent());
+    }
+    
     @Test
     void assertGetSchemaNameByTableNode() {
         Optional<String> actual = 
DatabaseMetaDataNode.getSchemaNameByTableNode("/metadata/foo_db/schemas/foo_schema/tables");
         assertTrue(actual.isPresent());
         assertThat(actual.get(), is("foo_schema"));
     }
+    
+    @Test
+    void assertGetSchemaNameByTableNodeIfNotFound() {
+        
assertFalse(DatabaseMetaDataNode.getSchemaNameByTableNode("/xxx/foo_db/schemas/foo_schema/tables").isPresent());
+    }
+    
+    @Test
+    void assertGetVersionNodeByActiveVersionPath() {
+        
assertThat(DatabaseMetaDataNode.getVersionNodeByActiveVersionPath("foo_rule", 
"1"), is("foo_rule/1"));
+    }
+    
+    @Test
+    void assertGetMetaDataNode() {
+        assertThat(DatabaseMetaDataNode.getMetaDataNode(), is("/metadata"));
+    }
 }

Reply via email to