### Question:
DownloadDispatcher { public void enqueue(DownloadTask[] tasks) { skipProceedCallCount.incrementAndGet(); enqueueLocked(tasks); skipProceedCallCount.decrementAndGet(); } 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 enqueue_maxTaskCountControl() { maxRunningTask(); final DownloadTask mockTask = mockTask(); dispatcher.enqueue(mockTask); assertThat(readyAsyncCalls).hasSize(1); assertThat(readyAsyncCalls.get(0).task).isEqualTo(mockTask); assertThat(runningSyncCalls).isEmpty(); assertThat(runningAsyncCalls).hasSize(dispatcher.maxParallelRunningCount); }
@Test public void enqueue_priority() { final DownloadTask mockTask1 = mockTask(); when(mockTask1.getPriority()).thenReturn(1); final DownloadTask mockTask2 = mockTask(); when(mockTask2.getPriority()).thenReturn(2); final DownloadTask mockTask3 = mockTask(); when(mockTask3.getPriority()).thenReturn(3); maxRunningTask(); dispatcher.enqueue(mockTask2); dispatcher.enqueue(mockTask1); dispatcher.enqueue(mockTask3); assertThat(readyAsyncCalls.get(0).task).isEqualTo(mockTask3); assertThat(readyAsyncCalls.get(1).task).isEqualTo(mockTask2); assertThat(readyAsyncCalls.get(2).task).isEqualTo(mockTask1); }