LiteDownloadManagerDownloader { void download(Batch batch, Map<DownloadBatchId, DownloadBatch> downloadBatchMap) { DownloadBatch downloadBatch = DownloadBatchFactory.newInstance( batch, fileOperations, downloadsBatchPersistence, downloadsFilePersistence, callbackThrottleCreator.create(), connectionChecker, downloadBatchRequirementRule ); executor.submit(downloadBatch::updateTotalSize); download(downloadBatch, downloadBatchMap); } @SuppressWarnings({"checkstyle:parameternumber", "PMD.ExcessiveParameterList"})  LiteDownloadManagerDownloader(Object waitForDownloadService,
                                  Object waitForDownloadBatchStatusCallback,
                                  ExecutorService executor,
                                  Handler callbackHandler,
                                  FileOperations fileOperations,
                                  DownloadsBatchPersistence downloadsBatchPersistence,
                                  DownloadsFilePersistence downloadsFilePersistence,
                                  DownloadBatchStatusNotificationDispatcher notificationDispatcher,
                                  DownloadBatchRequirementRule downloadBatchRequirementRule,
                                  ConnectionChecker connectionChecker,
                                  Set<DownloadBatchStatusCallback> callbacks,
                                  CallbackThrottleCreator callbackThrottleCreator,
                                  DownloadBatchStatusFilter downloadBatchStatusFilter,
                                  Wait.Criteria serviceCriteria); boolean addCompletedBatch(CompletedDownloadBatch completedDownloadBatch, Map<DownloadBatchId, DownloadBatch> downloadBatchMap);  }
@Test public void addsDownloadBatchToQueue() { downloadingBatches.clear(); downloader.download(downloadBatch, downloadingBatches); assertThat(downloadingBatches).containsEntry(downloadBatchId, downloadBatch); }
@Test public void doesNotAddDownloadBatchToQueue_whenIdAlreadyExists() { downloadingBatches.put(downloadBatchId, anotherDownloadBatchWithTheSameId); downloader.download(downloadBatch, downloadingBatches); assertThat(downloadingBatches).doesNotContainEntry(downloadBatchId, downloadBatch); }
@Test public void downloadsBatch() { downloadingBatches.clear(); downloader.download(downloadBatch, downloadingBatches); verify(downloadService).download(eq(downloadBatch), any()); }
@Test public void downloadsBatchByOriginalReference_whenIdAlreadyExists() { downloadingBatches.put(downloadBatchId, anotherDownloadBatchWithTheSameId); downloader.download(downloadBatch, downloadingBatches); verify(downloadService).download(eq(anotherDownloadBatchWithTheSameId), any()); }