use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class PropertyIndexQueryTest method bindVariableTest.
@Test
public void bindVariableTest() throws Exception {
Tree tree = root.getTree("/");
Tree test = tree.addChild("test");
test.addChild("hello").setProperty("id", "1");
test.addChild("world").setProperty("id", "2");
root.commit();
Map<String, PropertyValue> sv = new HashMap<String, PropertyValue>();
sv.put("id", PropertyValues.newString("1"));
Iterator<? extends ResultRow> result;
result = executeQuery("select * from [nt:base] where id = $id", SQL2, sv).getRows().iterator();
assertTrue(result.hasNext());
assertEquals("/test/hello", result.next().getPath());
sv.put("id", PropertyValues.newString("2"));
result = executeQuery("select * from [nt:base] where id = $id", SQL2, sv).getRows().iterator();
assertTrue(result.hasNext());
assertEquals("/test/world", result.next().getPath());
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testReferenceColumn.
@Test
public void testReferenceColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.REFERENCE).when(value).getType();
doReturn("value").when(value).getValue(Type.REFERENCE);
ResultRow row = mock(ResultRow.class);
doReturn(value).when(row).getValue("column");
ContentRemoteResult result = createResult(row);
RemoteValue remoteValue = result.getColumnValue("column");
assertEquals("value", remoteValue.asReference());
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testMultiStringColumn.
@Test
public void testMultiStringColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.STRINGS).when(value).getType();
doReturn(asList("a", "b")).when(value).getValue(Type.STRINGS);
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.asMultiText());
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testMultiBooleanColumn.
@Test
public void testMultiBooleanColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.BOOLEANS).when(value).getType();
doReturn(asList(true, false)).when(value).getValue(Type.BOOLEANS);
ResultRow row = mock(ResultRow.class);
doReturn(value).when(row).getValue("column");
ContentRemoteResult result = createResult(row);
RemoteValue remoteValue = result.getColumnValue("column");
assertEquals(asList(true, false), remoteValue.asMultiBoolean());
}
use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.
the class ContentRemoteResultTest method testMultiNameColumn.
@Test
public void testMultiNameColumn() {
PropertyValue value = mock(PropertyValue.class);
doReturn(Type.NAMES).when(value).getType();
doReturn(asList("a", "b")).when(value).getValue(Type.NAMES);
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.asMultiName());
}
Aggregations