AlleleResourceDownloader { public static void download(AlleleResource alleleResource) { Path resourceFile = alleleResource.getAlleleArchive().getPath(); if (!resourceFile.toFile().exists()) { downloadTabixFile(alleleResource); downloadResourceFile(alleleResource); } else { logger.info("{} resource file already present. Skipping download.", alleleResource.getName()); } } private  AlleleResourceDownloader(); static void download(AlleleResource alleleResource);  }
@Test @ExtendWith(TempDirectory.class) void downloadWithTabixIndex(@TempDir Path tempDir) throws Exception { URL url = Paths.get("src/test/resources/test_empty.vcf.gz").toUri().toURL(); Path alleleGzipFile = tempDir.resolve("test_empty.vcf.gz"); AlleleResource testResource = new TabixAlleleResource("test", url, alleleGzipFile, line -> null); AlleleResourceDownloader.download(testResource); assertThat(alleleGzipFile.toFile().exists(), is(true)); assertThat(tempDir.resolve("test_empty.vcf.gz.tbi").toFile().exists(), is(true)); }
@Test @ExtendWith(TempDirectory.class) void downloadNonExistentFileThrowsException(@TempDir Path tempDir) throws Exception { URL url = Paths.get("src/test/resources/no_file_here.vcf.gz").toUri().toURL(); Path alleleGzipFile = tempDir.resolve("no_file_here.vcf.gz"); AlleleResource testResource = new TabixAlleleResource("test", url, alleleGzipFile, line -> null); assertThrows(ResourceDownloadException.class, () -> AlleleResourceDownloader.download(testResource)); }
@Test @ExtendWith(TempDirectory.class) void downloadWithoutTabixIndex(@TempDir Path tempDir) throws Exception { URL url = Paths.get("src/test/resources/test_first_ten_dbsnp.vcf.gz").toUri().toURL(); Path alleleGzipFile = tempDir.resolve("test_first_ten_dbsnp.vcf.gz"); AlleleResource testResource = new TabixAlleleResource("test", url, alleleGzipFile, line -> null); AlleleResourceDownloader.download(testResource); assertThat(alleleGzipFile.toFile().exists(), is(true)); assertThat(tempDir.resolve("test_first_ten_dbsnp.vcf.gz.tbi").toFile().exists(), is(false)); }