Skip to content

Commit

Permalink
monkey patch
Browse files Browse the repository at this point in the history
Signed-off-by: tison <wander4096@gmail.com>
  • Loading branch information
tisonkun committed Feb 14, 2024
1 parent ed12072 commit c44e798
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void testWithNamespace() throws Exception {
assertNull(client.checkExists().forPath("/foo/bar"));

CuratorTransactionResult ephemeralResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/test-"));
assertNotNull(ephemeralResult);
assertNotEquals(ephemeralResult.getResultPath(), "/test-");
assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
Expand All @@ -148,9 +148,9 @@ public void testBasic() throws Exception {
assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());

CuratorTransactionResult fooResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
assertNotNull(fooResult);
assertNotNull(fooBarResult);
assertNotSame(fooResult, fooBarResult);
Expand Down Expand Up @@ -179,9 +179,9 @@ public void testBackground() throws Exception {
assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());

CuratorTransactionResult fooResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
assertNotNull(fooResult);
assertNotNull(fooBarResult);
assertNotSame(fooResult, fooBarResult);
Expand Down Expand Up @@ -225,7 +225,7 @@ public void testBackgroundWithNamespace() throws Exception {
assertNull(client.checkExists().forPath("/foo/bar"));

CuratorTransactionResult ephemeralResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/test-"));
assertNotNull(ephemeralResult);
assertNotEquals(ephemeralResult.getResultPath(), "/test-");
assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testWithNamespace() throws Exception {
assertNull(client.checkExists().forPath("/foo/bar"));

CuratorTransactionResult ephemeralResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/test-"));
assertNotNull(ephemeralResult);
assertNotEquals(ephemeralResult.getResultPath(), "/test-");
assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
Expand Down Expand Up @@ -162,7 +162,7 @@ public void testWithCompression() throws Exception {
assertEquals(client.getACL().forPath("/bar"), ZooDefs.Ids.READ_ACL_UNSAFE);

CuratorTransactionResult ephemeralResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/test-"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/test-"));
assertNotNull(ephemeralResult);
assertNotEquals(ephemeralResult.getResultPath(), "/test-");
assertTrue(ephemeralResult.getResultPath().startsWith("/test-"));
Expand Down Expand Up @@ -193,9 +193,9 @@ public void testBasic() throws Exception {
assertArrayEquals(client.getData().forPath("/foo/bar"), "snafu".getBytes());

CuratorTransactionResult fooResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo"));
CuratorTransactionResult fooBarResult =
Iterables.find(results, CuratorTransactionResult.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
Iterables.find(results, TransactionsHelper.ofTypeAndPath(OperationType.CREATE, "/foo/bar"));
assertNotNull(fooResult);
assertNotNull(fooBarResult);
assertNotSame(fooResult, fooBarResult);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.curator.framework.imps;

import com.google.common.base.Predicate;
import org.apache.curator.framework.api.transaction.CuratorTransactionResult;
import org.apache.curator.framework.api.transaction.OperationType;

public class TransactionsHelper {
public static Predicate<CuratorTransactionResult> ofTypeAndPath(OperationType type, String forPath) {
return result -> (result.getType() == type) && result.getForPath().equals(forPath);
}
}
2 changes: 1 addition & 1 deletion curator-test-zk37/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
<dependency>org.apache.curator:curator-recipes</dependency>
<dependency>org.apache.curator:curator-client</dependency>
</dependenciesToScan>
<excludedGroups>zk35TestCompatibility,zk36,zk38OrLater</excludedGroups>
<excludedGroups>zk38OrLater</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down
1 change: 0 additions & 1 deletion curator-test-zk38/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@
<dependency>org.apache.curator:curator-recipes</dependency>
<dependency>org.apache.curator:curator-client</dependency>
</dependenciesToScan>
<excludedGroups>zk36,zk35TestCompatibility</excludedGroups>
</configuration>
</plugin>
</plugins>
Expand Down

0 comments on commit c44e798

Please sign in to comment.