### Question:
DownloadDispatcher { public synchronized boolean isPending(DownloadTask task) { Util.d(TAG, "isPending: " + task.getId()); for (DownloadCall call : readyAsyncCalls) { if (call.isCanceled()) continue; if (call.equalsTask(task)) return true; } return false; } DownloadDispatcher();   DownloadDispatcher(List<DownloadCall> readyAsyncCalls,
                       List<DownloadCall> runningAsyncCalls,
                       List<DownloadCall> runningSyncCalls,
                       List<DownloadCall> finishingCalls); void setDownloadStore(@NonNull DownloadStore store); void enqueue(DownloadTask[] tasks); void enqueue(DownloadTask task); void execute(DownloadTask task); @SuppressWarnings("PMD.ForLoopsMustUseBraces") void cancelAll(); void cancel(IdentifiedTask[] tasks); boolean cancel(IdentifiedTask task); boolean cancel(int id); @Nullable synchronized DownloadTask findSameTask(DownloadTask task); synchronized boolean isRunning(DownloadTask task); synchronized boolean isPending(DownloadTask task); synchronized void flyingCanceled(DownloadCall call); synchronized void finish(DownloadCall call); synchronized boolean isFileConflictAfterRun(@NonNull DownloadTask task); static void setMaxParallelRunningCount(int maxParallelRunningCount);  }### Answer:
@Test public void isPending_true() { final DownloadCall mockReadyCall = spy(DownloadCall.create(mockTask(1), true, store)); when(mockReadyCall.isCanceled()).thenReturn(false); readyAsyncCalls.add(mockReadyCall); boolean result = dispatcher.isPending(mockReadyCall.task); assertThat(result).isEqualTo(true); }
@Test public void isPending_false() { boolean result = dispatcher.isPending(mockTask(0)); assertThat(result).isEqualTo(false); final DownloadCall pendingCall1 = spy(DownloadCall.create(mockTask(1), true, store)); when(pendingCall1.isCanceled()).thenReturn(false); readyAsyncCalls.add(pendingCall1); result = dispatcher.isPending(mockTask(0)); assertThat(result).isEqualTo(false); when(pendingCall1.isCanceled()).thenReturn(true); result = dispatcher.isPending(pendingCall1.task); assertThat(result).isEqualTo(false); }