### Question:
RemitStoreOnSQLite implements RemitSyncExecutor.RemitAgent, DownloadStore { @Override public void syncCacheToDB(List<Integer> idList) throws IOException { final SQLiteDatabase database = sqLiteHelper.getWritableDatabase(); database.beginTransaction(); try { for (Integer id : idList) { syncCacheToDB(id); } database.setTransactionSuccessful(); } finally { database.endTransaction(); } } RemitStoreOnSQLite(@NonNull BreakpointStoreOnSQLite sqlite);   RemitStoreOnSQLite(@NonNull RemitSyncToDBHelper helper, @NonNull BreakpointStoreOnSQLite sqlite,
                       @NonNull DownloadStore sqliteCache,
                       @NonNull BreakpointSQLiteHelper sqLiteHelper); @Nullable @Override BreakpointInfo get(int id); @NonNull @Override BreakpointInfo createAndInsert(@NonNull DownloadTask task); @Override void onTaskStart(int id); @Override void onSyncToFilesystemSuccess(@NonNull BreakpointInfo info, int blockIndex,
                                                    long increaseLength); @Override boolean update(@NonNull BreakpointInfo info); @Override void onTaskEnd(int id, @NonNull EndCause cause, @Nullable Exception exception); @Nullable @Override BreakpointInfo getAfterCompleted(int id); @Override boolean markFileDirty(int id); @Override boolean markFileClear(int id); @Override void remove(int id); @Override int findOrCreateId(@NonNull DownloadTask task); @Nullable @Override BreakpointInfo findAnotherInfoFromCompare(@NonNull DownloadTask task,
                                                     @NonNull BreakpointInfo ignored); @Override boolean isOnlyMemoryCache(); @Override boolean isFileDirty(int id); @Nullable @Override String getResponseFilename(String url); @Override void syncCacheToDB(List<Integer> idList); @Override void syncCacheToDB(int id); @Override void removeInfo(int id); static void setRemitToDBDelayMillis(int delayMillis);  }### Answer:
@Test public void syncCacheToDB() throws IOException { Util.setLogger(mock(Util.Logger.class)); final BreakpointInfo info = mock(BreakpointInfo.class); when(onCache.get(1)).thenReturn(info); store.syncCacheToDB(1); verify(helper).removeInfo(eq(1)); verify(helper, never()).insert(eq(info)); when(info.getFilename()).thenReturn("filename"); store.syncCacheToDB(1); verify(helper, never()).insert(eq(info)); when(info.getTotalOffset()).thenReturn(1L); store.syncCacheToDB(1); verify(helper).insert(eq(info)); }
@Test public void syncCacheToDB_list() throws IOException { final List<Integer> ids = new ArrayList<>(2); ids.add(1); ids.add(2); final SQLiteDatabase db = mock(SQLiteDatabase.class); when(helper.getWritableDatabase()).thenReturn(db); store.syncCacheToDB(ids); verify(store).syncCacheToDB(eq(1)); verify(store).syncCacheToDB(eq(2)); verify(db).beginTransaction(); verify(db).setTransactionSuccessful(); verify(db).endTransaction(); }