use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate5.
@Test
public void testUpdate5() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update5");
List<String> dataEntityNames = new ArrayList<String>();
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
dataEntityNames.add(((DataEntity) decl).getName().getValue());
}
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity));
Iterator<String> dataEntityNamesIterator = dataEntityNames.iterator();
for (int i = 0; i < declarations.wSize() && dataEntityNamesIterator.hasNext(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decl))
assertEquals(dataEntityNamesIterator.next(), ((SimpleEntity) decl).getName().getValue());
}
dataEntityNamesIterator = dataEntityNames.iterator();
for (int i = 0; i < declarations.wSize() && dataEntityNamesIterator.hasNext(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.CompositeEntity, decl))
assertEquals(dataEntityNamesIterator.next(), ((CompositeEntity) decl).getName().getValue());
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate10.
@Test
public void testUpdate10() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update10");
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)) {
String name = ((DataEntity) decl).getName().getValue();
assertEquals(StringUtils.toLowerCap(name), name);
}
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testDelete2.
@Test
public void testDelete2() {
Grammar model = new TestXmlGrammar().create();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("delete2");
for (Name name : BehaviorUtils.<Name>compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(GrammarsEntityDescriptorEnum.Name, name));
for (IEntity name : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(EntityUtils.isResolver(name));
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate11.
@Test
public void testUpdate11() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update11");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity) || Matcher.match(ModelsEntityDescriptorEnum.DataType, entity));
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl)) {
String name = ((DataEntity) decl).getName().getValue();
assertEquals(StringUtils.toLowerCap(name), name);
assertEquals("MyDataType", ((DataEntity) decl).getDataType().getValue());
}
}
}
use of org.whole.lang.queries.model.PathExpression in project whole by wholeplatform.
the class RewriteQueriesTest method testDelete1.
@Test
public void testDelete1() {
Model model = new ModelsModel().create();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("delete1");
for (DataEntity dataEntity : BehaviorUtils.<DataEntity>compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.DataEntity, dataEntity));
assertFalse(BehaviorUtils.compileAndLazyEvaluate(query, model).hasNext());
}
Aggregations