use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testDoubleProperty.
@Test
public void testDoubleProperty() {
PropertyState property = mock(PropertyState.class);
doReturn("name").when(property).getName();
doReturn(Type.DOUBLE).when(property).getType();
doReturn(4.2).when(property).getValue(Type.DOUBLE);
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").isDouble());
assertEquals(4.2, properties.get("name").asDouble(), 1e-9);
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetMultiDateProperty.
@Test
public void testGetMultiDateProperty() {
Calendar calendar = Calendar.getInstance();
PropertyState property = mock(PropertyState.class);
doReturn("name").when(property).getName();
doReturn(Type.DATES).when(property).getType();
doReturn(singletonList(ISO8601.format(calendar))).when(property).getValue(Type.DATES);
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").isMultiDate());
assertEquals(calendar.getTimeInMillis(), getOnlyElement(properties.get("name").asMultiDate()).longValue());
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteTreeTest method testGetMultiNameProperty.
@Test
public void testGetMultiNameProperty() {
PropertyState property = mock(PropertyState.class);
doReturn("name").when(property).getName();
doReturn(Type.NAMES).when(property).getType();
doReturn(singletonList("value")).when(property).getValue(Type.NAMES);
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").isMultiName());
assertEquals("value", getOnlyElement(properties.get("name").asMultiName()));
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testDoubleColumn.
@Test
public void testDoubleColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.DOUBLE).when(value).getType();
doReturn(4.2).when(value).getValue(Type.DOUBLE);
ResultRow row = mock(ResultRow.class);
doReturn(value).when(row).getValue("column");
ContentRemoteResult result = createResult(row);
RemoteValue remoteValue = result.getColumnValue("column");
assertEquals(4.2, remoteValue.asDouble().doubleValue(), 1e-5);
}
use of org.apache.jackrabbit.oak.remote.RemoteValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testDecimalColumn.
@Test
public void testDecimalColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.DECIMAL).when(value).getType();
doReturn(BigDecimal.ONE).when(value).getValue(Type.DECIMAL);
ResultRow row = mock(ResultRow.class);
doReturn(value).when(row).getValue("column");
ContentRemoteResult result = createResult(row);
RemoteValue remoteValue = result.getColumnValue("column");
assertEquals(BigDecimal.ONE, remoteValue.asDecimal());
}
Aggregations