Search in sources :

Example 41 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiWeakReferenceProperty.

@Test
public void testGetMultiWeakReferenceProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.WEAKREFERENCES).when(property).getType();
    doReturn(singletonList("value")).when(property).getValue(Type.WEAKREFERENCES);
    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").isMultiWeakReference());
    assertEquals("value", getOnlyElement(properties.get("name").asMultiWeakReference()));
}
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 42 with RemoteValue

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

the class ContentRemoteResultTest method testMultiDateColumn.

@Test
public void testMultiDateColumn() {
    Date first = new Date(4);
    Date second = new Date(2);
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.DATES).when(value).getType();
    doReturn(toFormattedDates(first, second)).when(value).getValue(Type.DATES);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList(4L, 2L), remoteValue.asMultiDate());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Date(java.util.Date) Test(org.junit.Test)

Example 43 with RemoteValue

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

the class ContentRemoteResultTest method testBinaryColumn.

@Test
public void testBinaryColumn() {
    Blob blob = mock(Blob.class);
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.BINARY).when(value).getType();
    doReturn(blob).when(value).getValue(Type.BINARY);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteBinaries binaries = mock(ContentRemoteBinaries.class);
    doReturn("id").when(binaries).put(blob);
    ContentRemoteResult result = createResult(binaries, row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("id", remoteValue.asBinaryId());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) Blob(org.apache.jackrabbit.oak.api.Blob) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Example 44 with RemoteValue

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

the class ContentRemoteResultTest method testMultiUriColumn.

@Test
public void testMultiUriColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.URIS).when(value).getType();
    doReturn(asList("a", "b")).when(value).getValue(Type.URIS);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList("a", "b"), remoteValue.asMultiUri());
}
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 45 with RemoteValue

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

the class ContentRemoteTreeTest method testPathProperty.

@Test
public void testPathProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.PATH).when(property).getType();
    doReturn("value").when(property).getValue(Type.PATH);
    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").isPath());
    assertEquals("value", properties.get("name").asPath());
}
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)

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