Search in sources :

Example 1 with Transaction

use of sqlite.kripton209.model1.BindApp1DataSource.Transaction in project kripton by xcesco.

the class Test209Model2Runtime method testRunSqlite1.

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

        @Override
        public TransactionResult onExecute(BindApp2DaoFactory 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 : BindApp2DaoFactory(sqlite.kripton209.model2.BindApp2DaoFactory) TransactionResult(com.abubusoft.kripton.android.sqlite.TransactionResult) User(sqlite.kripton209.model2.User) Transaction(sqlite.kripton209.model2.BindApp2DataSource.Transaction) UserDevice(sqlite.kripton209.model2.UserDevice) Device(sqlite.kripton209.model2.Device) BindApp2DataSource(sqlite.kripton209.model2.BindApp2DataSource) List(java.util.List) UserDevice(sqlite.kripton209.model2.UserDevice) Test(org.junit.Test) BaseAndroidTest(base.BaseAndroidTest)

Example 2 with Transaction

use of sqlite.kripton209.model1.BindApp1DataSource.Transaction 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)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)2 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)2 List (java.util.List)2 Test (org.junit.Test)2 BindApp1DaoFactory (sqlite.kripton209.model1.BindApp1DaoFactory)1 BindApp1DataSource (sqlite.kripton209.model1.BindApp1DataSource)1 Transaction (sqlite.kripton209.model1.BindApp1DataSource.Transaction)1 Device (sqlite.kripton209.model1.Device)1 User (sqlite.kripton209.model1.User)1 UserDevice (sqlite.kripton209.model1.UserDevice)1 BindApp2DaoFactory (sqlite.kripton209.model2.BindApp2DaoFactory)1 BindApp2DataSource (sqlite.kripton209.model2.BindApp2DataSource)1 Transaction (sqlite.kripton209.model2.BindApp2DataSource.Transaction)1 Device (sqlite.kripton209.model2.Device)1 User (sqlite.kripton209.model2.User)1 UserDevice (sqlite.kripton209.model2.UserDevice)1