Search in sources :

Example 6 with As

use of org.whole.lang.grammars.model.As in project whole by wholeplatform.

the class SelectQueriesTest method testSelectTupleWithTemplates.

@Test
public void testSelectTupleWithTemplates() {
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    Grammar model = new TestXmlGrammar().create();
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    PathExpression query = (PathExpression) tm.create("selectTupleWithTemplates");
    for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
        FieldDeclaration fd = (FieldDeclaration) tuple.wGet(0);
        Feature f = (Feature) tuple.wGet(1);
        As e = (As) tuple.wGet(2);
        assertEquals(e.getName().getValue(), fd.getFragments().wGet(0).wGet(0).wStringValue());
        assertEquals(e.getRule().wStringValue(), fd.getType().wStringValue());
        assertEquals(e.getName().getValue(), f.getName().wStringValue());
        assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
    }
}
Also used : As(org.whole.lang.grammars.model.As) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) IBindingManager(org.whole.lang.bindings.IBindingManager) ITemplateManager(org.whole.lang.templates.ITemplateManager) TestXmlGrammar(org.whole.lang.grammars.util.TestXmlGrammar) Grammar(org.whole.lang.grammars.model.Grammar) Feature(org.whole.lang.models.model.Feature) FieldDeclaration(org.whole.lang.java.model.FieldDeclaration) Test(org.junit.Test)

Aggregations

As (org.whole.lang.grammars.model.As)6 Test (org.junit.Test)3 Grammar (org.whole.lang.grammars.model.Grammar)3 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)3 IEntity (org.whole.lang.model.IEntity)3 ITemplateManager (org.whole.lang.templates.ITemplateManager)3 IBindingManager (org.whole.lang.bindings.IBindingManager)2 NonTerminal (org.whole.lang.grammars.model.NonTerminal)2 Repeat (org.whole.lang.grammars.model.Repeat)2 Rule (org.whole.lang.grammars.model.Rule)2 Feature (org.whole.lang.models.model.Feature)2 PathExpression (org.whole.lang.queries.model.PathExpression)2 ArrayList (java.util.ArrayList)1 QueriesGrammar (org.whole.lang.grammars.codebase.QueriesGrammar)1 Concatenate (org.whole.lang.grammars.model.Concatenate)1 Optional (org.whole.lang.grammars.model.Optional)1 Template (org.whole.lang.grammars.model.Template)1 AbstractPatternFilterIterator (org.whole.lang.iterators.AbstractPatternFilterIterator)1 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)1 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)1