use of org.whole.lang.rdb.model.Database in project whole by wholeplatform.
the class DBSchemaTemplateFactoryTest method testRDBUtils.
@Category(KnownFailingTests.class)
@Test
public void testRDBUtils() throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
bm.wDefValue("connection", connection);
bm.wDefValue("generateDropStatements", false);
Database database = new SampleDatabase().create();
InterpreterOperation.interpret(database, bm);
DBSchemaTemplateFactory dbSchemaTemplateFactory = new DBSchemaTemplateFactory(connection, "DBNAME", null);
Database generatedDatabase = dbSchemaTemplateFactory.create();
HashMap<EntityDescriptor<?>, Comparator<IEntity>> comparatorsMap = new HashMap<EntityDescriptor<?>, Comparator<IEntity>>();
comparatorsMap.put(RDBEntityDescriptorEnum.Tables, new OrderedMatcher.SimpleFeatureComparator(RDBFeatureDescriptorEnum.name));
Assert.assertTrue(OrderedMatcher.match(database, generatedDatabase, comparatorsMap));
Assert.fail();
}
use of org.whole.lang.rdb.model.Database 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.rdb.model.Database 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.rdb.model.Database 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.rdb.model.Database 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);
}
Aggregations