### Question:
DownloadSerialQueue extends DownloadListener2 implements Runnable { public synchronized void enqueue(DownloadTask task) { taskList.add(task); Collections.sort(taskList); if (!paused && !looping) { looping = true; startNewLooper(); } } 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 enqueue() { doNothing().when(serialQueue).startNewLooper(); when(task1.compareTo(task2)).thenReturn(-1); serialQueue.enqueue(task2); serialQueue.enqueue(task1); verify(taskList).add(eq(task1)); verify(taskList).add(eq(task2)); assertThat(taskList).containsExactly(task1, task2); }