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

geniuspig pushed a commit to branch refactor_metadata_test
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit df93c907d3865df69680c58342779c6a6f0a1b1b
Author: Boris <[email protected]>
AuthorDate: Wed Dec 16 16:57:59 2020 +0800

    Update PartialPathTest.java
---
 .../apache/iotdb/db/metadata/PartialPathTest.java  | 34 +++++++++++++++-------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git 
a/server/src/test/java/org/apache/iotdb/db/metadata/PartialPathTest.java 
b/server/src/test/java/org/apache/iotdb/db/metadata/PartialPathTest.java
index 4b77d44..5e8eaa4 100644
--- a/server/src/test/java/org/apache/iotdb/db/metadata/PartialPathTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/metadata/PartialPathTest.java
@@ -19,6 +19,7 @@
 package org.apache.iotdb.db.metadata;
 
 import java.util.Arrays;
+import java.util.List;
 import org.apache.iotdb.db.exception.metadata.IllegalPathException;
 import org.apache.iotdb.db.utils.EnvironmentUtils;
 import org.junit.After;
@@ -48,14 +49,14 @@ public class PartialPathTest {
     arr2[1] = "s1";
     PartialPath b = new PartialPath(arr2);
     Assert.assertEquals("[root, sg1, d1, s1]", 
Arrays.toString(a.concatPath(b).getNodes()));
+    Assert.assertEquals("s1", b.getTailNode());
+    Assert.assertEquals("root.sg1.d1", 
a.concatPath(b).getDevicePath().getFullPath());
+    Assert.assertEquals("root.sg1", a.toString());
   }
 
   @Test
-  public void testConcatArray() {
-    String[] arr1 = new String[2];
-    arr1[0] = "root";
-    arr1[1] = "sg1";
-    PartialPath a = new PartialPath(arr1);
+  public void testConcatArray() throws IllegalPathException {
+    PartialPath a = new PartialPath("root", "sg1");
     String[] arr2 = new String[2];
     arr2[0] = "d1";
     arr2[1] = "s1";
@@ -69,11 +70,11 @@ public class PartialPathTest {
     arr1[0] = "root";
     arr1[1] = "sg1";
     PartialPath a = new PartialPath(arr1);
-    String[] arr2 = new String[1];
-    arr2[0] = "d1";
-    a.concatPath(arr2);
-    Assert.assertEquals("[root, sg1, d1]", Arrays.toString(a.getNodes()));
-    Assert.assertEquals("root.sg1.d1", a.getFullPath());
+    PartialPath b =  a.concatNode("d1");
+    Assert.assertEquals("[root, sg1, d1]", Arrays.toString(b.getNodes()));
+    Assert.assertEquals("root.sg1.d1", b.getFullPath());
+    Assert.assertTrue(b.startsWith(arr1));
+    Assert.assertEquals("root", b.getFirstNode());
   }
 
   @Test
@@ -96,4 +97,17 @@ public class PartialPathTest {
     Assert.assertFalse(p1.matchFullPath(new PartialPath("")));
   }
 
+  @Test
+  public void testPartialPathAndStringList() {
+    List<PartialPath> paths = 
PartialPath.fromStringList(Arrays.asList("root.sg1.d1.s1", "root.sg1.d1.s2"));
+    Assert.assertEquals("root.sg1.d1.s1", paths.get(0).getFullPath());
+    Assert.assertEquals("root.sg1.d1.s2", paths.get(1).getFullPath());
+
+    List<String> stringPaths = PartialPath.toStringList(paths);
+    Assert.assertEquals("root.sg1.d1.s1", stringPaths.get(0));
+    Assert.assertEquals("root.sg1.d1.s2", stringPaths.get(1));
+  }
+
+
+
 }

Reply via email to