Search in sources :

Example 16 with RemoteValue

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());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Example 17 with RemoteValue

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());
}
Also used : 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 18 with RemoteValue

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());
}
Also used : 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 19 with RemoteValue

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());
}
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 20 with RemoteValue

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());
}
Also used : Blob(org.apache.jackrabbit.oak.api.Blob) 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

RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)52 Test (org.junit.Test)52 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)28 Tree (org.apache.jackrabbit.oak.api.Tree)28 RemoteTree (org.apache.jackrabbit.oak.remote.RemoteTree)28 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)24 ResultRow (org.apache.jackrabbit.oak.api.ResultRow)24 Blob (org.apache.jackrabbit.oak.api.Blob)6 RemoteTreeFilters (org.apache.jackrabbit.oak.remote.RemoteTreeFilters)4 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)2 InputStream (java.io.InputStream)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 Set (java.util.Set)2 BigDecimal (java.math.BigDecimal)1