use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class RewriteQueriesTest method testUpdate1.
@Test
public void testUpdate1() {
Model model = new ModelsModel().create();
ModelDeclarations declarations = model.getDeclarations();
ITemplateManager tm = RewriteQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("update1");
for (IEntity entity : BehaviorUtils.compileAndLazyEvaluate(query, model)) assertTrue(Matcher.match(ModelsEntityDescriptorEnum.SimpleName, entity) || Matcher.match(ModelsEntityDescriptorEnum.DataType, entity));
assertEquals("MyModelName", model.getName().getValue());
int j = 0;
for (int i = 0; i < declarations.wSize(); i++) {
IEntity decl = declarations.wGet(i);
if (Matcher.match(ModelsEntityDescriptorEnum.DataEntity, decl)) {
if (j++ == 0) {
assertEquals("MyFirstName", ((DataEntity) decl).getName().getValue());
assertEquals("MyFirstDataType", ((DataEntity) decl).getDataType().getValue());
} else {
assertEquals("MySecondName", ((DataEntity) decl).getName().getValue());
return;
}
}
}
}
use of org.whole.lang.models.codebase.ModelsModel 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.codebase.ModelsModel in project whole by wholeplatform.
the class PersistenceTest method testSingleModel2Xml.
@Test
public void testSingleModel2Xml() {
ModelBuilderOperation op = new ModelBuilderOperation();
IEntity model = new ModelsModel().create();
new ModelTemplate(model).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 PersistenceTest method testXMLPersistence.
@Test
public void testXMLPersistence() {
IEntity model1 = new TestEntities().create();
IEntity model2 = xmlRoundtrip(model1);
assertTrue(Matcher.match(model1, model2));
model1 = new ModelsModel().create();
model2 = xmlRoundtrip(model1);
assertTrue(Matcher.match(model1, model2));
model1 = new WholeLanguage().create();
model2 = xmlRoundtrip(model1);
assertTrue(Matcher.match(model1, model2));
}
use of org.whole.lang.models.codebase.ModelsModel in project whole by wholeplatform.
the class PushPullOperationsTest method testModel2PushPullOp.
@Test
public void testModel2PushPullOp() {
IEntity model = new ModelsModel().create();
new ModelTemplate(model).apply(new PrettyPrinterBuilderOperation());
}
Aggregations