use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class XsdMappingTest method testModelsToXmlSchemaXXX.
@Test
public void testModelsToXmlSchemaXXX() throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression path = new ModelToXmlSchemaQuery().create();
Model model = (Model) ModelsTemplateManager.instance().create("Models model");
String uri = model.getUri().getValue();
ILanguageKit lk = ReflectionFactory.getLanguageKit(uri);
IEntity tuple = BehaviorUtils.evaluateFirstResult(path, model, bm);
Assert.assertNotNull(tuple);
InterpreterOperation.interpret(tuple.wGet(1));
ITemplateManager tm = lk.getTemplateManager();
IEntity entity = tm.create("Editors model");
IPersistenceProvider pp = new StringPersistenceProvider();
XsiPersistenceKit.instance().writeModel(entity, pp);
IEntity entity2 = XsiPersistenceKit.instance().readModel(pp);
boolean matches = Matcher.match(entity, entity2);
Assert.assertTrue(matches);
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testVariableJoinTest4.
@Test
public void testVariableJoinTest4() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new QueriesGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction4");
StringBuilder names = new StringBuilder();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g)) names.append(p.getName().getValue());
Assert.assertEquals("ExpressionPathExpressionStepExpressionPredicate", names.toString());
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testVariableJoinTest5.
@Test
public void testVariableJoinTest5() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new QueriesGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("recursiveProduction5");
StringBuilder names = new StringBuilder();
for (Production p : BehaviorUtils.<Production>compileAndLazyEvaluate(pe1, g)) names.append(p.getName().getValue());
Assert.assertEquals("ExpressionPathExpressionStepExpressionPredicate", names.toString());
}
use of org.whole.lang.templates.ITemplateManager in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testProduct1.
@Test
public void testProduct1() {
ITemplateManager tm = PathExpressionsQueriesTemplateManager.instance();
Grammar g = new TestXmlGrammar().create();
PathExpression pe1 = (PathExpression) tm.create("testProduct1");
IBindingManager bm = BindingManagerFactory.instance.createArguments();
int count = 0;
for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(pe1, g, bm)) {
String vname = ((Production) bm.wGet("pp")).getName().getValue() + "x" + ((Production) bm.wGet("lp")).getName().getValue();
String tname = ((Production) tuple.wGet(0)).getName().getValue() + "x" + ((Production) tuple.wGet(1)).getName().getValue();
Assert.assertEquals(vname, tname);
count++;
}
Assert.assertEquals(g.getPhraseStructure().wSize() * g.getLexicalStructure().wSize(), count);
}
use of org.whole.lang.templates.ITemplateManager 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));
}
Aggregations