Search in sources :

Example 36 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiTextProperty.

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

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

the class ContentRemoteTreeTest method testTextProperty.

@Test
public void testTextProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.STRING).when(property).getType();
    doReturn("value").when(property).getValue(Type.STRING);
    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").isText());
    assertEquals("value", properties.get("name").asText());
}
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 38 with RemoteValue

use of org.apache.jackrabbit.oak.remote.RemoteValue 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"));
}
Also used : Sets.newHashSet(com.google.common.collect.Sets.newHashSet) Set(java.util.Set) 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 39 with RemoteValue

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

the class ContentRemoteResultTest method testWeakReferenceColumn.

@Test
public void testWeakReferenceColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.WEAKREFERENCE).when(value).getType();
    doReturn("value").when(value).getValue(Type.WEAKREFERENCE);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("value", remoteValue.asWeakReference());
}
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 40 with RemoteValue

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

the class ContentRemoteTreeTest method testWeakReferenceProperty.

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