use of org.whole.lang.text.model.Document in project whole by wholeplatform.
the class SelectQueriesTest method testVariableScopes.
@Test
public void testVariableScopes() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectVariableScopes");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Document d = (Document) tuple.wGet(0);
SimpleEntity se = (SimpleEntity) tuple.wGet(1);
assertFalse(bm.wIsSet("fromName"));
assertFalse(bm.wIsSet("oneTime"));
assertFalse(bm.wIsSet("featuresTimes"));
assertFalse(bm.wIsSet("featuresTimesInLine"));
assertFalse(bm.wIsSet("fTimes"));
assertFalse(bm.wIsSet("siblingTimes"));
// changed semantics: from variables are substituted multiple times
assertTrue(1 < d.wGet(0).wSize() - 1);
assertEquals(1, d.wGet(1).wSize() - 1);
assertEquals(se.getFeatures().wSize(), d.wGet(2).wSize() - 1);
assertEquals(se.getFeatures().wSize(), d.wGet(3).wSize() - 1);
assertEquals(model.getDeclarations().wSize() - 1 - model.getDeclarations().wIndexOf(se), d.wGet(4).wSize() - 1);
}
}
use of org.whole.lang.text.model.Document 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.text.model.Document 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());
}
}
use of org.whole.lang.text.model.Document in project whole by wholeplatform.
the class SelectQueriesTest method testBindingScopes.
@Test
public void testBindingScopes() {
Model m = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectBindingScopes");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
BindingsTester bt = new BindingsTester(bm);
bm.wDefValue("bindingsTester", bt);
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, m, 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 + eName, d.wGet(1).wGet(1).wStringValue());
assertEquals(eName + eName + eName + eName, d.wGet(2).wGet(1).wStringValue());
for (int f = 0; f < e.getFeatures().wSize(); f++) {
assertEquals(eName + eName + eName + eName + eName + eName + eName + eName, d.wGet(3).wGet(1 + f).wStringValue());
assertEquals("true", d.wGet(4).wGet(1 + f).wStringValue());
assertEquals("true", d.wGet(5).wGet(1 + f).wStringValue());
}
assertEquals(3, d.wGet(6).wSize());
assertTrue(EntityUtils.isVariable(d.wGet(6).wGet(1)));
assertTrue(EntityUtils.isVariable(d.wGet(6).wGet(2)));
}
}
Aggregations