Search in sources :

Example 6 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithSlicing.

@Test
public void testGetChildrenWithSlicing() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree baz = mock(Tree.class);
    doReturn("baz").when(baz).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar, baz)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public int getChildrenStart() {
            return 1;
        }

        @Override
        public int getChildrenCount() {
            return 1;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertFalse(children.containsKey("foo"));
    assertTrue(children.containsKey("bar"));
    assertFalse(children.containsKey("baz"));
}
Also used : RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 7 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithExcludeFilters.

@Test
public void testGetChildrenWithExcludeFilters() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public Set<String> getNodeFilters() {
            return newHashSet("-bar");
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertTrue(children.containsKey("foo"));
    assertFalse(children.containsKey("bar"));
}
Also used : Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Set(java.util.Set) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 8 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithCount.

@Test
public void testGetChildrenWithCount() {
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(foo, bar)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public int getChildrenCount() {
            return 1;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertTrue(children.containsKey("foo"));
    assertFalse(children.containsKey("bar"));
}
Also used : RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 9 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenMaxDepth.

@Test
public void testGetChildrenMaxDepth() {
    Tree child = mock(Tree.class);
    doReturn("child").when(child).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(child)).when(tree).getChildren();
    Map<String, RemoteTree> children = createTree(tree).getChildren();
    assertTrue(children.containsKey("child"));
    assertNull(children.get("child"));
}
Also used : RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Example 10 with RemoteTree

use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.

the class ContentRemoteTreeTest method testGetChildrenWithSlicingAndFiltering.

@Test
public void testGetChildrenWithSlicingAndFiltering() {
    Tree bar = mock(Tree.class);
    doReturn("bar").when(bar).getName();
    Tree foo = mock(Tree.class);
    doReturn("foo").when(foo).getName();
    Tree baz = mock(Tree.class);
    doReturn("baz").when(baz).getName();
    Tree tree = mock(Tree.class);
    doReturn(asList(bar, foo, baz)).when(tree).getChildren();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public Set<String> getNodeFilters() {
            return Sets.newHashSet("ba*");
        }

        @Override
        public int getChildrenStart() {
            return 1;
        }

        @Override
        public int getChildrenCount() {
            return 1;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertFalse(children.containsKey("bar"));
    assertFalse(children.containsKey("foo"));
    assertFalse(children.containsKey("baz"));
}
Also used : Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Set(java.util.Set) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) Test(org.junit.Test)

Aggregations

RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)19 Tree (org.apache.jackrabbit.oak.api.Tree)17 RemoteTreeFilters (org.apache.jackrabbit.oak.remote.RemoteTreeFilters)17 Test (org.junit.Test)17 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)5 Set (java.util.Set)5 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)4 InputStream (java.io.InputStream)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 RemoteRevision (org.apache.jackrabbit.oak.remote.RemoteRevision)2 RemoteSession (org.apache.jackrabbit.oak.remote.RemoteSession)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 ServletOutputStream (javax.servlet.ServletOutputStream)1