Search in sources :

Example 1 with PropertyValue

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

the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintAndOrdering.

public void testCreateQueryFromSourceWithConstraintAndOrdering() throws RepositoryException {
    Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
    PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
    PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    Ordering ordering = qf.ascending(propValue);
    QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, null);
    assertTrue("Not a selector source", qom.getSource() instanceof Selector);
    assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
    assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
    assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
Also used : Ordering(javax.jcr.query.qom.Ordering) PropertyValue(javax.jcr.query.qom.PropertyValue) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) PropertyExistence(javax.jcr.query.qom.PropertyExistence) Source(javax.jcr.query.qom.Source) Selector(javax.jcr.query.qom.Selector)

Example 2 with PropertyValue

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

the class QueryObjectModelFactoryTest method testPropertyValue.

/**
     * Test case for {@link QueryObjectModelFactory#propertyValue(String, String)}
     */
public void testPropertyValue() throws RepositoryException {
    PropertyValue propVal = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    assertEquals("Wrong selector name", SELECTOR_NAME1, propVal.getSelectorName());
    assertEquals("Wrong property name", propertyName1, propVal.getPropertyName());
}
Also used : PropertyValue(javax.jcr.query.qom.PropertyValue)

Example 3 with PropertyValue

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

the class QueryObjectModelFactoryTest method testComparison.

/**
     * Test case for {@link QueryObjectModelFactory#comparison(DynamicOperand, String, StaticOperand)}
     */
public void testComparison() throws RepositoryException {
    PropertyValue op1 = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    BindVariableValue op2 = qf.bindVariable(VARIABLE_NAME);
    for (Iterator<String> it = OPERATORS.iterator(); it.hasNext(); ) {
        String operator = it.next();
        Comparison comp = qf.comparison(op1, operator, op2);
        assertTrue("Not a PropertyValue operand", comp.getOperand1() instanceof PropertyValue);
        assertTrue("Not a BindVariableValue operand", comp.getOperand2() instanceof BindVariableValue);
        assertEquals("Wrong operator", operator, comp.getOperator());
    }
}
Also used : BindVariableValue(javax.jcr.query.qom.BindVariableValue) Comparison(javax.jcr.query.qom.Comparison) PropertyValue(javax.jcr.query.qom.PropertyValue)

Example 4 with PropertyValue

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

the class QueryObjectModelFactoryTest method testOrderingDescending.

/**
     * Test case for {@link QueryObjectModelFactory#descending(DynamicOperand)}
     */
public void testOrderingDescending() throws RepositoryException {
    PropertyValue op = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    Ordering desc = qf.descending(op);
    assertEquals("Ordering.getOrder() must return QueryObjectModelConstants.ORDER_DESCENDING", QueryObjectModelConstants.JCR_ORDER_DESCENDING, desc.getOrder());
    assertTrue("Not a PropertyValue operand", desc.getOperand() instanceof PropertyValue);
}
Also used : Ordering(javax.jcr.query.qom.Ordering) PropertyValue(javax.jcr.query.qom.PropertyValue)

Example 5 with PropertyValue

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

the class QueryObjectModelFactoryTest method testUpperCase.

/**
     * Test case for {@link QueryObjectModelFactory#upperCase(DynamicOperand)}
     */
public void testUpperCase() throws RepositoryException {
    PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    UpperCase upper = qf.upperCase(propValue);
    assertTrue("Not a property value operand", upper.getOperand() instanceof PropertyValue);
}
Also used : UpperCase(javax.jcr.query.qom.UpperCase) PropertyValue(javax.jcr.query.qom.PropertyValue)

Aggregations

PropertyValue (javax.jcr.query.qom.PropertyValue)26 Ordering (javax.jcr.query.qom.Ordering)9 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)8 Test (org.junit.Test)8 Length (javax.jcr.query.qom.Length)5 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)5 Selector (javax.jcr.query.qom.Selector)5 BindVariableValue (javax.jcr.query.qom.BindVariableValue)4 Constraint (javax.jcr.query.qom.Constraint)4 PropertyExistence (javax.jcr.query.qom.PropertyExistence)4 NodeType (javax.jcr.nodetype.NodeType)3 Column (javax.jcr.query.qom.Column)3 LowerCase (javax.jcr.query.qom.LowerCase)3 UpperCase (javax.jcr.query.qom.UpperCase)3 RepositoryException (javax.jcr.RepositoryException)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)2 Value (javax.jcr.Value)2 Comparison (javax.jcr.query.qom.Comparison)2 NodeLocalName (javax.jcr.query.qom.NodeLocalName)2 NodeName (javax.jcr.query.qom.NodeName)2