### Question:
RemitSyncExecutor implements Handler.Callback { public boolean handleMessage(Message msg) { List<Integer> idList; int id; switch (msg.what) { case WHAT_REMOVE_INFO: id = msg.arg1; freeToDBIdList.remove(id); this.agent.removeInfo(id); Util.d(TAG, "remove info " + id); break; case WHAT_REMOVE_FREE_BUNCH_ID: idList = (List<Integer>) msg.obj; freeToDBIdList.removeAll(idList); Util.d(TAG, "remove free bunch ids " + idList); break; case WHAT_REMOVE_FREE_ID: id = msg.arg1; freeToDBIdList.remove(id); Util.d(TAG, "remove free bunch id " + id); break; case WHAT_SYNC_BUNCH_ID: idList = (List<Integer>) msg.obj; try { this.agent.syncCacheToDB(idList); freeToDBIdList.addAll(idList); Util.d(TAG, "sync bunch info with ids: " + idList); } catch (IOException e) { Util.w(TAG, "sync info to db failed for ids: " + idList); } break; default: id = msg.what; try { this.agent.syncCacheToDB(id); freeToDBIdList.add(id); Util.d(TAG, "sync info with id: " + id); } catch (IOException e) { Util.w(TAG, "sync cache to db failed for id: " + id); } break; } return true; } RemitSyncExecutor(@NonNull RemitAgent agent);   RemitSyncExecutor(@NonNull RemitAgent agent, @Nullable Handler handler,
                      @NonNull Set<Integer> freeToDBIdList); void postSyncInfoDelay(int id, long delayMillis); void postSync(int id); void postSync(List<Integer> idList); void postRemoveInfo(int id); void postRemoveFreeIds(List<Integer> idList); void postRemoveFreeId(int id); boolean handleMessage(Message msg);  }### Answer:
@Test public void handleMessage_removeInfo() { final Message message = new Message(); message.what = WHAT_REMOVE_INFO; message.arg1 = 1; freeToDBIdList.add(1); executor.handleMessage(message); verify(agent).removeInfo(eq(1)); assertThat(freeToDBIdList).isEmpty(); }
@Test public void handleMessage_removeFreeBunchId() { final Message message = new Message(); message.what = WHAT_REMOVE_FREE_BUNCH_ID; message.obj = idList; freeToDBIdList.addAll(idList); executor.handleMessage(message); assertThat(freeToDBIdList).isEmpty(); }
@Test public void handleMessage_removeFreeId() { final Message message = new Message(); message.what = WHAT_REMOVE_FREE_ID; message.arg1 = 1; freeToDBIdList.add(1); executor.handleMessage(message); assertThat(freeToDBIdList).isEmpty(); }
@Test public void handleMessage_syncBunchId() throws IOException { final Message message = new Message(); message.what = WHAT_SYNC_BUNCH_ID; message.obj = idList; executor.handleMessage(message); verify(agent).syncCacheToDB(eq(idList)); assertThat(freeToDBIdList).containsExactly(1, 2, 3); }
@Test public void handleMessage_syncId() throws IOException { final Message message = new Message(); message.what = 1; executor.handleMessage(message); verify(agent).syncCacheToDB(eq(1)); assertThat(freeToDBIdList).containsExactly(1); }