if (file.getSize() != size) { parameters.put(FileDBAdaptor.QueryParams.SIZE.key(), size);
@Test public void testScanStudyURI() throws IOException, CatalogException { CatalogManagerTest.createDebugFile(directory.resolve("file1.txt").toString()); FileScanner fileScanner = new FileScanner(catalogManager); List<File> files = fileScanner.scan(folder, directory.toUri(), FileScanner.FileScannerPolicy.REPLACE, true, true, sessionIdUser); assertEquals(1, files.size()); URI studyUri = study.getUri(); CatalogManagerTest.createDebugFile(studyUri.resolve("data/test/folder/").resolve("file2.txt").getPath()); File root = catalogManager.getFileManager().get(study.getFqn(), new Query("name", "."), null, sessionIdUser).first(); files = fileScanner.scan(root, studyUri, FileScanner.FileScannerPolicy.REPLACE, true, true, sessionIdUser); assertEquals(1, files.size()); files.forEach((f) -> assertTrue(f.getSize() > 0)); files.forEach((f) -> assertEquals(f.getStatus().getName(), File.FileStatus.READY)); files.forEach((f) -> assertTrue(StringUtils.isNotEmpty(f.getChecksum()))); }
@Test public void testGetBasicMetadata() throws CatalogException, IOException { File file = catalogManager.getFileManager().create(study.getFqn(), new File().setPath(folder.getPath() + "test.txt"), false, StringUtils.randomString(1000), null, sessionIdUser).first(); assertEquals(1000, file.getSize()); String creationDate = file.getCreationDate(); String modificationDate = file.getModificationDate(); URI fileUri = catalogManager.getFileManager().getUri(file); try { Thread.sleep(1000); //Sleep 1 second to see changes on the "modificationDate" } catch (InterruptedException ignored) {} OutputStream outputStream = new FileOutputStream(Paths.get(fileUri).toFile(), true); byte[] bytes2 = StringUtils.randomString(100).getBytes(); outputStream.write(bytes2); outputStream.close(); file = FileMetadataReader.get(catalogManager). setMetadataInformation(file, null, null, sessionIdUser, false); assertEquals(1000 + bytes2.length, file.getSize()); assertTrue(TimeUtils.toDate(modificationDate).getTime() < TimeUtils.toDate(file.getModificationDate()).getTime()); assertEquals(creationDate, file.getCreationDate()); }
@Test public void testGetMetadataFromVcf() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), vcfFileUri, new File().setPath(folder.getPath() + VCF_FILE_NAME), false, false, sessionIdUser).first(); assertTrue(file.getSize() > 0); file = FileMetadataReader.get(catalogManager). setMetadataInformation(file, null, null, sessionIdUser, false); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); assertEquals(expectedSampleNames, ((Map<String, Object>) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")); catalogManager.getSampleManager().get(study.getFqn(), new Query(SampleDBAdaptor.QueryParams.ID.key(), file.getSamples().stream().map(Sample::getId).collect(Collectors.toList())), new QueryOptions(), sessionIdUser).getResult(); assertTrue(expectedSampleNames.containsAll(file.getSamples().stream().map(Sample::getId).collect(Collectors.toSet()))); }
fileSolrModel.setSize(file.getSize()); if (file.getSoftware() != null) { fileSolrModel.setSoftware(file.getSoftware().getName());
assertTrue(file.getSize() > 0); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertTrue(StringUtils.isNotEmpty(file.getChecksum()));
dbAdaptorFactory.getCatalogStudyDBAdaptor().updateDiskUsage(studyId, file.getSize());
@Test public void testCreate() throws CatalogException { QueryResult<File> fileQueryResult = FileMetadataReader.get(catalogManager). create(study.getFqn(), vcfFileUri, folder.getPath() + VCF_FILE_NAME, "", false, null, sessionIdUser); File file = fileQueryResult.first(); assertEquals(File.FileStatus.STAGE, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); assertEquals(21499, file.getSize()); new FileUtils(catalogManager).upload(vcfFileUri, file, null, sessionIdUser, false, false, true, true, Integer.MAX_VALUE); file = catalogManager.getFileManager().get(study.getFqn(), file.getPath(), null, sessionIdUser).first(); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertNotNull(((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")); assertEquals(4, ((List) ((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")).size()); assertNotNull(((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("header")); assertEquals(4, file.getSamples().size()); assertEquals(21499, file.getSize()); }
assert (fileSolrModel.getSize() == file.getSize()); assert (fileSolrModel.getSoftware().equals(file.getSoftware().getName())); assert (fileSolrModel.getNumSamples() == file.getSamples().size());
@Test public void testGetMetadataFromBam() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), bamFileUri, new File().setPath(folder.getPath() + BAM_FILE_NAME), false, false, sessionIdUser).first(); assertTrue(file.getSize() > 0); file = FileMetadataReader.get(catalogManager). setMetadataInformation(file, null, null, sessionIdUser, false); assertEquals(File.FileStatus.READY, file.getStatus().getName()); // assertEquals(File.Format.GZIP, file.getFormat()); assertEquals(File.Bioformat.ALIGNMENT, file.getBioformat()); assertNotNull(file.getAttributes().get("alignmentHeader")); assertEquals(1, file.getSamples().size()); assertEquals("HG00096", catalogManager.getSampleManager().get(study.getFqn(), file.getSamples().get(0).getId(), null, sessionIdUser).first().getId()); }
file.setStatus(ParamUtils.defaultObject(file.getStatus(), new File.FileStatus(File.FileStatus.READY))); if (file.getSize() < 0) { throw new CatalogException("Error: DiskUsage can't be negative!");