private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
private PropertyExistence getPropertyExistence(PropertyValue p) throws InvalidQueryException, RepositoryException { return factory.propertyExistence(p.getSelectorName(), p.getPropertyName()); }
/** * Test case for {@link QueryObjectModelFactory#and(Constraint, Constraint)} */ public void testAnd() throws RepositoryException { PropertyExistence c1 = qf.propertyExistence(SELECTOR_NAME1, propertyName1); PropertyExistence c2 = qf.propertyExistence(SELECTOR_NAME1, propertyName2); And and = qf.and(c1, c2); assertTrue("Not a PropertyExistence constraint", and.getConstraint1() instanceof PropertyExistence); assertTrue("Not a PropertyExistence constraint", and.getConstraint2() instanceof PropertyExistence); }
/** * Test case for {@link QueryObjectModelFactory#or(Constraint, Constraint)} */ public void testOr() throws RepositoryException { PropertyExistence c1 = qf.propertyExistence(SELECTOR_NAME1, propertyName1); PropertyExistence c2 = qf.propertyExistence(SELECTOR_NAME1, propertyName2); Or or = qf.or(c1, c2); assertTrue("Not a PropertyExistence constraint", or.getConstraint1() instanceof PropertyExistence); assertTrue("Not a PropertyExistence constraint", or.getConstraint2() instanceof PropertyExistence); }
/** * Test case for {@link QueryObjectModelFactory#not(Constraint)} */ public void testNot() throws RepositoryException { PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1); Not not = qf.not(propExist); assertTrue("Not a property existence constraint", not.getConstraint() instanceof PropertyExistence); }
public void testNot() throws RepositoryException { Node n1 = testRootNode.addNode(nodeName1, testNodeType); n1.setProperty(propertyName1, "foo"); Node n2 = testRootNode.addNode(nodeName2, testNodeType); n2.setProperty(propertyName2, "bar"); superuser.save(); QueryObjectModel qom = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.descendantNode("s", testRootNode.getPath()), qf.not( qf.propertyExistence("s", propertyName1) ) ), null, null ); checkQOM(qom, new Node[]{n2}); } }
/** * Test case for {@link QueryObjectModelFactory#propertyExistence(String, String)} */ public void testPropertyExistence() throws RepositoryException { PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1); assertEquals("Wrong selector", SELECTOR_NAME1, propExist.getSelectorName()); assertEquals("Wrong property name", propertyName1, propExist.getPropertyName()); }
@Test public void not() throws RepositoryException { Constraint c = f.propertyExistence("x", "c0"); Not n = f.not(c); assertEquals(c, n.getConstraint()); assertEquals("[x].[c0] IS NOT NULL", c.toString()); assertEquals("* IS NOT NULL", f.propertyExistence(null, null).toString()); assertEquals("[s].* IS NOT NULL", f.propertyExistence("s", null).toString()); assertEquals("[p] IS NOT NULL", f.propertyExistence(null, "p").toString()); assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString()); }
/** * Test case for {@link QueryObjectModelFactory#propertyExistence(String, String)} */ public void testPropertyExistenceWithSelector() throws RepositoryException { PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1); assertEquals("Wrong selector name", SELECTOR_NAME1, propExist.getSelectorName()); assertEquals("Wrong property name", propertyName1, propExist.getPropertyName()); }
@Test public void propertyExistence() throws RepositoryException { PropertyExistence pe = f.propertyExistence("selectorName", "propertyName"); assertEquals("selectorName", pe.getSelectorName()); assertEquals("propertyName", pe.getPropertyName()); assertEquals("[selectorName].[propertyName] IS NOT NULL", pe.toString()); assertEquals("* IS NOT NULL", f.propertyExistence(null, null).toString()); assertEquals("[s].* IS NOT NULL", f.propertyExistence("s", null).toString()); assertEquals("[p] IS NOT NULL", f.propertyExistence(null, "p").toString()); assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString()); }
@Test public void and() throws RepositoryException { Constraint c0 = f.propertyExistence("x", "c0"); Constraint c1 = f.propertyExistence("x", "c1"); And and = f.and(c0, c1); assertEquals(and.getConstraint1(), c0); assertEquals(and.getConstraint2(), c1); assertEquals("([x].[c0] IS NOT NULL) AND ([x].[c1] IS NOT NULL)", and.toString()); }
@Test public void or() throws RepositoryException { Constraint c0 = f.propertyExistence("x", "c0"); Constraint c1 = f.propertyExistence("x", "c1"); Or or = f.or(c0, c1); assertEquals(or.getConstraint1(), c0); assertEquals(or.getConstraint2(), c1); assertEquals("([x].[c0] IS NOT NULL) OR ([x].[c1] IS NOT NULL)", or.toString()); }
public void testCreateQueryWithConstraint() throws RepositoryException { Selector selector = qf.selector(testNodeType, SELECTOR_NAME1); PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1); QueryObjectModel qom = qf.createQuery( selector, propExist, null, 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", 0, qom.getOrderings().length); assertEquals("Wrong size of columns", 0, qom.getColumns().length); }
public void testCreateQueryFromSourceWithConstraint() throws RepositoryException { Source selector = qf.selector(testNodeType, SELECTOR_NAME1); PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1); QueryObjectModel qom = qf.createQuery( selector, propExist, null, 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", 0, qom.getOrderings().length); assertEquals("Wrong size of columns", 0, qom.getColumns().length); }
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); }
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); }
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); }
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); }
@Test public void createQuery() throws RepositoryException { Selector s = f.selector("nt:file", "x"); BindVariableValue b = f.bindVariable("var"); Constraint c = f.propertyExistence("x", "c"); PropertyValue p = f.propertyValue("x", "propertyName"); c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c); Ordering o = f.ascending(p); Column col = f.column("x", "propertyName", "columnName"); Ordering[] ords = new Ordering[]{o}; Column[] cols = new Column[]{col}; QueryObjectModel q = f.createQuery(s, c, ords, cols); assertEquals(Query.JCR_JQOM, q.getLanguage()); String[] bv = q.getBindVariableNames(); assertEquals(1, bv.length); assertEquals("var", bv[0]); assertEquals(s, q.getSource()); assertEquals(c, q.getConstraint()); assertEquals(o, q.getOrderings()[0]); assertEquals(col, q.getColumns()[0]); }