DefaultInventoryService implements InventoryService { static List<ProductSet> readProductSetFromCsv(InputStream is) throws IOException { InputStreamReader reader = new InputStreamReader(is); try (BufferedReader bufferedReader = new BufferedReader(reader)) { List<ProductSet> productSets = new ArrayList<ProductSet>(); String line = bufferedReader.readLine(); while (line != null) { ProductSet productSet = ProductSetPersistable.convertFromCSV(line); if (productSet != null) { productSets.add(productSet); } line = bufferedReader.readLine(); } return productSets; } } DefaultInventoryService(AbstractFileSystemService fileSystemService, String archiveRootDir); @Override ProductSet[] getProductSets(String username, String filter); static String getRegexpForPathGlob(String wildcardPath);  }
@Test public void testReadProductSetFromCsv() throws Exception { String csv = "MER_RR__1;MERIS RR L1b 2004-2008;eodata/MER_RR__1P/r03/${yyyy}/${MM}/${dd}/.*.N1;2004-01-01;2008-12-31;null;null\n" + "MER_RR__1;MERIS RR L1b 2004;eodata/MER_RR__1P/r03/2004/${MM}/${dd}/.*.N1;2004-01-01;2004-12-31;null;null\n" + "MER_RR__1;MERIS RR L1b 2005;eodata/MER_RR__1P/r03/2005/${MM}/${dd}/.*.N1;2005-01-01;2005-12-31;null;null\n"; List<ProductSet> productSets = DefaultInventoryService.readProductSetFromCsv( new ByteArrayInputStream(csv.getBytes())); assertNotNull(productSets); assertEquals(3, productSets.size()); assertEquals("MERIS RR L1b 2004", productSets.get(1).getName()); assertEquals("eodata/MER_RR__1P/r03/2004/${MM}/${dd}/.*.N1", productSets.get(1).getPath()); assertEquals(ProductData.UTC.createDateFormat("yyyy-MM-dd").parse("2004-01-01"), productSets.get(1).getMinDate()); assertEquals(ProductData.UTC.createDateFormat("yyyy-MM-dd").parse("2004-12-31"), productSets.get(1).getMaxDate()); }