Search in sources :

Example 16 with PropertyValue

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

the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintOrderingAndColumn.

public void testCreateQueryFromSourceWithConstraintOrderingAndColumn() 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);
    Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
    QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
    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", 1, qom.getColumns().length);
}
Also used : Column(javax.jcr.query.qom.Column) 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 17 with PropertyValue

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

the class QueryObjectModelFactoryTest method testLowerCase.

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

Example 18 with PropertyValue

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

the class QueryObjectModelFactoryTest method testPropertyValueWithSelector.

/**
     * Test case for {@link QueryObjectModelFactory#propertyValue(String, String)}
     */
public void testPropertyValueWithSelector() 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 19 with PropertyValue

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

the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintAndOrdering.

public void testCreateQueryWithConstraintAndOrdering() throws RepositoryException {
    Selector 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) Selector(javax.jcr.query.qom.Selector)

Example 20 with PropertyValue

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

the class QueryObjectModelFactoryTest method testCreateQueryWithConstraintOrderingAndColumn.

public void testCreateQueryWithConstraintOrderingAndColumn() throws RepositoryException {
    Selector 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);
    Column column = qf.column(SELECTOR_NAME1, propertyName1, propertyName1);
    QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, new Column[] { column });
    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", 1, qom.getColumns().length);
}
Also used : Column(javax.jcr.query.qom.Column) Ordering(javax.jcr.query.qom.Ordering) PropertyValue(javax.jcr.query.qom.PropertyValue) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) PropertyExistence(javax.jcr.query.qom.PropertyExistence) Selector(javax.jcr.query.qom.Selector)

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