Search in sources :

Example 1 with Transaction

use of sqlite.kripton84.BindBean84ADataSource.Transaction in project kripton by xcesco.

the class Test84RuntimeA method testRunSqlite.

@Test
public void testRunSqlite() throws IOException, InstantiationException, IllegalAccessException {
    Assert.assertNotNull(Bean84ATable.class.getName() != null);
    Assert.assertNotNull(Bean84ADaoImpl.class.getName() != null);
    BindBean84ADataSource dataSource = BindBean84ADataSource.instance();
    // dataSource.openWritableDatabase();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindBean84ADaoFactory daoFactory) {
            Bean84ADaoImpl dao = daoFactory.getBean84ADao();
            Bean84A bean = new Bean84A();
            bean.valueString = "hello";
            dao.insertAll(bean);
            List<Bean84A> list = dao.selectById(bean.id);
            Assert.assertEquals("not list ", 1, list.size());
            Assert.assertEquals("not map", 1, list.size());
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.kripton84.BindBean84ADataSource.Transaction) List(java.util.List) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 2 with Transaction

use of sqlite.kripton84.BindBean84ADataSource.Transaction in project kripton by xcesco.

the class Test84RuntimeB method testRun.

@Test
public void testRun() throws IOException, InstantiationException, IllegalAccessException {
    Assert.assertNotNull(Bean84BTable.class.getName() != null);
    Assert.assertNotNull(Bean84BDaoImpl.class.getName() != null);
    BindBean84BDataSource dataSource = BindBean84BDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindBean84BDaoFactory daoFactory) {
            Bean84BDaoImpl dao = daoFactory.getBean84BDao();
            Bean84B2 innerBean = new Bean84B2();
            innerBean.columnString = "test01";
            Bean84B bean = new Bean84B();
            bean.columnBean = innerBean;
            dao.insert(bean);
            Bean84B bean2 = dao.selectById(bean.id);
            assertTrue(bean.equals(bean2));
            Bean84B bean3 = dao.selectByBean(innerBean);
            assertTrue(bean.equals(bean3));
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.kripton84.BindBean84BDataSource.Transaction) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)2 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)2 Test (org.junit.Test)2 List (java.util.List)1 Transaction (sqlite.kripton84.BindBean84ADataSource.Transaction)1 Transaction (sqlite.kripton84.BindBean84BDataSource.Transaction)1