use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class ControlQueriesTest method testCall4.
@Test
public void testCall4() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call4");
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.bindings.IBindingManager in project whole by wholeplatform.
the class ControlQueriesTest method testChoose4.
@Test
public void testChoose4() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("choose4");
int i = 0;
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model, bm);
while (iterator.hasNext()) {
IEntity result = iterator.next();
assertSame(result, bm.wGet("type"));
assertTrue(result instanceof ClassDeclaration);
ClassDeclaration classDecl = (ClassDeclaration) result;
IEntity decl = decls.wGet(i++);
String name = "", superClassName = "";
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
SimpleEntity simpleEntity = (SimpleEntity) decl;
name = simpleEntity.getName().wStringValue();
superClassName = "AbstractSimpleEntity";
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
CompositeEntity compositeEntity = (CompositeEntity) decl;
name = compositeEntity.getName().wStringValue();
superClassName = "AbstractCompositeEntity";
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
DataEntity dataEntity = (DataEntity) decl;
name = dataEntity.getName().wStringValue();
superClassName = "AbstractDataEntity";
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
EnumEntity enumEntity = (EnumEntity) decl;
name = enumEntity.getName().wStringValue();
superClassName = "AbstractEnumEntity";
break;
}
assertEquals(name, classDecl.getName().wStringValue());
assertEquals(superClassName, classDecl.getSuperclassType().wStringValue());
}
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class ControlQueriesTest method testCall6.
@Test
public void testCall6() {
Grammar grammar = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("call6");
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.bindings.IBindingManager in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl5.
@Test
public void testQueryDecl5() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl5");
int count = 0;
int index = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
IEntity decl = decls.wGet(index++);
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
Features features = ((SimpleEntity) decl).getFeatures();
if (!features.isEmpty())
assertEquals(features.get(0).getName().wStringValue(), p.wStringValue());
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
assertEquals(((CompositeEntity) decl).getComponentType().wStringValue(), p.wStringValue());
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
assertEquals(((DataEntity) decl).getName().wStringValue(), p.wStringValue());
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
assertTrue(Matcher.matchImpl(ModelsEntityDescriptorEnum.EnumEntity, p));
break;
}
count++;
}
assertEquals(33, count);
}
use of org.whole.lang.bindings.IBindingManager 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);
}
Aggregations