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"));
}
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"));
}
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());
}
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"));
}
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"));
}
Aggregations