use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.
the class ControlQueriesTest method testDo1.
@Test
public void testDo1() {
Model model = new XmlModel().create();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("do1");
IEntity result = BehaviorUtils.evaluateFirstResult(query, model);
assertTrue(result instanceof ClassDeclaration);
assertEquals("HelloWorld", ((ClassDeclaration) result).getName().getValue());
}
use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.
the class ControlQueriesTest method testIf2.
@Test
public void testIf2() {
Model model = new XmlModel().create();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("if2");
IEntity result = BehaviorUtils.evaluateFirstResult(query, model);
assertTrue(result instanceof ClassDeclaration);
assertEquals(model.getName().getValue(), ((ClassDeclaration) result).getName().getValue());
}
use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.
the class ControlQueriesTest method testFor1.
@Test
public void testFor1() {
Model model = new XmlModel().create();
ModelDeclarations decls = model.getDeclarations();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("for1");
int i = 0;
for (IEntity name : BehaviorUtils.compileAndLazyEvaluate(query, model)) {
while (!Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decls.wGet(i))) i++;
assertEquals(((SimpleEntity) decls.wGet(i++)).getName().wStringValue(), name.wStringValue());
}
assertTrue(i > 0);
}
use of org.whole.lang.models.codebase.XmlModel 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.models.codebase.XmlModel 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());
}
Aggregations