use of org.whole.lang.java.model.FieldDeclaration 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.java.model.FieldDeclaration 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.java.model.FieldDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateFromPatternWithWhere.
@Test
public void testSelectTemplateFromPatternWithWhere() {
Model m = new XmlModel().create();
Feature feature = (Feature) ((SimpleEntity) m.getDeclarations().wGet(0)).getFeatures().wGet(0);
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromPatternWithWhere");
for (FieldDeclaration field : BehaviorUtils.<FieldDeclaration>compileAndLazyEvaluate(pe1, feature)) {
assertEquals(feature.getName().wStringValue(), field.getFragments().wGet(0).wGet(0).wStringValue());
assertEquals(StringUtils.toUpperCap(feature.getType().wStringValue()), field.getType().wStringValue());
}
}
use of org.whole.lang.java.model.FieldDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateAs.
@Test
public void testSelectTemplateAs() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectTemplateAs");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
FieldDeclaration f = (FieldDeclaration) tuple.wGet(0);
Feature e = (Feature) tuple.wGet(1);
FieldDeclaration field = (FieldDeclaration) bm.wGet("field");
assertSame(f, field);
String ptype = e.getType().wStringValue();
assertEquals(ptype, field.getType().wStringValue());
}
}
use of org.whole.lang.java.model.FieldDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateFromPathWithPattern.
@Test
public void testSelectTemplateFromPathWithPattern() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromPathWithPattern");
IEntityIterator<Feature> featureIterator = IteratorFactory.<Feature>descendantOrSelfMatcherIterator().withPattern(ModelsEntityDescriptorEnum.Feature);
featureIterator.reset(m);
for (FieldDeclaration field : BehaviorUtils.<FieldDeclaration>compileAndLazyEvaluate(pe1, m)) {
Feature feature = featureIterator.next();
assertEquals(feature.getType().wStringValue(), field.getType().wStringValue());
assertEquals(feature.getName().wStringValue(), field.getFragments().wGet(0).wGet(0).wStringValue());
}
}
Aggregations