use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class ModelFragmentsBuilderTest method testModelFeaturesBuilderWithFeatureEvents.
@Test
public void testModelFeaturesBuilderWithFeatureEvents() {
ITemplateFactory<Model> modelsModel = new ModelsModelWithFeatureEvents();
Features features = ModelsEntityFactory.instance.createFeatures(0);
modelsModel.apply(new SpecificBuilderAdapterOperation(new ModelFeaturesBuilder(features)));
int count = 0;
Model model = modelsModel.create();
AbstractPatternFilterIterator<Feature> i = IteratorFactory.<Feature>descendantOrSelfMatcherIterator().withPattern(ModelsEntityDescriptorEnum.Feature);
i.reset(model);
for (Feature feature : i) if (EntityUtils.isNotResolver(feature))
count++;
assertEquals(features.wSize(), count);
}
use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class ModelFragmentsBuilderTest method testModelFeaturesBuilder.
@Test
public void testModelFeaturesBuilder() {
ITemplateFactory<Model> modelsModel = new ModelsModel();
final Features features = ModelsEntityFactory.instance.createFeatures(0);
modelsModel.apply(new SpecificBuilderAdapterOperation(new ModelFeaturesBuilder(features)));
int count = 0;
Model model = modelsModel.create();
AbstractPatternFilterIterator<Feature> i = IteratorFactory.<Feature>descendantOrSelfMatcherIterator().withPattern(ModelsEntityDescriptorEnum.Feature);
i.reset(model);
for (Feature feature : i) if (EntityUtils.isNotResolver(feature))
count++;
assertEquals(features.wSize(), count);
}
use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class PersistenceTest method testSingleBuilder2Xml.
@Test
public void testSingleBuilder2Xml() {
ModelBuilderOperation op = new ModelBuilderOperation();
new ModelsModel().apply(new XmlStoreProducerBuilderOperation(op));
IEntity xmlModel = op.wGetResult();
PrettyPrinterOperation.prettyPrint(xmlModel);
}
use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class ControlQueriesTest method testChoose4.
@Test
public void testChoose4() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("choose4");
int i = 0;
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model, bm);
while (iterator.hasNext()) {
IEntity result = iterator.next();
assertSame(result, bm.wGet("type"));
assertTrue(result instanceof ClassDeclaration);
ClassDeclaration classDecl = (ClassDeclaration) result;
IEntity decl = decls.wGet(i++);
String name = "", superClassName = "";
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
SimpleEntity simpleEntity = (SimpleEntity) decl;
name = simpleEntity.getName().wStringValue();
superClassName = "AbstractSimpleEntity";
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
CompositeEntity compositeEntity = (CompositeEntity) decl;
name = compositeEntity.getName().wStringValue();
superClassName = "AbstractCompositeEntity";
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
DataEntity dataEntity = (DataEntity) decl;
name = dataEntity.getName().wStringValue();
superClassName = "AbstractDataEntity";
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
EnumEntity enumEntity = (EnumEntity) decl;
name = enumEntity.getName().wStringValue();
superClassName = "AbstractEnumEntity";
break;
}
assertEquals(name, classDecl.getName().wStringValue());
assertEquals(superClassName, classDecl.getSuperclassType().wStringValue());
}
}
use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class ControlQueriesTest method testChoose3.
@Test
public void testChoose3() {
Model model = new ModelsModel().create();
ModelDeclarations decls = model.getDeclarations();
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("choose3");
int i = 0;
IEntityIterator<IEntity> iterator = BehaviorUtils.compileAndLazyEvaluate(query, model);
while (iterator.hasNext()) {
IEntity result = iterator.next();
IEntity decl = decls.wGet(i++);
switch(decl.wGetEntityOrd()) {
case ModelsEntityDescriptorEnum.SimpleEntity_ord:
Features features = ((SimpleEntity) decl).getFeatures();
if (!features.isEmpty())
assertEquals(features.get(0).getName().wStringValue(), result.wStringValue());
break;
case ModelsEntityDescriptorEnum.CompositeEntity_ord:
CompositeEntity compositeEntity = (CompositeEntity) decl;
assertEquals(compositeEntity.getComponentType().wStringValue(), result.wStringValue());
break;
case ModelsEntityDescriptorEnum.DataEntity_ord:
DataEntity dataEntity = (DataEntity) decl;
assertEquals(dataEntity.getDataType().wStringValue(), result.wStringValue());
break;
case ModelsEntityDescriptorEnum.EnumEntity_ord:
EnumEntity enumEntity = (EnumEntity) decl;
assertEquals(enumEntity.getValues().wGet(0).wStringValue(), result.wStringValue());
break;
}
}
}
Aggregations