use of org.whole.lang.models.model.Model 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());
}
use of org.whole.lang.models.model.Model in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testHelperResultAs.
@Test
public void testHelperResultAs() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression query = (PathExpression) tm.create("helperResultAs");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("ftype", "firstName");
IEntityIterator<?> iterator = BehaviorUtils.<FieldDeclaration>compileAndLazyEvaluate(query, m, bm);
Assert.assertTrue(iterator.hasNext());
IEntity result = iterator.next();
IEntity as = bm.wGet("jtype");
Assert.assertEquals("FirstName", result.wStringValue());
Assert.assertEquals("FirstName", as.wStringValue());
Assert.assertFalse(iterator.hasNext());
iterator.reset(m);
bm.wDefValue("ftype", "secondName");
Assert.assertTrue(iterator.hasNext());
IEntity result2 = iterator.next();
IEntity as2 = bm.wGet("jtype");
Assert.assertEquals("SecondName", result2.wStringValue());
Assert.assertEquals("SecondName", as2.wStringValue());
}
use of org.whole.lang.models.model.Model 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.models.model.Model 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.models.model.Model in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate4.
@Test
public void testUpdate4() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update4");
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());
}
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl))
assertTrue(EntityUtils.isResolver(((DataEntity) decl).getName()));
}
}
Aggregations