Search in sources :

Example 1 with SampleDatabase

use of org.whole.lang.rdb.codebase.SampleDatabase 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);
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Database(org.whole.lang.rdb.model.Database) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) Test(org.junit.Test)

Example 2 with SampleDatabase

use of org.whole.lang.rdb.codebase.SampleDatabase 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);
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Database(org.whole.lang.rdb.model.Database) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) Test(org.junit.Test)

Example 3 with SampleDatabase

use of org.whole.lang.rdb.codebase.SampleDatabase 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);
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Database(org.whole.lang.rdb.model.Database) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) Test(org.junit.Test)

Example 4 with SampleDatabase

use of org.whole.lang.rdb.codebase.SampleDatabase in project whole by wholeplatform.

the class SQLInterpreterTest method testMapAuthorsQuery2.

@Test
public void testMapAuthorsQuery2() {
    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("mapAuthorsQuery2");
    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);
}
Also used : IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) Database(org.whole.lang.rdb.model.Database) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) SampleDatabase(org.whole.lang.rdb.codebase.SampleDatabase) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 IBindingManager (org.whole.lang.bindings.IBindingManager)4 IEntity (org.whole.lang.model.IEntity)4 SampleDatabase (org.whole.lang.rdb.codebase.SampleDatabase)4 Database (org.whole.lang.rdb.model.Database)4