use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithJavaHelpers.
@Test
public void testSelectTemplateWithJavaHelpers() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithJavaHelpers");
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertEquals(JavaEntityDescriptorEnum.ClassDeclaration, t.wGetEntityDescriptor());
String cname = t.getName().wStringValue();
assertTrue(Character.isUpperCase(cname.charAt(0)) && cname.endsWith("Impl"));
for (int i = 0; i < t.getBodyDeclarations().wSize(); i++) {
FieldDeclaration fd = (FieldDeclaration) t.getBodyDeclarations().wGet(i);
assertTrue(Character.isUpperCase(fd.getType().wStringValue().charAt(0)));
}
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectPathExpression2.
@Test
public void testSelectPathExpression2() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
PathExpression query = (PathExpression) tm.create("selectPath2");
StringBuilder names = new StringBuilder();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(query, model)) names.append(nt.getValue());
assertEquals("DocumentElementINameIContent", names.toString());
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateFromPattern.
@Test
public void testSelectTemplateFromPattern() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
JavaEntityFactory ef = JavaEntityFactory.instance;
IfStatement ifStm = ef.createIfStatement(ef.createPrefixExpression(ef.createPrefixOperator(PrefixOperatorEnum.not), ef.createInfixExpression(ef.createSimpleName("x"), ef.createInfixOperator(InfixOperatorEnum.less), ef.createIntLiteral(3), ef.createExpressions(0))), ef.createEmptyStatement(), ef.createBlock(ef.createExpressionStatement(ef.createAssignment()), ef.createExpressionStatement(ef.createAssignment())));
PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromPattern");
IfStatement t = BehaviorUtils.<IfStatement>evaluateFirstResult(pe1, ifStm);
assertEquals(JavaEntityDescriptorEnum.PrefixExpression, t.getExpression().wGetEntityDescriptor());
assertTrue(Matcher.match(ifStm.getElseStatement(), t.getThenStatement()));
assertTrue(Matcher.match(ifStm.getThenStatement(), t.getElseStatement()));
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectPathExpression1.
@Test
public void testSelectPathExpression1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("selectPath1");
StringBuilder names = new StringBuilder();
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g)) names.append(nt.getValue());
assertEquals("DocumentElementINameIContent", names.toString());
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplate1.
@Test
public void testSelectTemplate1() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression query = (PathExpression) tm.create("selectTemplate1");
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
Feature f = (Feature) tuple.wGet(0);
As e = (As) tuple.wGet(1);
assertEquals(e.getName().getValue(), f.getName().wStringValue());
assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
}
}
Aggregations