Search in sources :

Example 1 with RemoteTree

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

the class ContentRemoteTreeTest method testGetChildren.

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

        @Override
        public int getDepth() {
            return 1;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertTrue(children.containsKey("child"));
    assertNotNull(children.get("child"));
}
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 2 with RemoteTree

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

the class ContentRemoteTreeTest method testGetChildrenWithStartTooBig.

@Test
public void testGetChildrenWithStartTooBig() {
    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 getChildrenStart() {
            return 2;
        }
    });
    Map<String, RemoteTree> children = remoteTree.getChildren();
    assertFalse(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 3 with RemoteTree

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

the class ContentRemoteTreeTest method testGetMultiBinaryProperty.

@Test
public void testGetMultiBinaryProperty() {
    InputStream stream = mock(InputStream.class);
    Blob blob = mock(Blob.class);
    doReturn(stream).when(blob).getNewStream();
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.BINARIES).when(property).getType();
    doReturn(singletonList(blob)).when(property).getValue(Type.BINARIES);
    Tree tree = mock(Tree.class);
    doReturn(singletonList(property)).when(tree).getProperties();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public long getBinaryThreshold() {
            return Long.MAX_VALUE;
        }
    });
    Map<String, RemoteValue> properties = remoteTree.getProperties();
    assertTrue(properties.containsKey("name"));
    assertTrue(properties.get("name").isMultiBinary());
    assertEquals(stream, getOnlyElement(properties.get("name").asMultiBinary()).get());
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) InputStream(java.io.InputStream) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) Test(org.junit.Test)

Example 4 with RemoteTree

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

the class ContentRemoteTreeTest method testGetChildrenWithIncludeFilters.

@Test
public void testGetChildrenWithIncludeFilters() {
    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("foo");
        }
    });
    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 5 with RemoteTree

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

the class ContentRemoteTreeTest method testFilterPropertyOut.

@Test
public void testFilterPropertyOut() {
    PropertyState fooProperty = mock(PropertyState.class);
    doReturn("foo").when(fooProperty).getName();
    doReturn(Type.BOOLEAN).when(fooProperty).getType();
    doReturn(true).when(fooProperty).getValue(Type.BOOLEAN);
    PropertyState barProperty = mock(PropertyState.class);
    doReturn("bar").when(barProperty).getName();
    doReturn(Type.BOOLEAN).when(barProperty).getType();
    doReturn(true).when(barProperty).getValue(Type.BOOLEAN);
    Tree tree = mock(Tree.class);
    doReturn(asList(fooProperty, barProperty)).when(tree).getProperties();
    ContentRemoteTree remoteTree = createTree(tree, new RemoteTreeFilters() {

        @Override
        public Set<String> getPropertyFilters() {
            return newHashSet("-bar");
        }
    });
    Map<String, RemoteValue> properties = remoteTree.getProperties();
    assertTrue(properties.containsKey("foo"));
    assertFalse(properties.containsKey("bar"));
}
Also used : Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Set(java.util.Set) RemoteTreeFilters(org.apache.jackrabbit.oak.remote.RemoteTreeFilters) Tree(org.apache.jackrabbit.oak.api.Tree) RemoteTree(org.apache.jackrabbit.oak.remote.RemoteTree) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) 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