Search in sources :

Example 16 with Feature

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

the class ControlQueriesTest method testChoose1.

@Test
public void testChoose1() {
    Model model = new ModelsModel().create();
    ModelDeclarations decls = model.getDeclarations();
    ITemplateManager tm = ControlQueriesTemplateManager.instance();
    PathExpression query = (PathExpression) tm.create("choose1");
    assertFalse(BehaviorUtils.compileAndLazyEvaluate(query, model).hasNext());
    int i = 0;
    while (!Matcher.match(ModelsEntityDescriptorEnum.SimpleEntity, decls.wGet(i))) i++;
    SimpleEntity simpleEntity = (SimpleEntity) decls.wGet(i);
    int j = 0;
    for (IEntity name : BehaviorUtils.compileAndLazyEvaluate(query, simpleEntity)) {
        assertEquals(((Feature) simpleEntity.getFeatures().wGet(j++)).getName().wStringValue(), name.wStringValue());
    }
    assertEquals(simpleEntity.getFeatures().wSize(), j);
    while (!Matcher.match(ModelsEntityDescriptorEnum.CompositeEntity, decls.wGet(i))) i++;
    CompositeEntity compositeEntity = (CompositeEntity) decls.wGet(i);
    IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, compositeEntity);
    assertTrue(iterator.hasNext());
    assertEquals(compositeEntity.getComponentType().wStringValue(), iterator.next().wStringValue());
    assertFalse(iterator.hasNext());
    while (!Matcher.match(ModelsEntityDescriptorEnum.EnumEntity, decls.wGet(i))) i++;
    EnumEntity enumEntity = (EnumEntity) decls.wGet(i);
    iterator = BehaviorUtils.compileAndLazyEvaluate(query, enumEntity);
    assertTrue(iterator.hasNext());
    assertTrue(iterator.next() instanceof EnumValues);
    assertFalse(iterator.hasNext());
}
Also used : EnumEntity(org.whole.lang.models.model.EnumEntity) IEntity(org.whole.lang.model.IEntity) SimpleEntity(org.whole.lang.models.model.SimpleEntity) ITemplateManager(org.whole.lang.templates.ITemplateManager) Feature(org.whole.lang.models.model.Feature) EnumValues(org.whole.lang.models.model.EnumValues) ModelDeclarations(org.whole.lang.models.model.ModelDeclarations) PathExpression(org.whole.lang.queries.model.PathExpression) XmlModel(org.whole.lang.models.codebase.XmlModel) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Model(org.whole.lang.models.model.Model) CompositeEntity(org.whole.lang.models.model.CompositeEntity) ModelsModel(org.whole.lang.models.codebase.ModelsModel) Test(org.junit.Test)

Example 17 with Feature

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

the class MatcherTest method testRename.

@Test
public void testRename() {
    Feature featurePattern = new FeaturePattern().create();
    Variable var = (Variable) featurePattern.getType().wGetAdaptee(false);
    assertEquals("featureType", var.getVarName().getValue());
    Matcher.rename(featurePattern, "featureType", "fType", false);
    assertEquals("fType", var.getVarName().getValue());
}
Also used : Variable(org.whole.lang.commons.model.Variable) Feature(org.whole.lang.models.model.Feature) Test(org.junit.Test)

Example 18 with Feature

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

the class FeatureRowPart method getModelSpecificChildren.

@Override
protected List<IEntity> getModelSpecificChildren() {
    Feature entity = getModelEntity();
    List<IEntity> children = new ArrayList<IEntity>(4);
    children.add(entity.getModifiers());
    children.add(entity.getName());
    children.add(entity.getOppositeName());
    children.add(entity.getType());
    return children;
}
Also used : IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) Feature(org.whole.lang.models.model.Feature)

Aggregations

Feature (org.whole.lang.models.model.Feature)18 Test (org.junit.Test)13 IEntity (org.whole.lang.model.IEntity)9 PathExpression (org.whole.lang.queries.model.PathExpression)9 ITemplateManager (org.whole.lang.templates.ITemplateManager)9 Model (org.whole.lang.models.model.Model)8 XmlModel (org.whole.lang.models.codebase.XmlModel)6 FieldDeclaration (org.whole.lang.java.model.FieldDeclaration)5 SimpleEntity (org.whole.lang.models.model.SimpleEntity)5 IBindingManager (org.whole.lang.bindings.IBindingManager)4 ModelsModel (org.whole.lang.models.codebase.ModelsModel)4 Grammar (org.whole.lang.grammars.model.Grammar)3 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)3 Features (org.whole.lang.models.model.Features)3 ModelFeaturesBuilder (org.whole.lang.builders.builder.ModelFeaturesBuilder)2 Variable (org.whole.lang.commons.model.Variable)2 As (org.whole.lang.grammars.model.As)2 CompositeEntity (org.whole.lang.models.model.CompositeEntity)2 EnumEntity (org.whole.lang.models.model.EnumEntity)2 EnumValues (org.whole.lang.models.model.EnumValues)2