### Question:
BreakpointSQLiteHelper extends SQLiteOpenHelper { public List<Integer> loadDirtyFileList() { final List<Integer> dirtyFileList = new ArrayList<>(); Cursor cursor = null; try { cursor = getWritableDatabase().rawQuery("SELECT * FROM " + TASK_FILE_DIRTY_TABLE_NAME, null); while (cursor.moveToNext()) { dirtyFileList.add(cursor.getInt(cursor.getColumnIndex(ID))); } } finally { if (cursor != null) cursor.close(); } return dirtyFileList; } BreakpointSQLiteHelper(Context context); @Override void onOpen(SQLiteDatabase db); @Override void onCreate(SQLiteDatabase db); @Override void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion); @Override void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion); void markFileDirty(int id); void markFileClear(int id); List<Integer> loadDirtyFileList(); SparseArray<BreakpointInfo> loadToCache(); HashMap<String, String> loadResponseFilenameToMap(); void updateFilename(@NonNull String url, @NonNull String filename); void insert(@NonNull BreakpointInfo info); void updateBlockIncrease(@NonNull BreakpointInfo info, int blockIndex,
                                    long newCurrentOffset); void updateInfo(@NonNull BreakpointInfo info); void removeInfo(int id); void removeBlock(int breakpointId);  }### Answer:
@Test public void loadDirtyFileList() { doReturn(db).when(helper).getWritableDatabase(); Cursor cursor = mock(Cursor.class); doReturn(cursor).when(db).rawQuery("SELECT * FROM " + TASK_FILE_DIRTY_TABLE_NAME, null); doReturn(true, true, false).when(cursor).moveToNext(); doReturn(1, 2).when(cursor).getInt(anyInt()); assertThat(helper.loadDirtyFileList()).containsExactly(1, 2); }