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());
}
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());
}
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;
}
Aggregations