use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testSomePredicate.
@Test
public void testSomePredicate() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new QueriesGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction6");
StringBuilder names = new StringBuilder();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g)) names.append(p.getName().getValue());
Assert.assertEquals("ExpressionPathExpressionStepExpressionPredicate", names.toString());
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testSingleVariableTestInPathExpPredicateOfPathInternalStep.
@Test
public void testSingleVariableTestInPathExpPredicateOfPathInternalStep() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("findAllNonTerminalsUsed");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
// FIXME bm.wDefValue("pname", "Element");
bm.wDef("pname", GrammarsEntityFactory.instance.createNonTerminal("IName"));
int count = 0;
for (NonTerminal nt : BehaviorUtils.<NonTerminal>compileAndLazyEvaluate(pe1, g, bm)) count++;
Assert.assertEquals(4, count);
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate7.
@Test
public void testUpdate7() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update7");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity));
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
assertEquals("DataEntityName", ((DataEntity) decl).getName().getValue());
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate6.
@Test
public void testUpdate6() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update6");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity));
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
assertEquals("DataEntityName", ((DataEntity) decl).getName().getValue());
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testDelete3.
@Test
public void testDelete3() {
Grammar model = new TestXmlGrammar().create();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("delete3");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Name, entity) || EntityUtils.isResolver(entity));
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(EntityUtils.isResolver(entity));
}
Aggregations