You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/10/15 16:00:23 UTC
[shardingsphere] branch master updated: Add unit tests to cover CuratorZookeeperRepository.getNumChildren method (#21537)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 57270d92a3b Add unit tests to cover CuratorZookeeperRepository.getNumChildren method (#21537)
57270d92a3b is described below
commit 57270d92a3b3e85395631f806b277c5e5a9c80e0
Author: Filiberto RamÃrez <zi...@gmail.com>
AuthorDate: Sat Oct 15 09:00:14 2022 -0700
Add unit tests to cover CuratorZookeeperRepository.getNumChildren method (#21537)
Co-authored-by: iofit <fi...@gmail.com>
---
.../zookeeper/CuratorZookeeperRepositoryTest.java | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/mode/type/cluster/repository/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java b/mode/type/cluster/repository/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java
index 8cb76cef7fd..df9aef21fc9 100644
--- a/mode/type/cluster/repository/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java
+++ b/mode/type/cluster/repository/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/mode/repository/cluster/zookeeper/CuratorZookeeperRepositoryTest.java
@@ -304,4 +304,20 @@ public final class CuratorZookeeperRepositoryTest {
REPOSITORY.delete("/test/children/1");
verify(backgroundVersionable).forPath("/test/children/1");
}
+
+ @Test
+ public void assertGetNumChildrenGtZero() throws Exception {
+ Stat stat = new Stat(1L, 2L, 3L, 4L, 5, 6, 7, 8L, 9, 10, 11L);
+ when(existsBuilder.forPath("/test/children")).thenReturn(stat);
+ int children = REPOSITORY.getNumChildren("/test/children");
+ assertThat(children, is(10));
+ }
+
+ @Test
+ public void assertGetNumChildrenEqZero() throws Exception {
+ Stat stat = new Stat();
+ when(existsBuilder.forPath("/test/children")).thenReturn(stat);
+ int children = REPOSITORY.getNumChildren("/test/children");
+ assertThat(children, is(0));
+ }
}