use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testTemplateFromWhere.
@Test
public void testTemplateFromWhere() {
Model m = new XmlModel().create();
SimpleEntity simpleEntity = (SimpleEntity) m.getDeclarations().wGet(0);
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromWhere");
for (ClassDeclaration classDecl : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, simpleEntity)) {
assertEquals(StringUtils.toUpperCap(simpleEntity.getName().getValue()), classDecl.getName().wStringValue());
int featuresSize = simpleEntity.getFeatures().wSize();
assertEquals(featuresSize * 2, classDecl.getBodyDeclarations().wSize());
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testBindingScopes3.
@Test
public void testBindingScopes3() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectBindingScopes3");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
IEntity nameData = tuple.wGet(1);
String name = nameData.wStringValue();
String entityName = bm.wStringValue("entityName");
assertEquals(name, d.wGet(0).wGet(1).wStringValue());
assertEquals(name, entityName);
assertFalse(bm.wIsSet("fromName"));
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithNestedRelativeQuery.
@Test
public void testSelectTemplateWithNestedRelativeQuery() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithNestedRelativeQuery");
PathExpression pe2 = (PathExpression) tm.create("selectTemplateWithNestedQuery");
IEntityIterator<ClassDeclaration> i2 = BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe2, m);
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertTrue(i2.hasNext());
assertTrue(Matcher.match(i2.next(), t));
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTuple1.
@Test
public void testSelectTuple1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectTuple1");
int count = 0;
for (IEntity t : BehaviorUtils.compileAndLazyEvaluate(pe1, g)) {
NonTerminal name = (NonTerminal) t.wGet(0);
Rule rule = (Rule) t.wGet(1);
Production prod = (Production) t.wGet(2);
assertEquals(name, prod.getName());
assertSame(rule, prod.getRule());
assertEquals(g.getName(), t.wGet(3));
count++;
}
assertEquals(g.getPhraseStructure().wSize(), count);
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testBindingScopes2.
@Test
public void testBindingScopes2() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectBindingScopes2");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
SimpleEntity e = (SimpleEntity) tuple.wGet(1);
String eName = e.getName().getValue();
assertEquals(eName, d.wGet(0).wGet(1).wStringValue());
assertEquals(eName, d.wGet(0).wGet(2).wStringValue());
assertEquals(eName + eName, d.wGet(1).wGet(1).wStringValue());
}
}
Aggregations