Search in sources :

Example 1 with BindKripton180BeanDaoFactory

use of sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory 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 2 with BindKripton180BeanDaoFactory

use of sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory 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)

Aggregations

BaseAndroidTest (base.BaseAndroidTest)2 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)2 Test (org.junit.Test)2 BindKripton180BeanDaoFactory (sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDaoFactory)2 BindKripton180BeanDataSource (sqlite.feature.typeadapter.kripton180.bean.BindKripton180BeanDataSource)2 EmployeeBeanDaoImpl (sqlite.feature.typeadapter.kripton180.bean.EmployeeBeanDaoImpl)2