DAPDownloader { void downloadFile(File targetDir, String fileURI) throws URISyntaxException, IOException { final URL fileUrl = new URI(fileURI).toURL(); updateProgressBar(fileUrl.getFile(), 0); final File file = FileDownloader.downloadFile(fileUrl, targetDir, null); downloadContext.notifyFileDownloaded(file); } DAPDownloader(Map<String, Boolean> dapUris, List<String> fileURIs, DownloadContext downloadContext,
                         DownloadProgressBarPM pm); void saveProducts(File targetDir);  }
@Test public void testDownloadFile() throws Exception { final Set<File> downloadedFiles = new HashSet<File>(); NullDownloadContext fileCountProvider = new NullDownloadContext() { @Override public void notifyFileDownloaded(File downloadedFile) { downloadedFiles.add(downloadedFile); } }; DAPDownloader dapDownloader = new DAPDownloader(new HashMap<String, Boolean>(), new ArrayList<String>(), fileCountProvider, new NullLabelledProgressBarPM()); String fileName = "fileToTextDownload.txt"; assertFalse(getTestFile(fileName).exists()); assertEquals(0, downloadedFiles.size()); URL resource = getClass().getResource(fileName); dapDownloader.downloadFile(TESTDATA_DIR, resource.toString()); assertEquals(1, downloadedFiles.size()); assertEquals(fileName, ((File) downloadedFiles.toArray()[0]).getName()); assertTrue(getTestFile(fileName).exists()); }