Search in sources :

Example 11 with ModelDeclarations

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

the class RewriteQueriesTest method testUpdate8.

@Test
public void testUpdate8() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("update8");
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.DataEntity, entity));
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl)) {
            assertEquals("Object", ((DataEntity) decl).getDataType().getValue());
            assertTrue(((DataEntity) decl).getName().getValue().startsWith("My"));
        }
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) DataEntity(org.whole.lang.models.model.DataEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Example 12 with ModelDeclarations

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

the class ResolversTest method testSimpleEntityResolverTighteningByIndex.

@Test
public void testSimpleEntityResolverTighteningByIndex() {
    ModelDeclaration modelDeclaration = createResolver(ModelsEntityDescriptorEnum.ModelDeclaration);
    ModelDeclarations modelDeclarations = mf.createModelDeclarations(modelDeclaration);
    int index = ModelsEntityDescriptorEnum.ModelDeclaration.indexOf(ModelsFeatureDescriptorEnum.name);
    try {
        modelDeclaration.wSet(index, mf.createSimpleName("testName"));
        Assert.fail();
    } catch (IllegalArgumentException e) {
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) ModelDeclaration(org.whole.lang.models.model.ModelDeclaration) Test(org.junit.Test)

Example 13 with ModelDeclarations

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

the class ResolversTest method testSimpleEntityResolverTighteningByFD.

@Test
public void testSimpleEntityResolverTighteningByFD() {
    ModelDeclaration modelDeclaration = createResolver(ModelsEntityDescriptorEnum.ModelDeclaration);
    ModelDeclarations modelDeclarations = mf.createModelDeclarations(modelDeclaration);
    modelDeclaration.wSet(ModelsFeatureDescriptorEnum.name, mf.createSimpleName("testName"));
    Assert.assertTrue(EntityUtils.isResolver(modelDeclaration));
    modelDeclaration.wSet(ModelsFeatureDescriptorEnum.componentType, mf.createSimpleName("testTypeName"));
    Assert.assertTrue(Matcher.matchImpl(ModelsEntityDescriptorEnum.CompositeEntity, modelDeclarations.wGet(0)));
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) ModelDeclaration(org.whole.lang.models.model.ModelDeclaration) Test(org.junit.Test)

Example 14 with ModelDeclarations

use of org.whole.lang.models.model.ModelDeclarations 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);
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) 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 ModelDeclarations

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

the class RewriteQueriesTest method testInsert1.

@Test
public void testInsert1() {
    Model model = new ModelsModel().create();
    ModelDeclarations declarations = model.getDeclarations();
    ITemplateManager tm = RewriteQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("insert1");
    for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.Feature, entity));
    for (int i = 0; i < declarations.wSize(); i++) {
        IEntity decl = declarations.wGet(i);
        if (Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decl)) {
            Features features = ((SimpleEntity) decl).getFeatures();
            int size = features.wSize();
            assertTrue(size >= 2);
            String name1 = ((Feature) features.wGet(size - 2)).getName().getValue();
            assertEquals("n1", name1);
            String name2 = ((Feature) features.wGet(size - 1)).getName().getValue();
            assertEquals("n2", name2);
        }
    }
}
Also used : ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) ITemplateManager(org.whole.lang.templates.ITemplateManager) Features(org.whole.lang.models.model.Features) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Aggregations

ModelDeclarations (org.whole.lang.models.model.ModelDeclarations)22 Test (org.junit.Test)21 IEntity (org.whole.lang.model.IEntity)19 Model (org.whole.lang.models.model.Model)19 ModelsModel (org.whole.lang.models.codebase.ModelsModel)18 PathExpression (org.whole.lang.queries.model.PathExpression)18 ITemplateManager (org.whole.lang.templates.ITemplateManager)18 DataEntity (org.whole.lang.models.model.DataEntity)9 XmlModel (org.whole.lang.models.codebase.XmlModel)7 SimpleEntity (org.whole.lang.models.model.SimpleEntity)7 CompositeEntity (org.whole.lang.models.model.CompositeEntity)5 EnumEntity (org.whole.lang.models.model.EnumEntity)4 ArrayList (java.util.ArrayList)3 Features (org.whole.lang.models.model.Features)3 IBindingManager (org.whole.lang.bindings.IBindingManager)2 EnumValues (org.whole.lang.models.model.EnumValues)2 Feature (org.whole.lang.models.model.Feature)2 ModelDeclaration (org.whole.lang.models.model.ModelDeclaration)2 ClassDeclaration (org.whole.lang.java.model.ClassDeclaration)1 ModelsEntityFactory (org.whole.lang.models.factories.ModelsEntityFactory)1