Dao { @CheckResult protected Observable<Long> insert(final String table, final ContentValues contentValues) { return Observable.defer(new Func0<Observable<Long>>() { @Override public Observable<Long> call() { return Observable.just(db.insert(table, contentValues)); } }); }  abstract void createTable(SQLiteDatabase database); abstract void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); Transaction newTransaction();  }
@Test public void testDao() throws Exception { for (int i = 0; i < 10; i++) { String name = "Name" + i; int age = i; double weight = i + 10 / 3; byte[] blob = Integer.toString(i).getBytes("UTF-8"); User u = userDao.insert(name, age, weight, blob); assertEquals(name, u.name); assertEquals(age, u.age); assertEquals(weight, u.weight, 0.1); assertEquals(blob, u.blob); User qUser = userDao.getById(u.id); assertEquals(qUser.age, u.age); assertArrayEquals(qUser.blob, u.blob); assertEquals(qUser.id, u.id); assertEquals(qUser.name, u.name); assertEquals(qUser.weight, u.weight, 0.1); } }