use of org.whole.lang.java.model.ClassDeclaration 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.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testTemplateFromWhere.
@Test
public void testTemplateFromWhere() {
Model m = new XmlModel().create();
SimpleEntity simpleEntity = (SimpleEntity) m.getDeclarations().wGet(0);
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateFromWhere");
for (ClassDeclaration classDecl : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, simpleEntity)) {
assertEquals(StringUtils.toUpperCap(simpleEntity.getName().getValue()), classDecl.getName().wStringValue());
int featuresSize = simpleEntity.getFeatures().wSize();
assertEquals(featuresSize * 2, classDecl.getBodyDeclarations().wSize());
}
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithNestedRelativeQuery.
@Test
public void testSelectTemplateWithNestedRelativeQuery() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithNestedRelativeQuery");
PathExpression pe2 = (PathExpression) tm.create("selectTemplateWithNestedQuery");
IEntityIterator<ClassDeclaration> i2 = BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe2, m);
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertTrue(i2.hasNext());
assertTrue(Matcher.match(i2.next(), t));
}
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithNestedQuery.
@Test
public void testSelectTemplateWithNestedQuery() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithNestedQuery");
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m)) {
assertEquals(JavaEntityDescriptorEnum.ClassDeclaration, t.wGetEntityDescriptor());
assertTrue(t.getBodyDeclarations().wSize() >= 2);
}
}
use of org.whole.lang.java.model.ClassDeclaration in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTemplateWithFreeVariable.
@Test
public void testSelectTemplateWithFreeVariable() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Model m = new XmlModel().create();
PathExpression pe1 = (PathExpression) tm.create("selectTemplateWithFreeVariable");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (ClassDeclaration t : BehaviorUtils.<ClassDeclaration>compileAndLazyEvaluate(pe1, m, bm)) {
assertEquals(JavaEntityDescriptorEnum.ClassDeclaration, t.wGetEntityDescriptor());
if (bm.wIsSet("freeVariable")) {
assertEquals(bm.wStringValue("freeVariable"), t.getName().wStringValue());
bm.wUnset("freeVariable");
} else {
assertTrue(t.getName().wIsAdapter());
bm.wDefValue("freeVariable", "MyClassName");
}
}
}
Aggregations