use of org.whole.lang.models.model.Feature 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.models.model.Feature 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.models.model.Feature 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());
}
}
use of org.whole.lang.models.model.Feature in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTupleOfTemplatesAs.
@Test
public void testSelectTupleOfTemplatesAs() {
Model model = new XmlModel().create();
ITemplateManager tm = SelectQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("selectTupleOfTemplatesAs");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
FieldDeclaration f = (FieldDeclaration) tuple.wGet(0);
SingleVariableDeclaration p = (SingleVariableDeclaration) tuple.wGet(1);
ExpressionStatement s = (ExpressionStatement) tuple.wGet(2);
Feature e = (Feature) tuple.wGet(3);
String ptype = e.getType().wStringValue();
String pname = e.getName().wStringValue();
assertSame(f, bm.wGet("field"));
assertEquals(ptype, f.getType().wStringValue());
assertSame(p, bm.wGet("param"));
assertEquals(ptype, p.getType().wStringValue());
assertEquals(pname, p.getName().wStringValue());
assertSame(s, bm.wGet("init"));
assertEquals(pname, ((Assignment) s.getExpression()).getRightHandSide().wStringValue());
}
}
use of org.whole.lang.models.model.Feature in project whole by wholeplatform.
the class SelectQueriesTest method testSelectTupleWithTemplates.
@Test
public void testSelectTupleWithTemplates() {
ITemplateManager tm = SelectQueriesTemplateManager.instance();
Grammar model = new TestXmlGrammar().create();
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression query = (PathExpression) tm.create("selectTupleWithTemplates");
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
FieldDeclaration fd = (FieldDeclaration) tuple.wGet(0);
Feature f = (Feature) tuple.wGet(1);
As e = (As) tuple.wGet(2);
assertEquals(e.getName().getValue(), fd.getFragments().wGet(0).wGet(0).wStringValue());
assertEquals(e.getRule().wStringValue(), fd.getType().wStringValue());
assertEquals(e.getName().getValue(), f.getName().wStringValue());
assertEquals(e.getRule().wStringValue(), f.getType().wStringValue());
}
}
Aggregations