Package org.modeshape.jcr.query.model

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


    public void shouldParseReferenceValueFromStringWithQuotedSelectorNameAndQuotedPropertyName() {
        ReferenceValue value = parser.parseReferenceValue(tokens("[mode:tableA].[mode:property]"), typeSystem, mock(Join.class));
        assertThat(value.getPropertyName(), is("mode:property"));
        assertThat(value.selectorName(), is(selectorName("mode:tableA")));

        Source source = new NamedSelector(selectorName("mode:tableA"));
        value = parser.parseReferenceValue(tokens("[mode:tableA].[mode:property]"), typeSystem, source);
        assertThat(value.getPropertyName(), is("mode:property"));
        assertThat(value.selectorName(), is(selectorName("mode:tableA")));
    }
View Full Code Here


        assertThat(value.selectorName(), is(selectorName("mode:tableA")));
    }

    @Test
    public void shouldParseReferenceValueFromStringWithOnlyPropertyNameIfSourceIsSelector() {
        Source source = new NamedSelector(selectorName("tableA"));
        ReferenceValue value = parser.parseReferenceValue(tokens("property)"), typeSystem, source);
        assertThat(value.getPropertyName(), is("property"));
        assertThat(value.selectorName(), is(selectorName("tableA")));
    }
View Full Code Here

        assertThat(value.selectorName(), is(selectorName("tableA")));
    }

    @Test
    public void shouldParseReferenceValueFromStringWithMatchingSelectorNameIfSourceIsSelector() {
        Source source = new NamedSelector(selectorName("tableA"));
        ReferenceValue value = parser.parseReferenceValue(tokens("tableA)"), typeSystem, source);
        assertThat(value.getPropertyName(), is(nullValue()));
        assertThat(value.selectorName(), is(selectorName("tableA")));
    }
View Full Code Here

    // parseNamedSelector
    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseNamedSelectorFromUnquotedNameWithNoAlias() {
        NamedSelector selector = parser.parseNamedSelector(tokens("name"), typeSystem);
        assertThat(selector.name(), is(selectorName("name")));
        assertThat(selector.alias(), is(nullValue()));
        assertThat(selector.aliasOrName(), is(selectorName("name")));
    }
View Full Code Here

        assertThat(selector.aliasOrName(), is(selectorName("name")));
    }

    @Test
    public void shouldParseNamedSelectorFromUnquotedNameWithUnquotedAlias() {
        NamedSelector selector = parser.parseNamedSelector(tokens("name AS alias"), typeSystem);
        assertThat(selector.name(), is(selectorName("name")));
        assertThat(selector.alias(), is(selectorName("alias")));
        assertThat(selector.aliasOrName(), is(selectorName("alias")));
    }
View Full Code Here

        assertThat(selector.aliasOrName(), is(selectorName("alias")));
    }

    @Test
    public void shouldParseNamedSelectorFromQuotedNameWithUnquotedAlias() {
        NamedSelector selector = parser.parseNamedSelector(tokens("'name' AS alias"), typeSystem);
        assertThat(selector.name(), is(selectorName("name")));
        assertThat(selector.alias(), is(selectorName("alias")));
        assertThat(selector.aliasOrName(), is(selectorName("alias")));
    }
View Full Code Here

        assertThat(selector.aliasOrName(), is(selectorName("alias")));
    }

    @Test
    public void shouldParseNamedSelectorFromQuotedNameWithQuotedAlias() {
        NamedSelector selector = parser.parseNamedSelector(tokens("'name' AS [alias]"), typeSystem);
        assertThat(selector.name(), is(selectorName("name")));
        assertThat(selector.alias(), is(selectorName("alias")));
        assertThat(selector.aliasOrName(), is(selectorName("alias")));
    }
View Full Code Here

        assertParseConstraint("ISSAMENODE('/a/b') AND (NOT(ISCHILDNODE('/parent')))");
        assertParseConstraint("ISSAMENODE('/a/b') AND (NOT(tableA.id < 1234)))");
    }

    protected void assertParseConstraint( String expression ) {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        parser.parseConstraint(tokens(expression), typeSystem, selector);
    }
View Full Code Here

    // parseConstraint - between
    // ----------------------------------------------------------------------------------------------------------------

    @Test
    public void shouldParseConstraintFromStringWithValidBetweenExpressionUsing() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' AND 'upper'"), typeSystem, selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(true));
        assertThat(between.isUpperBoundIncluded(), is(true));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
View Full Code Here

        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
    }

    @Test
    public void shouldParseConstraintFromStringWithValidBetweenExpressionUsingExclusiveAndExclusive() {
        NamedSelector selector = new NamedSelector(selectorName("tableA"));
        Constraint constraint = parser.parseConstraint(tokens("tableA.id BETWEEN 'lower' EXCLUSIVE AND 'upper' EXCLUSIVE"),
                                                       typeSystem,
                                                       selector);
        assertThat(constraint, is(instanceOf(Between.class)));
        Between between = (Between)constraint;
        assertThat(between.isLowerBoundIncluded(), is(false));
        assertThat(between.isUpperBoundIncluded(), is(false));
        assertThat(between.getOperand(), is(instanceOf(PropertyValue.class)));
        PropertyValue operand = (PropertyValue)between.getOperand();
        assertThat(operand.selectorName(), is(selector.name()));
        assertThat(operand.getPropertyName(), is("id"));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat(between.getLowerBound(), is(instanceOf(Literal.class)));
        assertThat((Literal)between.getLowerBound(), is(literal("lower")));
        assertThat((Literal)between.getUpperBound(), is(literal("upper")));
View Full Code Here

TOP

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

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.