Search in sources :

Example 31 with RemoteValue

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

the class ContentRemoteTreeTest method testGetBooleanProperty.

@Test
public void testGetBooleanProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.BOOLEAN).when(property).getType();
    doReturn(true).when(property).getValue(Type.BOOLEAN);
    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").isBoolean());
    assertEquals(true, properties.get("name").asBoolean());
}
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 32 with RemoteValue

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

the class ContentRemoteTreeTest method testGetMultiDecimalProperty.

@Test
public void testGetMultiDecimalProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.DECIMALS).when(property).getType();
    doReturn(singletonList(BigDecimal.ONE)).when(property).getValue(Type.DECIMALS);
    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").isMultiDecimal());
    assertEquals(BigDecimal.ONE, getOnlyElement(properties.get("name").asMultiDecimal()));
}
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 33 with RemoteValue

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

the class ContentRemoteTreeTest method testNameProperty.

@Test
public void testNameProperty() {
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.NAME).when(property).getType();
    doReturn("value").when(property).getValue(Type.NAME);
    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").isName());
    assertEquals("value", properties.get("name").asName());
}
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 34 with RemoteValue

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

the class ContentRemoteTreeTest method testGetDateProperty.

@Test
public void testGetDateProperty() {
    Calendar calendar = Calendar.getInstance();
    PropertyState property = mock(PropertyState.class);
    doReturn("name").when(property).getName();
    doReturn(Type.DATE).when(property).getType();
    doReturn(ISO8601.format(calendar)).when(property).getValue(Type.DATE);
    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").isDate());
    assertEquals(calendar.getTimeInMillis(), properties.get("name").asDate().longValue());
}
Also used : Calendar(java.util.Calendar) 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 35 with RemoteValue

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

the class ContentRemoteTreeTest method testUriProperty.

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