Search in sources :

Example 6 with Literal

use of javax.jcr.query.qom.Literal in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testFullTextSearch.

/**
     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)}
     */
public void testFullTextSearch() throws RepositoryException {
    FullTextSearch ftSearch = qf.fullTextSearch(SELECTOR_NAME1, propertyName1, qf.literal(vf.createValue(FULLTEXT_SEARCH_EXPR)));
    assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName());
    assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName());
    StaticOperand op = ftSearch.getFullTextSearchExpression();
    assertNotNull(op);
    assertTrue("not a Literal", op instanceof Literal);
    Literal literal = (Literal) op;
    assertEquals(FULLTEXT_SEARCH_EXPR, literal.getLiteralValue().getString());
}
Also used : StaticOperand(javax.jcr.query.qom.StaticOperand) Literal(javax.jcr.query.qom.Literal) FullTextSearch(javax.jcr.query.qom.FullTextSearch)

Example 7 with Literal

use of javax.jcr.query.qom.Literal in project jackrabbit-oak by apache.

the class QomTest method comparison.

@Test
public void comparison() throws RepositoryException {
    PropertyValue p = f.propertyValue("selectorName", "propertyName");
    Literal l = f.literal(vf.createValue(1));
    Comparison c = f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, l);
    assertEquals(p, c.getOperand1());
    assertEquals(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, c.getOperator());
    assertEquals(l, c.getOperand2());
    assertEquals("[selectorName].[propertyName] = 1", c.toString());
}
Also used : Comparison(javax.jcr.query.qom.Comparison) Literal(javax.jcr.query.qom.Literal) PropertyValue(javax.jcr.query.qom.PropertyValue) Test(org.junit.Test) AbstractRepositoryTest(org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)

Aggregations

Literal (javax.jcr.query.qom.Literal)7 PropertyValue (javax.jcr.query.qom.PropertyValue)5 Value (javax.jcr.Value)4 BindVariableValue (javax.jcr.query.qom.BindVariableValue)3 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)3 Test (org.junit.Test)3 FullTextSearch (javax.jcr.query.qom.FullTextSearch)2 StaticOperand (javax.jcr.query.qom.StaticOperand)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Row (javax.jcr.query.Row)1 Comparison (javax.jcr.query.qom.Comparison)1 Constraint (javax.jcr.query.qom.Constraint)1