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;
}
});
}
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;
}
});
}
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;
}
});
}
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;
}
});
}
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;
}
});
}
Aggregations