use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testChoose2.
@Test
public void testChoose2() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("choose2");
int i = 0;
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model);
while (iterator.hasNext()) {
IEntity result;
IEntity decl = decls.wGet(i++);
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
IEntity features = ((SimpleEntity) decl).getFeatures();
for (int j = 0; j < features.wSize(); j++) {
result = iterator.next();
assertEquals(((Feature) features.wGet(j)).getName().wStringValue(), result.wStringValue());
}
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
result = iterator.next();
CompositeEntity compositeEntity = (CompositeEntity) decl;
assertEquals(compositeEntity.getComponentType().wStringValue(), result.wStringValue());
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
result = iterator.next();
DataEntity dataEntity = (DataEntity) decl;
assertEquals(dataEntity.getDataType().wStringValue(), result.wStringValue());
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
EnumValues enumValues = ((EnumEntity) decl).getValues();
if (enumValues.wIsEmpty())
iterator.next();
else
for (int j = 0; j < enumValues.wSize(); j++) {
result = iterator.next();
assertEquals(enumValues.wGet(j).wStringValue(), result.wStringValue());
}
break;
}
}
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testCall3.
@Test
public void testCall3() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call3");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
assertEquals("IContent", ((Production) p).getName().getValue());
count++;
}
assertEquals(1, count);
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl2.
@Test
public void testQueryDecl2() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl2");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
assertEquals("IContent", ((Production) p).getName().getValue());
count++;
}
assertEquals(1, count);
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl6.
@Test
public void testQueryDecl6() {
// not used
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl6");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
if (++count == 1)
assertEquals(5, p.wIntValue());
else if (count == 2)
assertEquals(10, p.wIntValue());
else if (count == 3)
assertEquals(8, p.wIntValue());
}
assertEquals(3, count);
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl1.
@Test
public void testQueryDecl1() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl1");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, grammar, bm)) {
assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Production, p));
assertEquals("IContent", ((Production) p).getName().getValue());
count++;
}
assertEquals(1, count);
}
Aggregations