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