use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate3.
@Test
public void testUpdate3() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update3");
List<String> names = new ArrayList<String>();
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
names.add(((DataEntity) decl).getName().getValue());
}
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity));
Iterator<String> iterator = names.iterator();
for (int i = 0; i < declarations.wSize() && iterator.hasNext(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decl))
assertEquals(iterator.next(), ((SimpleEntity) decl).getName().getValue());
}
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate2.
@Test
public void testUpdate2() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update2");
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)) {
assertEquals("MyDataEntityName", ((DataEntity) decl).getName().getValue());
assertEquals("MyDataType", ((DataEntity) decl).getDataType().getValue());
}
}
}
use of org.whole.lang.templates.ITemplateManager 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.templates.ITemplateManager 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.templates.ITemplateManager 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));
}
Aggregations