public void testInsertWithDefaultValues() { // insert into things default values; Insert insert = Insert.into(Thing.TABLE).defaultValues(); CompiledStatement compiled = insert.compile(); verifyCompiledSqlArgs(compiled, 0); int rowsBeforeInsert = dao.count(Thing.class, Criterion.all); assertEquals(3, dao.insert(insert)); int rowsAfterInsert = dao.count(Thing.class, Criterion.all); assertEquals(rowsBeforeInsert + 1, rowsAfterInsert); // get the newest Thing newThing = null; SquidCursor<Thing> cursor = null; try { cursor = dao.query( Thing.class, Query.select(Thing.PROPERTIES).orderBy(Order.desc(Thing.ID)).limit(1)); if (cursor.moveToFirst()) { newThing = new Thing(cursor); } } finally { if (cursor != null) { cursor.close(); } } assertNotNull(newThing); assertEquals(Thing.DEFAULT_FOO, newThing.getFoo()); assertEquals(Thing.DEFAULT_BAR, newThing.getBar().intValue()); assertEquals(Thing.DEFAULT_IS_ALIVE, newThing.isAlive().booleanValue()); }
private void testRecyclerAdapterInternal(LongProperty idProperty, RecyclerAdapterTest test) { Query query = Query.select(TestModel.PROPERTIES).orderBy(TestModel.BIRTHDAY.asc()).limit(2); if (idProperty != null) { query.selectMore(idProperty); } SquidCursor<TestModel> cursor = database.query(TestModel.class, query); TestRecyclerAdapter adapter = new TestRecyclerAdapter(idProperty); adapter.changeCursor(cursor); try { test.testRecyclerAdapter(adapter); } finally { cursor.close(); } }
public ArrayList<LibraryAdapter.Language> getFilteredLanguages() { SquidCursor<NetworkLanguageDatabaseEntity> languageCursor = mDb.query(NetworkLanguageDatabaseEntity.class, Query.select()); ArrayList<LibraryAdapter.Language> result = new ArrayList<>(); try { while (languageCursor.moveToNext()) { result.add( new LibraryAdapter.Language( languageCursor.get(NetworkLanguageDatabaseEntity.LANGUAGE_I_S_O_3), languageCursor.get(NetworkLanguageDatabaseEntity.ENABLED))); } } finally { languageCursor.close(); } return result; }