use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SQLInterpreterTest method testMapAuthorsQueryWithNestedVar.
@Test
public void testMapAuthorsQueryWithNestedVar() {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("connection", connection);
bm.wDefValue("generateDropStatements", false);
Database database = new SampleDatabase().create();
InterpreterOperation.interpret(database, bm);
IEntity e = DBMappingTemplateManager.instance().create("populateDB");
InterpreterOperation.interpret(e, bm);
IEntity map = DBMappingTemplateManager.instance().create("mapAuthorsQueryWithNestedVar");
IEntity results = DBMappingTemplateManager.instance().create("mapAuthorsResults");
int index = 0;
for (IEntity result : DynamicCompilerOperation.compile(map, bm).getResultIterator()) {
IEntity expectedResult = results.wGet(index++).wGet(0);
assertTrue(Matcher.match(expectedResult, result));
}
assertEquals(1, index);
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SQLInterpreterTest method testMapAuthorsQuery.
@Test
public void testMapAuthorsQuery() {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("connection", connection);
bm.wDefValue("generateDropStatements", false);
Database database = new SampleDatabase().create();
InterpreterOperation.interpret(database, bm);
IEntity e = DBMappingTemplateManager.instance().create("populateDB");
InterpreterOperation.interpret(e, bm);
IEntity map = DBMappingTemplateManager.instance().create("mapAuthorsQuery");
IEntity results = DBMappingTemplateManager.instance().create("mapAuthorsResults");
int index = 0;
for (IEntity result : DynamicCompilerOperation.compile(map, bm).getResultIterator()) {
IEntity expectedResult = results.wGet(index++).wGet(0);
assertTrue(Matcher.match(expectedResult, result));
}
assertEquals(results.wSize(), index);
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SQLInterpreterTest method testDataTypes.
@Test
public void testDataTypes() {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("connection", connection);
bm.wDefValue("generateDropStatements", false);
Database database = new AllTypesDatabase().create();
InterpreterOperation.interpret(database, bm);
IEntity e = DBMappingTemplateManager.instance().create("populateDatatypesDB");
InterpreterOperation.interpret(e, bm);
IEntity map = DBMappingTemplateManager.instance().create("selectDatatypesDB");
IEntity results = DBMappingTemplateManager.instance().create("selectDatatypesDBResults");
IEntityIterator<IEntity> resultsIterator = DynamicCompilerOperation.compile(results, bm).getResultIterator();
for (IEntity result : DynamicCompilerOperation.compile(map, bm).getResultIterator()) {
assertTrue(resultsIterator.hasNext());
IEntity expectedResult = resultsIterator.next();
assertEquals(expectedResult.wSize(), result.wSize());
for (int i = 0; i < expectedResult.wSize(); i++) {
IEntity expectedValue = expectedResult.wGet(i);
IEntity actualValue = result.wGet(i);
switch(expectedValue.wGetEntityOrd()) {
case SQLEntityDescriptorEnum.ArrayValue_ord:
case SQLEntityDescriptorEnum.BinaryValue_ord:
Object a1 = expectedValue.wGetValue();
Object a2 = actualValue.wGetValue();
assertTrue(a1.getClass().isArray());
assertTrue(a2.getClass().isArray());
int length = Array.getLength(a1);
assertEquals(length, Array.getLength(a2));
for (int j = 0; j < length; j++) assertEquals(Array.get(a1, j), Array.get(a2, j));
break;
default:
assertTrue(Matcher.match(expectedValue, actualValue));
}
}
}
assertFalse(resultsIterator.hasNext());
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class SQLInterpreterTest method testMapAuthorsQuery3.
@Test
public void testMapAuthorsQuery3() {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("connection", connection);
bm.wDefValue("generateDropStatements", false);
Database database = new SampleDatabase().create();
InterpreterOperation.interpret(database, bm);
IEntity e = DBMappingTemplateManager.instance().create("populateDB");
InterpreterOperation.interpret(e, bm);
IEntity map = DBMappingTemplateManager.instance().create("mapAuthorsQuery3");
IEntity results = DBMappingTemplateManager.instance().create("mapAuthorsResults");
int index = 0;
for (IEntity result : DynamicCompilerOperation.compile(map, bm).getResultIterator()) {
IEntity expectedResult = results.wGet(index++).wGet(0);
assertTrue(Matcher.match(expectedResult, result));
}
assertEquals(results.wSize(), index);
}
use of org.whole.lang.bindings.IBindingManager in project whole by wholeplatform.
the class XsiModelTemplateTest method testXsiModelTemplate.
@Category({ KnownFailingTests.class, SlowTests.class })
@Test
public void testXsiModelTemplate() throws Exception {
fail();
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/templates").getAbsolutePath());
bm.wDefValue("packageName", "");
XsdDeployStrategies.setDeployStrategy(bm, XsdDeployStrategies.ALL);
String fileName = "S202SCTDIRPFRAA0001.C.xml";
IEntity xsiModel = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
CommonsEntityFactory.instance.createRootFragment(xsiModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
IEntity xmlModel = XmlSourcePersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream(fileName), null, bm));
CommonsEntityFactory.instance.createRootFragment(xmlModel.wGetAdapter(CommonsEntityDescriptorEnum.Any));
ModelBuilderOperation mop = new ModelBuilderOperation();
XmlNormalizerBuilderOperation xnbo = new XmlNormalizerBuilderOperation(mop);
XsiModelTemplate xsiModelTemplate = new XsiModelTemplate(xsiModel);
xsiModelTemplate.apply(xnbo);
IEntity xmlModelFromXsiModel = mop.wGetResult();
Assert.assertTrue(Matcher.match(xmlModelFromXsiModel, xmlModel));
}
Aggregations