Search in sources :

Example 11 with XmlModel

use of org.whole.lang.models.codebase.XmlModel 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));
    }
}
Also used : ClassDeclaration(org.whole.lang.java.model.ClassDeclaration) PathExpression(org.whole.lang.queries.model.PathExpression) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Example 12 with XmlModel

use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.

the class SelectQueriesTest method testBindingScopes2.

@Test
public void testBindingScopes2() {
    Model model = new XmlModel().create();
    ITemplateManager tm = SelectQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("selectBindingScopes2");
    IBindingManager bm = BindingManagerFactory.instance.createArguments();
    for (IEntity tuple : BehaviorUtils.compileAndLazyEvaluate(query, model, bm)) {
        Document d = (Document) tuple.wGet(0);
        SimpleEntity e = (SimpleEntity) tuple.wGet(1);
        String eName = e.getName().getValue();
        assertEquals(eName, d.wGet(0).wGet(1).wStringValue());
        assertEquals(eName, d.wGet(0).wGet(2).wStringValue());
        assertEquals(eName + eName, d.wGet(1).wGet(1).wStringValue());
    }
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) IBindingManager(org.whole.lang.bindings.IBindingManager) XmlModel(org.whole.lang.models.codebase.XmlModel) ITemplateManager(org.whole.lang.templates.ITemplateManager) Document(org.whole.lang.text.model.Document) Test(org.junit.Test)

Example 13 with XmlModel

use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.

the class HistoryInvariantsTest method testHistoryDefaultHistoryEnablement.

@Test
public void testHistoryDefaultHistoryEnablement() {
    IEntity model = new XmlModel().create();
    IHistoryManager history = ReflectionFactory.getHistoryManager(model);
    Assert.assertFalse(history.isHistoryEnabled());
    Assert.assertEquals(0, history.getUndoSize());
    Assert.assertTrue(history.getUndoCommands().isEmpty());
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) XmlModel(org.whole.lang.models.codebase.XmlModel) IHistoryManager(org.whole.lang.lifecycle.IHistoryManager) Test(org.junit.Test)

Example 14 with XmlModel

use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testPathOfChildSteps.

@Test
public void testPathOfChildSteps() {
    Model model = new XmlModel().create();
    IEntity decl3 = model.getDeclarations().wGet(3);
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    PathExpression pe = ef.createPath(ef.createFeatureStep("declarations"), ef.createFilter(ef.createChildStep(), ef.createIndexTest(ef.createIntLiteral(3))));
    IEntity result = BehaviorUtils.evaluateFirstResult(pe, model);
    Assert.assertSame(decl3, result);
}
Also used : PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Example 15 with XmlModel

use of org.whole.lang.models.codebase.XmlModel in project whole by wholeplatform.

the class PathExpressionsQueriesTest method testChildStepByName.

@Test
public void testChildStepByName() {
    Model model = new XmlModel().create();
    SimpleName name = model.getName();
    QueriesEntityFactory ef = QueriesEntityFactory.instance;
    IEntity result = BehaviorUtils.evaluateFirstResult(ef.createFeatureStep("name"), model);
    Assert.assertSame(name, result);
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) SimpleName(org.whole.lang.models.model.SimpleName) XmlModel(org.whole.lang.models.codebase.XmlModel) Model(org.whole.lang.models.model.Model) XmlModel(org.whole.lang.models.codebase.XmlModel) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)26 XmlModel (org.whole.lang.models.codebase.XmlModel)26 Model (org.whole.lang.models.model.Model)25 PathExpression (org.whole.lang.queries.model.PathExpression)23 ITemplateManager (org.whole.lang.templates.ITemplateManager)22 IEntity (org.whole.lang.model.IEntity)17 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)10 IBindingManager (org.whole.lang.bindings.IBindingManager)9 SimpleEntity (org.whole.lang.models.model.SimpleEntity)7 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)6 ModelsModel (org.whole.lang.models.codebase.ModelsModel)5 Feature (org.whole.lang.models.model.Feature)4 Document (org.whole.lang.text.model.Document)4 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)3 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)2 Assignment (org.whole.lang.java.model.Assignment)1 BodyDeclarations (org.whole.lang.java.model.BodyDeclarations)1 ExpressionStatement (org.whole.lang.java.model.ExpressionStatement)1 MethodDeclaration (org.whole.lang.java.model.MethodDeclaration)1 SingleVariableDeclaration (org.whole.lang.java.model.SingleVariableDeclaration)1