Package org.modeshape.jcr.query.model

Examples of org.modeshape.jcr.query.model.Constraint


    }

    @Test
    public void shouldParseConstraintFromStringWithParenthesesAndConjunctionAndDisjunctions() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b') OR (ISSAMENODE('/c/d') AND ISSAMENODE('/e/f'))"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Or.class)));
        Or or = (Or)constraint;
View Full Code Here


    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithAndExpressionWithNoParentheses() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') AND CONTAINS(p1,term1)"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(And.class)));
        And and = (And)constraint;
View Full Code Here

    }

    @Test
    public void shouldParseConstraintFromStringWithMultipleAndExpressions() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') AND CONTAINS(p1,term1) AND CONTAINS(p2,term2)"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(And.class)));
        And and = (And)constraint;
View Full Code Here

    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithOrExpressionWithNoParentheses() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') OR CONTAINS(p1,term1)"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(Or.class)));
        Or or = (Or)constraint;

        assertThat(or.left(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)or.left();
View Full Code Here

    // parseConstraint - NOT
    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithNotSameNodeExpression() {
        Constraint constraint = parser.parseConstraint(tokens("NOT(ISSAMENODE(tableA,'/a/b/c'))"), typeSystem, mock(Source.class));
        assertThat(constraint, is(instanceOf(Not.class)));
        Not not = (Not)constraint;
        assertThat(not.getConstraint(), is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)not.getConstraint();
        assertThat(same.selectorName(), is(selectorName("tableA")));
View Full Code Here

    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithIsContainsExpressionWithPropertyAndNoSelectorNameOnlyIfThereIsOneSelectorSource() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("CONTAINS(propertyA,'term1 term2 -term3')"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(FullTextSearch.class)));
        FullTextSearch search = (FullTextSearch)constraint;
        assertThat(search.selectorName(), is(selectorName("tableA")));
        assertThat(search.getPropertyName(), is("propertyA"));
        assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3"));
View Full Code Here

        assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3"));
    }

    @Test
    public void shouldParseConstraintFromStringWithIsContainsExpressionWithSelectorNameAndProperty() {
        Constraint constraint = parser.parseConstraint(tokens("CONTAINS(tableA.propertyA,'term1 term2 -term3')"),
                                                       typeSystem,
                                                       mock(Source.class));
        assertThat(constraint, is(instanceOf(FullTextSearch.class)));
        FullTextSearch search = (FullTextSearch)constraint;
        assertThat(search.selectorName(), is(selectorName("tableA")));
View Full Code Here

        assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3"));
    }

    @Test
    public void shouldParseConstraintFromStringWithIsContainsExpressionWithSelectorNameAndAnyProperty() {
        Constraint constraint = parser.parseConstraint(tokens("CONTAINS(tableA.*,'term1 term2 -term3')"),
                                                       typeSystem,
                                                       mock(Source.class));
        assertThat(constraint, is(instanceOf(FullTextSearch.class)));
        FullTextSearch search = (FullTextSearch)constraint;
        assertThat(search.selectorName(), is(selectorName("tableA")));
View Full Code Here

    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithIsSameNodeExpressionWithPathOnlyIfThereIsOneSelectorSource() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c')"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));
    }
View Full Code Here

        assertThat(same.getPath(), is("/a/b/c"));
    }

    @Test
    public void shouldParseConstraintFromStringWithIsSameNodeExpressionWithSelectorNameAndPath() {
        Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE(tableA,'/a/b/c')"), typeSystem, mock(Source.class));
        assertThat(constraint, is(instanceOf(SameNode.class)));
        SameNode same = (SameNode)constraint;
        assertThat(same.selectorName(), is(selectorName("tableA")));
        assertThat(same.getPath(), is("/a/b/c"));
    }
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.query.model.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.