MetaDataResolver { @Nullable static RunContext fromMetaDataFile(@NotNull String runDirectory) { File metaDataFileP4 = new File(runDirectory + File.separator + METADATA_FILE_P4); File metaDataFileP5 = new File(runDirectory + File.separator + METADATA_FILE_P5); if (metaDataFileP4.exists()) { try { return fromPv4MetaData(runDirectory, metaDataFileP4); } catch (FileNotFoundException exception) { LOGGER.warn("Could not find meta data file '{}' for run dir '{}'.", METADATA_FILE_P4, runDirectory); return null; } } else if (metaDataFileP5.exists()) { try { return fromPv5MetaData(runDirectory, metaDataFileP5); } catch (FileNotFoundException exception) { LOGGER.warn("Could not find meta data file '{}' for run dir '{}'.", METADATA_FILE_P5, runDirectory); return null; } } else { LOGGER.warn("No metadata file found for run dir '{}'.", runDirectory); return null; } } private  MetaDataResolver();   }
@Test public void noMetaDataReturnsNull() { String noMetaDataRunDir = RESOURCE_DIR + File.separator + "RunDirNoMetaData"; assertNull(MetaDataResolver.fromMetaDataFile(noMetaDataRunDir)); }
@Test public void noRefSampleReturnsNull() { String noRefSampleRunDir = RESOURCE_DIR + File.separator + "RunDirNoRefSample"; assertNull(MetaDataResolver.fromMetaDataFile(noRefSampleRunDir)); }
@Test public void noSetNameReturnsNull() { String noSetNameRunDir = RESOURCE_DIR + File.separator + "RunDirNoSetName"; assertNull(MetaDataResolver.fromMetaDataFile(noSetNameRunDir)); }
@Test public void canResolveMetaDataFilePV5() { String noSetNameRunDir = RESOURCE_DIR + File.separator + "RunDirP5"; assertNotNull(MetaDataResolver.fromMetaDataFile(noSetNameRunDir)); }
@Test public void canResolveSomaticMetaDataP4() { String setName = "RunDirSomatic"; String runDirectory = RESOURCE_DIR + File.separator + setName; RunContext runContext = MetaDataResolver.fromMetaDataFile(runDirectory); assertNotNull(runContext); assertEquals("CPCT12345678R", runContext.refSample()); assertEquals("CPCT12345678T", runContext.tumorSample()); assertEquals(setName, runContext.setName()); assertEquals(runDirectory, runContext.runDirectory()); assertEquals(Strings.EMPTY, runContext.tumorBarcodeSample()); }
@Test public void canResolveSomaticMetaDataP5() { String setName = "RunDirP5"; String runDirectory = RESOURCE_DIR + File.separator + setName; RunContext runContext = MetaDataResolver.fromMetaDataFile(runDirectory); assertNotNull(runContext); assertEquals("CPCT12345678R", runContext.refSample()); assertEquals("CPCT12345678T", runContext.tumorSample()); assertEquals(setName, runContext.setName()); assertEquals(runDirectory, runContext.runDirectory()); assertEquals("AB456", runContext.tumorBarcodeSample()); }