use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testNameColumn.
@Test
public void testNameColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.NAME).when(value).getType();
doReturn("value").when(value).getValue(Type.NAME);
ResultRow row = mock(ResultRow.class);
doReturn(value).when(row).getValue("column");
ContentRemoteResult result = createResult(row);
RemoteValue remoteValue = result.getColumnValue("column");
assertEquals("value", remoteValue.asName());
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testReferenceProperty.
@Test
public void testReferenceProperty() {
PropertyState property = mock(PropertyState.class);
doReturn("name").when(property).getName();
doReturn(Type.REFERENCE).when(property).getType();
doReturn("value").when(property).getValue(Type.REFERENCE);
Tree tree = mock(Tree.class);
doReturn(singletonList(property)).when(tree).getProperties();
Map<String, RemoteValue> properties = createTree(tree).getProperties();
assertTrue(properties.containsKey("name"));
assertTrue(properties.get("name").isReference());
assertEquals("value", properties.get("name").asReference());
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testLongProperty.
@Test
public void testLongProperty() {
PropertyState property = mock(PropertyState.class);
doReturn("name").when(property).getName();
doReturn(Type.LONG).when(property).getType();
doReturn(42L).when(property).getValue(Type.LONG);
Tree tree = mock(Tree.class);
doReturn(singletonList(property)).when(tree).getProperties();
Map<String, RemoteValue> properties = createTree(tree).getProperties();
assertTrue(properties.containsKey("name"));
assertTrue(properties.get("name").isLong());
assertEquals(42L, properties.get("name").asLong().longValue());
}
use of org.apache.jackrabbit.oak.remote.RemoteValue 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.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetBinaryIdProperty.
@Test
public void testGetBinaryIdProperty() {
Blob blob = mock(Blob.class);
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();
ContentRemoteBinaries binaries = mock(ContentRemoteBinaries.class);
doReturn("id").when(binaries).put(blob);
Map<String, RemoteValue> properties = createTree(tree, binaries).getProperties();
assertTrue(properties.containsKey("name"));
assertTrue(properties.get("name").isBinaryId());
assertEquals("id", properties.get("name").asBinaryId());
}
Aggregations