Search in sources :

Example 21 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiReferenceProperty.

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

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

the class ContentRemoteTreeTest method testGetMultiDoubleProperty.

@Test
public void testGetMultiDoubleProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.DOUBLES).when(property).getType();
    doReturn(singletonList(4.2)).when(property).getValue(Type.DOUBLES);
    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").isMultiDouble());
    assertEquals(4.2, getOnlyElement(properties.get("name").asMultiDouble()), 1e-9);
}
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 23 with RemoteValue

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

the class ContentRemoteTreeTest method testFilterPropertyOut.

@Test
public void testFilterPropertyOut() {
    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("-bar");
        }
    });
    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 24 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiLongProperty.

@Test
public void testGetMultiLongProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.LONGS).when(property).getType();
    doReturn(singletonList(42L)).when(property).getValue(Type.LONGS);
    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").isMultiLong());
    assertEquals(42L, getOnlyElement(properties.get("name").asMultiLong()).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 25 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiUriProperty.

@Test
public void testGetMultiUriProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.URIS).when(property).getType();
    doReturn(singletonList("value")).when(property).getValue(Type.URIS);
    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").isMultiUri());
    assertEquals("value", getOnlyElement(properties.get("name").asMultiUri()));
}
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