Search in sources :

Example 1 with Transaction

use of sqlite.feature.foreignKey.BindDummyDataSource.Transaction in project kripton by xcesco.

the class TestForeignKeyARuntime method testRunSqlite2.

@Test
public void testRunSqlite2() throws IOException, InstantiationException, IllegalAccessException {
    BindDummyDataSource dataSource = BindDummyDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
            DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
            BeanA_2 beanParent = new BeanA_2();
            beanParent.valueString2 = "parent";
            daoFactory.getDaoBeanA_2().insert(beanParent);
            BeanA_1 bean = new BeanA_1();
            bean.valueString = "hello";
            bean.beanA2Id = beanParent.id;
            dao.insert(bean);
            assertEquals(1, bean.id);
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.foreignKey.BindDummyDataSource.Transaction) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 2 with Transaction

use of sqlite.feature.foreignKey.BindDummyDataSource.Transaction in project kripton by xcesco.

the class TestForeignKeyARuntime method testRunSqlite1.

@Test
public void testRunSqlite1() throws IOException, InstantiationException, IllegalAccessException {
    BindDummyDataSource dataSource = BindDummyDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
            DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
            BeanA_2 beanParent = new BeanA_2();
            beanParent.valueString2 = "parent";
            daoFactory.getDaoBeanA_2().insert(beanParent);
            BeanA_1 bean = new BeanA_1();
            bean.valueString = "hello";
            bean.beanA2Id = beanParent.id;
            dao.insert(bean);
            assertEquals(1, bean.id);
            List<BeanA_1> list = dao.selectById(bean.id);
            Assert.assertEquals("not one ", 1, list.size());
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.foreignKey.BindDummyDataSource.Transaction) List(java.util.List) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 3 with Transaction

use of sqlite.feature.foreignKey.BindDummyDataSource.Transaction in project kripton by xcesco.

the class TestForeignKeyARuntime method testRunSqlite3.

@Test
public void testRunSqlite3() throws IOException, InstantiationException, IllegalAccessException {
    BindDummyDataSource dataSource = BindDummyDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
            DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
            BeanA_2 beanParent = new BeanA_2();
            beanParent.valueString2 = "parent";
            daoFactory.getDaoBeanA_2().insert(beanParent);
            BeanA_1 bean = new BeanA_1();
            bean.valueString = "hello";
            bean.beanA2Id = beanParent.id;
            dao.insert(bean);
            assertEquals(1, bean.id);
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.foreignKey.BindDummyDataSource.Transaction) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 4 with Transaction

use of sqlite.feature.foreignKey.BindDummyDataSource.Transaction in project kripton by xcesco.

the class TestForeignKeyARuntime method testRunSqlite4.

@Test
public void testRunSqlite4() throws IOException, InstantiationException, IllegalAccessException {
    BindDummyDataSource dataSource = BindDummyDataSource.instance();
    dataSource.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindDummyDaoFactory daoFactory) {
            DaoBeanA_1Impl dao = daoFactory.getDaoBeanA_1();
            BeanA_2 beanParent = new BeanA_2();
            beanParent.valueString2 = "parent";
            daoFactory.getDaoBeanA_2().insert(beanParent);
            BeanA_1 bean = new BeanA_1();
            bean.valueString = "hello";
            bean.beanA2Id = beanParent.id;
            dao.insert(bean);
            assertEquals(1, bean.id);
            return TransactionResult.COMMIT;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Transaction(sqlite.feature.foreignKey.BindDummyDataSource.Transaction) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)4 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)4 Test (org.junit.Test)4 Transaction (sqlite.feature.foreignKey.BindDummyDataSource.Transaction)4 List (java.util.List)1