### Question:
DownloadSerialQueue extends DownloadListener2 implements Runnable { @Override public void run() { while (!shutedDown) { final DownloadTask nextTask; synchronized (this) { if (taskList.isEmpty() || paused) { runningTask = null; looping = false; break; } nextTask = taskList.remove(0); } nextTask.execute(listenerBunch); } } 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 run() { serialQueue.looping = true; serialQueue.run(); assertThat(serialQueue.looping).isFalse(); serialQueue.looping = true; taskList.add(task1); taskList.add(task2); serialQueue.paused = true; serialQueue.run(); verify(task1, never()).execute(any(DownloadListener.class)); verify(task2, never()).execute(any(DownloadListener.class)); verify(taskList, never()).remove(anyInt()); assertThat(serialQueue.looping).isFalse(); serialQueue.looping = true; serialQueue.paused = false; serialQueue.run(); verify(task1).execute(any(DownloadListener.class)); verify(task2).execute(any(DownloadListener.class)); verify(taskList, times(2)).remove(eq(0)); assertThat(serialQueue.looping).isFalse(); }