You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by me...@apache.org on 2025/02/11 11:06:23 UTC

(shardingsphere) branch master updated: Refactor GlobalRuleNodePath (#34631)

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

menghaoran 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 ab60cb83a6b Refactor GlobalRuleNodePath (#34631)
ab60cb83a6b is described below

commit ab60cb83a6b4fae339051b3a19e320a44d6f3009
Author: Haoran Meng <me...@gmail.com>
AuthorDate: Tue Feb 11 19:06:16 2025 +0800

    Refactor GlobalRuleNodePath (#34631)
---
 .../shardingsphere/mode/node/path/config/GlobalRuleNodePath.java | 2 +-
 .../mode/node/path/config/GlobalRuleNodePathTest.java            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePath.java b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePath.java
index a7fdda89fc0..07997266446 100644
--- a/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePath.java
+++ b/mode/node/src/main/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePath.java
@@ -31,7 +31,7 @@ public final class GlobalRuleNodePath {
     
     private static final String ROOT_NODE = "/rules";
     
-    private static final VersionNodePathParser PARSER = new VersionNodePathParser(NodePathPattern.IDENTIFIER);
+    private static final VersionNodePathParser PARSER = new VersionNodePathParser(getRootPath() + "/" + NodePathPattern.IDENTIFIER);
     
     /**
      * Get global rule root path.
diff --git a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePathTest.java b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePathTest.java
index c0b80d12c10..acb0ef75e93 100644
--- a/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePathTest.java
+++ b/mode/node/src/test/java/org/apache/shardingsphere/mode/node/path/config/GlobalRuleNodePathTest.java
@@ -21,6 +21,8 @@ import org.junit.jupiter.api.Test;
 
 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 GlobalRuleNodePathTest {
     
@@ -40,4 +42,11 @@ class GlobalRuleNodePathTest {
         assertThat(GlobalRuleNodePath.getVersionNodePathGenerator("foo_rule").getVersionsPath(), is("/rules/foo_rule/versions"));
         assertThat(GlobalRuleNodePath.getVersionNodePathGenerator("foo_rule").getVersionPath(0), is("/rules/foo_rule/versions/0"));
     }
+    
+    @Test
+    void assertFindIdentifierByActiveVersionPath() {
+        assertTrue(GlobalRuleNodePath.getVersionNodePathParser().findIdentifierByActiveVersionPath("/rules/foo_rule/active_version", 1).isPresent());
+        assertThat(GlobalRuleNodePath.getVersionNodePathParser().findIdentifierByActiveVersionPath("/rules/foo_rule/active_version", 1).get(), is("foo_rule"));
+        assertFalse(GlobalRuleNodePath.getVersionNodePathParser().findIdentifierByActiveVersionPath("/rules/foo_rule/versions", 1).isPresent());
+    }
 }