use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testPathWithKindAndLogicFiltersIterator.
@Test
public void testPathWithKindAndLogicFiltersIterator() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
QueriesEntityFactory ef = QueriesEntityFactory.instance;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate((PathExpression) tm.create("path2"), new TestXmlGrammar().create())) Assert.assertTrue(p.wGetEntityKind().equals(EntityKinds.SIMPLE) || p.wGetEntityKind().equals(EntityKinds.DATA));
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate((PathExpression) tm.create("path3"), new TestXmlGrammar().create())) Assert.assertFalse(p.wGetEntityKind().equals(EntityKinds.COMPOSITE));
}
use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testChildStepByIndex.
@Test
public void testChildStepByIndex() {
Model model = new XmlModel().create();
ModelDeclarations decls = model.getDeclarations();
IEntity decl3 = decls.wGet(3);
QueriesEntityFactory ef = QueriesEntityFactory.instance;
IEntity result = BehaviorUtils.evaluateFirstResult(ef.createFilter(ef.createChildStep(), ef.createIndexTest(ef.createIntLiteral(3))), decls);
Assert.assertSame(decl3, result);
}
use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl7.
@Test
public void testQueryDecl7() {
QueriesEntityFactory qef = QueriesEntityFactory.instance;
JavaEntityFactory jef = JavaEntityFactory.instance;
IEntity queryExp1 = qef.createDivision(qef.createMultiplication(qef.createIntLiteral(10), qef.createIntLiteral(8)), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
IEntity queryExp2 = qef.createDivision(qef.createIntLiteral(10), qef.createAddition(qef.createIntLiteral(2), qef.createIntLiteral(1)));
IEntity javaExp1 = jef.createInfixExpression(jef.createInfixExpression(jef.createIntLiteral(10), jef.createInfixOperator(InfixOperatorEnum.times), jef.createIntLiteral(8), jef.createExpressions(0)), jef.createInfixOperator(InfixOperatorEnum.divide), jef.createInfixExpression(jef.createIntLiteral(2), jef.createInfixOperator(InfixOperatorEnum.plus), jef.createIntLiteral(1), jef.createExpressions(0)), jef.createExpressions(0));
IEntity javaExp2 = EntityUtils.clone(javaExp1);
javaExp2.wSet(JavaFeatureDescriptorEnum.leftOperand, jef.createIntLiteral(10));
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl7");
assertTrue(Matcher.match(javaExp2, BehaviorUtils.evaluateFirstResult(query, queryExp2)));
assertTrue(Matcher.match(javaExp1, BehaviorUtils.evaluateFirstResult(query, queryExp1)));
}
use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.
the class ControlQueriesTest method testIf5.
@Test
public void testIf5() {
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("if5");
QueriesEntityFactory qef = QueriesEntityFactory.instance;
IEntity queryExp1 = qef.createDivision(qef.createIntLiteral(10), qef.createIntLiteral(8));
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
IEntity queryRes1 = BehaviorUtils.evaluateFirstResult(query, queryExp1, bm);
assertNotSame(queryExp1.wGet(0), queryRes1.wGet(0));
assertTrue(Matcher.match(queryExp1.wGet(0), queryRes1.wGet(0)));
assertNotSame(queryExp1.wGet(1), queryRes1.wGet(1));
assertTrue(Matcher.match(queryExp1.wGet(1), queryRes1.wGet(1)));
assertTrue(bm.wIsSet("a"));
assertTrue(bm.wIsSet("b"));
assertFalse(bm.wIsSet("exp1"));
assertFalse(bm.wIsSet("exp2"));
}
use of org.whole.lang.queries.factories.QueriesEntityFactory in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testLanguageTest.
@Test
public void testLanguageTest() throws Exception {
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
QueriesEntityFactory ef = QueriesEntityFactory.instance;
for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createLanguageTest("http://lang.whole.org/Java")), model)) Assert.assertEquals("http://lang.whole.org/Java", e.wGetLanguageKit().getURI());
}
Aggregations