Repository: curator
Updated Branches:
  refs/heads/CURATOR-397 5ebcfa32d -> 52b334c30


Added some tests/fixes


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/22fdb298
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/22fdb298
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/22fdb298

Branch: refs/heads/CURATOR-397
Commit: 22fdb298db42a10ab74902b623e1696d22c2021f
Parents: 5ebcfa3
Author: randgalt <randg...@apache.org>
Authored: Wed Apr 26 16:10:59 2017 -0500
Committer: randgalt <randg...@apache.org>
Committed: Wed Apr 26 16:10:59 2017 -0500

----------------------------------------------------------------------
 .../curator/x/async/modeled/details/ZPathImpl.java    |  7 ++++---
 .../org/apache/curator/x/async/modeled/TestZPath.java | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/22fdb298/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
----------------------------------------------------------------------
diff --git 
a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
 
b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
index a4685af..be03963 100644
--- 
a/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
+++ 
b/curator-x-async/src/main/java/org/apache/curator/x/async/modeled/details/ZPathImpl.java
@@ -130,16 +130,17 @@ public class ZPathImpl implements ZPath
     public ZPath resolved(Object... parameters)
     {
         List<String> nodeNames = Lists.newArrayList();
+        int parameterIndex = 0;
         for ( int i = 0; i < nodes.size(); ++i )
         {
             String name = nodes.get(i);
             if ( name.equals(parameter) )
             {
-                if ( parameters.length >= i )
+                if ( parameterIndex >= parameters.length )
                 {
-                    throw new IllegalStateException(String.format("Parameter 
missing at index [%d] for [%s]", i, nodes.toString()));
+                    throw new IllegalStateException(String.format("Parameter 
missing at index [%d] for [%s]", parameterIndex, nodes.toString()));
                 }
-                nodeNames.add(parameters[i].toString());
+                nodeNames.add(parameters[parameterIndex++].toString());
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/curator/blob/22fdb298/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
----------------------------------------------------------------------
diff --git 
a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
 
b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
index c6049f2..2ca38ca 100644
--- 
a/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
+++ 
b/curator-x-async/src/test/java/org/apache/curator/x/async/modeled/TestZPath.java
@@ -54,4 +54,18 @@ public class TestZPath
         Assert.assertEquals(ZPath.parse("/one/two/three"), 
ZPath.root().at("one").at("two").at("three"));
         Assert.assertEquals(ZPath.parse("/one/two/three"), ZPath.from("one", 
"two", "three"));
     }
+
+    @Test(expectedExceptions = IllegalStateException.class)
+    public void testUnresolvedPath()
+    {
+        ZPath path = ZPath.from("one", ZPath.parameterNodeName(), "two");
+        path.fullPath();
+    }
+
+    @Test
+    public void testResolvedPath()
+    {
+        ZPath path = ZPath.from("one", ZPath.parameterNodeName(), "two", 
ZPath.parameterNodeName());
+        Assert.assertEquals(path.resolved("a", "b"), ZPath.from("one", "a", 
"two", "b"));
+    }
 }

Reply via email to