Search in sources :

Example 36 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testBinaryColumn.

@Test
public void testBinaryColumn() {
    Blob blob = mock(Blob.class);
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.BINARY).when(value).getType();
    doReturn(blob).when(value).getValue(Type.BINARY);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteBinaries binaries = mock(ContentRemoteBinaries.class);
    doReturn("id").when(binaries).put(blob);
    ContentRemoteResult result = createResult(binaries, row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("id", remoteValue.asBinaryId());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) Blob(org.apache.jackrabbit.oak.api.Blob) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Example 37 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testMultiUriColumn.

@Test
public void testMultiUriColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.URIS).when(value).getType();
    doReturn(asList("a", "b")).when(value).getValue(Type.URIS);
    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.asMultiUri());
}
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 38 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue 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);
}
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 39 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue 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());
}
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 40 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testMultiBinaryColumn.

@Test
public void testMultiBinaryColumn() {
    Blob first = mock(Blob.class);
    Blob second = mock(Blob.class);
    ContentRemoteBinaries binaries = mock(ContentRemoteBinaries.class);
    doReturn("first").when(binaries).put(first);
    doReturn("second").when(binaries).put(second);
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.BINARIES).when(value).getType();
    doReturn(asList(first, second)).when(value).getValue(Type.BINARIES);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(binaries, row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList("first", "second"), remoteValue.asMultiBinaryId());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) Blob(org.apache.jackrabbit.oak.api.Blob) 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