Search in sources :

Example 16 with PropertyValue

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());
}
Also used : HashMap(java.util.HashMap) Tree(org.apache.jackrabbit.oak.api.Tree) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) Test(org.junit.Test) AbstractQueryTest(org.apache.jackrabbit.oak.query.AbstractQueryTest)

Example 17 with PropertyValue

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());
}
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 18 with PropertyValue

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());
}
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 19 with PropertyValue

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());
}
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 20 with PropertyValue

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());
}
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)

Aggregations

PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)57 Test (org.junit.Test)28 ResultRow (org.apache.jackrabbit.oak.api.ResultRow)26 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)24 Tree (org.apache.jackrabbit.oak.api.Tree)5 ParseException (java.text.ParseException)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 ArrayList (java.util.ArrayList)3 Result (org.apache.jackrabbit.oak.api.Result)3 Date (java.util.Date)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 LiteralImpl (org.apache.jackrabbit.oak.query.ast.LiteralImpl)2 StaticOperandImpl (org.apache.jackrabbit.oak.query.ast.StaticOperandImpl)2 FulltextQueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 InvalidQueryException (javax.jcr.query.InvalidQueryException)1