### Question:
DownloadSerialQueue extends DownloadListener2 implements Runnable { public synchronized void pause() { if (paused) { Util.w(TAG, "require pause this queue(remain " + taskList.size() + "), but" + "it has already been paused"); return; } paused = true; if (runningTask != null) { runningTask.cancel(); taskList.add(0, runningTask); runningTask = null; } } DownloadSerialQueue();   DownloadSerialQueue(DownloadListener listener, ArrayList<DownloadTask> taskList);  DownloadSerialQueue(DownloadListener listener); void setListener(DownloadListener listener); synchronized void enqueue(DownloadTask task); synchronized void pause(); synchronized void resume(); int getWorkingTaskId(); int getWaitingTaskCount(); synchronized DownloadTask[] shutdown(); @Override void run(); @Override void taskStart(@NonNull DownloadTask task); @Override synchronized void taskEnd(@NonNull DownloadTask task, @NonNull EndCause cause,
                                     @Nullable Exception realCause);  }### Answer:
@Test public void pause() { serialQueue.pause(); assertThat(serialQueue.paused).isTrue(); }
@Test public void pause_isRunning_cancel() { serialQueue.runningTask = task1; serialQueue.pause(); verify(task1).cancel(); assertThat(taskList.get(0)).isEqualTo(task1); }