Search in sources :

Example 16 with TransactionResult

use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.

the class TestRx method testRunSyncWithListener.

@Test
public void testRunSyncWithListener() {
    BindXenoDataSource dataSource = BindXenoDataSource.instance();
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            CountryDaoImpl dao = daoFactory.getCountryDao();
            for (int i = 0; i < COUNTER; i++) {
                Country bean = new Country();
                bean.code = "code" + i;
                bean.callingCode = "" + i;
                bean.name = "name" + i;
                // Object bean = new
                dao.insert(bean);
            }
            dao.selectAll();
            return TransactionResult.COMMIT;
        }
    });
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            System.out.println("onSubscribe");
            CountryDaoImpl dao = daoFactory.getCountryDao();
            dao.selectAll(new OnReadBeanListener<Country>() {

                @Override
                public void onRead(Country bean, int row, int rowCount) {
                    System.out.println("onNext" + bean);
                }
            });
            System.out.println("onComplete");
            return TransactionResult.COMMIT;
        }
    });
}
Also used : CountryDaoImpl(sqlite.feature.rx.persistence.CountryDaoImpl) BindXenoDataSource(sqlite.feature.rx.persistence.BindXenoDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) OnReadBeanListener(com.abubusoft.kripton.android.sqlite.OnReadBeanListener) Country(sqlite.feature.rx.model.Country) BindXenoDaoFactory(sqlite.feature.rx.persistence.BindXenoDaoFactory) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 17 with TransactionResult

use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.

the class Test209Model1Runtime method testRunSqlite1.

@Test
public void testRunSqlite1() {
    BindApp1DataSource ds = BindApp1DataSource.instance();
    ds.execute(new Transaction() {

        @Override
        public TransactionResult onExecute(BindApp1DaoFactory daoFactory) {
            Device device = new Device();
            device.name = "device-test";
            daoFactory.getDeviceDao().insert(device);
            User user = new User();
            user.userName = "user-test";
            daoFactory.getUserDao().insert(user);
            UserDevice userDevice = new UserDevice();
            userDevice.deviceId = device.id;
            userDevice.userId = user.id;
            daoFactory.getUserDeviceDao().insert(userDevice);
            List<Device> devices = daoFactory.getDeviceDao().getUserDevices(user.id);
            Assert.assertTrue(devices.size() == 1);
            return TransactionResult.ROLLBACK;
        }
    });
}
Also used : TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) User(sqlite.kripton209.model1.User) Transaction(sqlite.kripton209.model1.BindApp1DataSource.Transaction) BindApp1DataSource(sqlite.kripton209.model1.BindApp1DataSource) BindApp1DaoFactory(sqlite.kripton209.model1.BindApp1DaoFactory) UserDevice(sqlite.kripton209.model1.UserDevice) Device(sqlite.kripton209.model1.Device) List(java.util.List) UserDevice(sqlite.kripton209.model1.UserDevice) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 18 with TransactionResult

use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.

the class TestKripton180Runtime method testRun.

@Test
public void testRun() {
    final Employee bean = new Employee();
    bean.birthDate = new java.sql.Date((new java.util.Date()).getTime());
    bean.fieldBoolean = "true";
    bean.fieldByte = "42";
    bean.fieldByteArray = "42";
    bean.fieldCharacter = "a";
    bean.fieldDouble = "120";
    bean.fieldFloat = "120";
    bean.fieldInteger = "11";
    bean.fieldLong = "13";
    bean.fieldShort = "2";
    bean.fieldString = "a";
    bean.hireDate = new java.sql.Date((new java.util.Date()).getTime());
    BindKripton180BeanDataSource dataSource = BindKripton180BeanDataSource.instance();
    dataSource.execute(new BindKripton180BeanDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindKripton180BeanDaoFactory daoFactory) {
            EmployeeBeanDaoImpl dao = daoFactory.getEmployeeBeanDao();
            dao.insert(bean);
            Assert.assertTrue(bean.id > 0);
            Employee readResult = dao.selectById(bean);
            Assert.assertTrue(readResult.fieldBoolean.equals(bean.fieldBoolean));
            Assert.assertTrue(readResult.birthDate.toString().equals(bean.birthDate.toString()));
            dao.update(bean);
            readResult = dao.selectById(bean);
            Assert.assertTrue(Double.valueOf(readResult.fieldDouble).equals(Double.valueOf(bean.fieldDouble)));
            Assert.assertTrue(readResult.fieldString.equals(bean.fieldString));
            long result = dao.deleteById(bean);
            Assert.assertTrue(result == 1);
            return TransactionResult.ROLLBACK;
        }
    });
}
Also used : BindKripton180BeanDataSource(sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) BindKripton180BeanDaoFactory(sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory) EmployeeBeanDaoImpl(sqlite.feature.typeadapter.kripton180.bean.EmployeeBeanDaoImpl) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 19 with TransactionResult

use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.

the class TestKripton180Runtime method testRunJQL.

@Test
public void testRunJQL() {
    final Employee bean = new Employee();
    bean.birthDate = new java.sql.Date((new java.util.Date()).getTime());
    bean.fieldBoolean = "true";
    bean.fieldByte = "42";
    bean.fieldByteArray = "42";
    bean.fieldCharacter = "a";
    bean.fieldDouble = "120";
    bean.fieldFloat = "120";
    bean.fieldInteger = "11";
    bean.fieldLong = "13";
    bean.fieldShort = "2";
    bean.fieldString = "a";
    bean.hireDate = new java.sql.Date((new java.util.Date()).getTime());
    BindKripton180BeanDataSource dataSource = BindKripton180BeanDataSource.instance();
    dataSource.execute(new BindKripton180BeanDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindKripton180BeanDaoFactory daoFactory) {
            EmployeeBeanDaoImpl dao = daoFactory.getEmployeeBeanDao();
            dao.insertJQL(bean);
            Assert.assertTrue(bean.id > 0);
            Employee readResult = dao.selectByIdJQL(bean);
            Assert.assertTrue(readResult.fieldBoolean.equals(bean.fieldBoolean));
            Assert.assertTrue(readResult.fieldLong.toString().equals(bean.fieldLong.toString()));
            dao.update(bean);
            readResult = dao.selectByIdJQL(bean);
            Assert.assertTrue(Double.valueOf(readResult.fieldDouble).equals(Double.valueOf(bean.fieldDouble)));
            Assert.assertTrue(readResult.fieldString.equals(bean.fieldString));
            long result = dao.deleteById(bean);
            Assert.assertTrue(result == 1);
            return TransactionResult.ROLLBACK;
        }
    });
}
Also used : BindKripton180BeanDataSource(sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) BindKripton180BeanDaoFactory(sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory) EmployeeBeanDaoImpl(sqlite.feature.typeadapter.kripton180.bean.EmployeeBeanDaoImpl) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 20 with TransactionResult

use of com.abubusoft.kripton.android.sqlite.TransactionResult in project kripton by xcesco.

the class TestRx method testRunSync.

@Test
public void testRunSync() {
    BindXenoDataSource dataSource = BindXenoDataSource.instance();
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            CountryDaoImpl dao = daoFactory.getCountryDao();
            for (int i = 0; i < COUNTER; i++) {
                Country bean = new Country();
                bean.code = "code" + i;
                bean.callingCode = "" + i;
                bean.name = "name" + i;
                // Object bean = new
                dao.insert(bean);
            }
            dao.selectAll();
            return TransactionResult.COMMIT;
        }
    });
    dataSource.execute(new BindXenoDataSource.Transaction() {

        @Override
        public TransactionResult onExecute(BindXenoDaoFactory daoFactory) {
            System.out.println("onSubscribe");
            CountryDaoImpl dao = daoFactory.getCountryDao();
            List<Country> list = dao.selectAll();
            for (Country item : list) {
                System.out.println("onNext" + item);
            }
            System.out.println("onComplete");
            return TransactionResult.COMMIT;
        }
    });
}
Also used : CountryDaoImpl(sqlite.feature.rx.persistence.CountryDaoImpl) BindXenoDataSource(sqlite.feature.rx.persistence.BindXenoDataSource) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) Country(sqlite.feature.rx.model.Country) List(java.util.List) BindXenoDaoFactory(sqlite.feature.rx.persistence.BindXenoDaoFactory) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Aggregations

TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)28 BaseAndroidTest (base.BaseAndroidTest)27 Test (org.junit.Test)27 List (java.util.List)13 Transaction (sqlite.feature.foreignKey.BindDummyDataSource.Transaction)4 One (com.abubusoft.kripton.common.One)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 Country (sqlite.feature.rx.model.Country)3 BindXenoDaoFactory (sqlite.feature.rx.persistence.BindXenoDaoFactory)3 BindXenoDataSource (sqlite.feature.rx.persistence.BindXenoDataSource)3 CountryDaoImpl (sqlite.feature.rx.persistence.CountryDaoImpl)3 Person (sqlite.feature.speed.model.Person)3 BindPersonDaoFactory (sqlite.feature.speed.persistence.BindPersonDaoFactory)3 BindPersonDataSource (sqlite.feature.speed.persistence.BindPersonDataSource)3 Transaction (sqlite.feature.speed.persistence.BindPersonDataSource.Transaction)3 PersonDaoImpl (sqlite.feature.speed.persistence.PersonDaoImpl)3 ArrayList (java.util.ArrayList)2 BindKripton180BeanDaoFactory (sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory)2 BindKripton180BeanDataSource (sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDataSource)2