DbAdapter implements StorageService { public void deleteTable(Table table) { try { final SQLiteDatabase db = mDb.getWritableDatabase(); String deleteParams=KEY_TABLE+"=?"; db.delete(TABLES_TABLE, deleteParams, new String[]{table.name}); } catch (final SQLiteException e) { Logger.log(TAG, "Failed to delete table:" + table.name, Logger.SDK_DEBUG); mDb.delete(); } finally { mDb.close(); } } DbAdapter(Context context); static DbAdapter getInstance(Context context); int addEvent(Table table, String data); int count(Table table); Batch getEvents(Table table, int limit); List<Table> getTables(); int deleteEvents(Table table, String lastId); void deleteTable(Table table); void vacuum(); static final String KEY_DATA; static final String KEY_TOKEN; static final String KEY_TABLE; static final String KEY_CREATED_AT; static final String TABLES_TABLE; static final String REPORTS_TABLE; }
@Test public void deleteTable() { SQLiteDatabase db = mock(SQLiteDatabase.class); when(handler.getWritableDatabase()).thenReturn(db); adapter.deleteTable(table); verify(db, times(1)).delete(eq(DbAdapter.TABLES_TABLE), anyString(), any(String[].class)); }