use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetBinaryProperty.
@Test
public void testGetBinaryProperty() {
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.BINARY).when(property).getType();
doReturn(blob).when(property).getValue(Type.BINARY);
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").isBinary());
assertEquals(stream, properties.get("name").asBinary().get());
}
use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetChildrenWithNegativeCount.
@Test
public void testGetChildrenWithNegativeCount() {
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"));
assertTrue(children.containsKey("bar"));
}
use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetChildrenWithCountTooBig.
@Test
public void testGetChildrenWithCountTooBig() {
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 3;
}
});
Map<String, RemoteTree> children = remoteTree.getChildren();
assertTrue(children.containsKey("foo"));
assertTrue(children.containsKey("bar"));
}
use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testFilterPropertyIn.
@Test
public void testFilterPropertyIn() {
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("foo");
}
});
Map<String, RemoteValue> properties = remoteTree.getProperties();
assertTrue(properties.containsKey("foo"));
assertFalse(properties.containsKey("bar"));
}
use of org.apache.jackrabbit.oak.remote.RemoteTree in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetChildrenWithZeroCount.
@Test
public void testGetChildrenWithZeroCount() {
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 0;
}
});
Map<String, RemoteTree> children = remoteTree.getChildren();
assertFalse(children.containsKey("foo"));
assertFalse(children.containsKey("bar"));
}
Aggregations