ProductInventory { public static ProductInventory createInventory(Configuration conf) throws IOException { String inventoryPath = conf.get(JobConfigNames.CALVALUS_INPUT_INVENTORY); if (inventoryPath == null) { return null; } Path path = new Path(inventoryPath); FileSystem fileSystem = path.getFileSystem(conf); if (!fileSystem.exists(path)) { return null; } Reader reader = new BufferedReader(new InputStreamReader(fileSystem.open(path))); try { return createInventory(reader); } finally { reader.close(); } } ProductInventory(); static ProductInventory createInventory(Configuration conf); static ProductInventory createInventory(Reader reader); ProductInventoryEntry getEntry(String productName); List<ProductInventoryEntry> getAll(); int size();  }
@Test public void testCreateInventory() throws Exception { String content = "the/path\t2001-07-02-13-10-11.123400\t2001-07-02-13-12-14.567800\t45\t3\t42\tbar"; StringReader reader = new StringReader(content); ProductInventory inventory = ProductInventory.createInventory(reader); assertNotNull(inventory); assertEquals(1, inventory.size()); ProductInventoryEntry entry = inventory.getEntry("the/wrong/path"); assertNull(entry); entry = inventory.getEntry("the/path"); assertNotNull(entry); assertEquals("bar", entry.getMessage()); assertEquals(45, entry.getLength()); assertEquals(3, entry.getProcessStartLine()); assertEquals(42, entry.getProcessLength()); }