MimToGeneParser implements ResourceParser { @Override public void parseResource(Resource resource, Path inDir, Path outDir) { Path inFile = inDir.resolve(resource.getExtractedFileName()); Path outFile = outDir.resolve(resource.getParsedFileName()); logger.info("Parsing {} file: {}. Writing out to: {}", resource.getName(), inFile, outFile); ResourceOperationStatus status; try (BufferedReader reader = Files.newBufferedReader(inFile, Charset.defaultCharset())) { String line; while ((line = reader.readLine()) != null) { if (!line.startsWith("#")) { parseLine(line); } } logger.info("Extracted {} genes from {}", mim2geneMap.size(), inFile); status = ResourceOperationStatus.SUCCESS; } catch (FileNotFoundException ex) { logger.error("Unable to find file: {}", inFile, ex); status = ResourceOperationStatus.FILE_NOT_FOUND; } catch (IOException ex) { logger.error("Error parsing file: {}", inFile, ex); status = ResourceOperationStatus.FAILURE; } resource.setParseStatus(status); logger.info("{}", status); } MimToGeneParser(Map<Integer, Integer> mim2geneMap); @Override void parseResource(Resource resource, Path inDir, Path outDir);  }
@Test public void testParse() { Resource testResource = new Resource("MIM2GENE"); testResource.setExtractedFileName("mim2gene_test.txt"); testResource.setParsedFileName("testMim2Gene.out"); Map<Integer, Integer> mim2geneMap = new HashMap<>(); MimToGeneParser instance = new MimToGeneParser(mim2geneMap); instance.parseResource(testResource, Paths.get("src/test/resources/data"), Paths.get("target/test-data")); Map<Integer, Integer> expected = new HashMap<>(); expected.put(123463, 124); expected.put(123464, 123); expected.put(123466, 216); expected.put(123468, 87); assertThat(mim2geneMap, equalTo(expected)); assertThat(testResource.getParseStatus(), equalTo(ResourceOperationStatus.SUCCESS)); }