use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testIf1.
@Test
public void testIf1() {
Model model = new XmlModel().create();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("if1");
assertFalse(BehaviorUtils.compileAndLazyEvaluate(query, model.getDeclarations()).hasNext());
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model);
assertTrue(iterator.hasNext());
assertEquals(model.getName().getValue(), iterator.next().wStringValue());
assertFalse(iterator.hasNext());
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testIf3.
@Test
public void testIf3() {
Model model = new XmlModel().create();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("if3");
IEntity result = BehaviorUtils.evaluateFirstResult(query, model);
assertTrue(result instanceof ClassDeclaration);
assertEquals(StringUtils.toUpperCap(model.getName().getValue()), ((ClassDeclaration) result).getName().getValue());
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPatternWithVariablePredicate.
@Test
public void testPatternWithVariablePredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
StringBuilder names = new StringBuilder();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
IEntityIterator<Production> iterator = BehaviorUtils.<Production>compileAndLazyEvaluate((PathExpression) tm.create("path8"), g, bm);
for (Production p : iterator) {
Assert.assertEquals(bm.wStringValue("name"), p.getName().getValue());
names.append(p.getName().getValue());
}
Assert.assertEquals("VersionEncodingValueNameNameSpaceCharDataCDataSectDataCommentText", names.toString());
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPatternPredicate.
@Test
public void testPatternPredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
int count = 0;
for (As as : BehaviorUtils.<As>compileAndLazyEvaluate((PathExpression) tm.create("path7"), g)) {
Assert.assertEquals("tag", as.getName().wStringValue());
count++;
}
Assert.assertEquals(2, count);
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPathWithFiltersIterator.
@Test
public void testPathWithFiltersIterator() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
Set<String> l = new HashSet<String>();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate((PathExpression) tm.create("path4"), g)) l.add(p.getName().getValue());
Assert.assertEquals(16, l.size());
}
Aggregations