Search in sources :

Example 11 with SimpleEntity

use of org.whole.lang.models.model.SimpleEntity 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 12 with SimpleEntity

use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.

the class MatcherTest method testCompareSimpleEntityWithResolver.

@Test
public void testCompareSimpleEntityWithResolver() {
    SimpleEntity concrete = ModelsEntityFactory.instance.createSimpleEntity();
    SimpleEntity resolver = CommonsEntityAdapterFactory.createResolver(ModelsEntityDescriptorEnum.SimpleEntity);
    assertFalse(Matcher.match(concrete, resolver));
}
Also used : SimpleEntity(org.whole.lang.models.model.SimpleEntity) Test(org.junit.Test)

Example 13 with SimpleEntity

use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.

the class MatcherTest method testDataSubstitute.

@Test
public void testDataSubstitute() {
    SimpleEntity entityPattern = new SimpleEntityPattern().create();
    IBindingManager bindings = BindingManagerFactory.instance.createBindingManager();
    bindings.wDefValue("entityName", "SE");
    Matcher.substitute(entityPattern, bindings, false);
    assertEquals("SE", entityPattern.getName().wStringValue());
    assertEquals(ModelsEntityDescriptorEnum.SimpleName, entityPattern.getName().wGetEntityDescriptor());
}
Also used : SimpleEntity(org.whole.lang.models.model.SimpleEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Test(org.junit.Test)

Example 14 with SimpleEntity

use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method createSimpleEntity.

private SimpleEntity createSimpleEntity() {
    SimpleEntity se = ModelsEntityFactory.instance.createSimpleEntity();
    ReflectionFactory.getHistoryManager(se).setHistoryEnabled(true);
    se.getName().setValue("my new simple name");
    se.getTypes().wAdd(ModelsEntityFactory.instance.createSimpleName("T1"));
    se.getFeatures().wAdd(ModelsEntityFactory.instance.createFeature());
    return se;
}
Also used : SimpleEntity(org.whole.lang.models.model.SimpleEntity)

Example 15 with SimpleEntity

use of org.whole.lang.models.model.SimpleEntity in project whole by wholeplatform.

the class HistoryInvariantsTest method testMergeHistory.

@Test
public void testMergeHistory() {
    performChanges(model);
    int size1 = history.getUndoSize();
    SimpleEntity se = createSimpleEntity();
    Assert.assertEquals(size1, history.getUndoSize());
    model.getDeclarations().wAdd(se);
    Assert.assertEquals(size1 + 1, history.getUndoSize());
    size1 = history.getUndoSize();
    se = createSimpleEntity();
    se.wGetModel().getCompoundModel().setHistoryManager(history, false);
    Assert.assertEquals(size1, history.getUndoSize());
    model.getDeclarations().wAdd(se);
    Assert.assertEquals(size1 + 1, history.getUndoSize());
    size1 = history.getUndoSize();
    se = createSimpleEntity();
    se.wGetModel().getCompoundModel().setHistoryManager(history, true);
    Assert.assertEquals(size1 + 1, history.getUndoSize());
    model.getDeclarations().wAdd(se);
    Assert.assertEquals(size1 + 2, history.getUndoSize());
    size1 = history.getUndoSize();
    se = createSimpleEntity();
    history.mergeHistory(ReflectionFactory.getHistoryManager(se));
    Assert.assertEquals(size1 + 1, history.getUndoSize());
    model.getDeclarations().wAdd(se);
    Assert.assertEquals(size1 + 2, history.getUndoSize());
}
Also used : SimpleEntity(org.whole.lang.models.model.SimpleEntity) Test(org.junit.Test)

Aggregations

SimpleEntity (org.whole.lang.models.model.SimpleEntity)29 Test (org.junit.Test)22 IEntity (org.whole.lang.model.IEntity)14 Model (org.whole.lang.models.model.Model)13 PathExpression (org.whole.lang.queries.model.PathExpression)13 ITemplateManager (org.whole.lang.templates.ITemplateManager)13 XmlModel (org.whole.lang.models.codebase.XmlModel)12 IBindingManager (org.whole.lang.bindings.IBindingManager)9 ModelsModel (org.whole.lang.models.codebase.ModelsModel)7 ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)7 CompositeEntity (org.whole.lang.models.model.CompositeEntity)6 DataEntity (org.whole.lang.models.model.DataEntity)5 EnumEntity (org.whole.lang.models.model.EnumEntity)5 Feature (org.whole.lang.models.model.Feature)5 Features (org.whole.lang.models.model.Features)5 EnumValues (org.whole.lang.models.model.EnumValues)3 Document (org.whole.lang.text.model.Document)3 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)2 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)2 ArrayList (java.util.ArrayList)1