L1CFormatExporter extends AbstractFormatExporter { static Dimension extractDimensions(String dimensionNames, HashMap<String, Integer> dimensionMap) { final String[] dimNamesArray = StringUtils.split(dimensionNames, new char[]{' '}, true); final Dimension dimension = new Dimension(); dimension.width = dimensionMap.get(dimNamesArray[0]); if (dimNamesArray.length > 1) { dimension.height = dimensionMap.get(dimNamesArray[1]); } else { dimension.height = -1; } return dimension; }  @Override void initialize(Product product, ExportParameter exportParameter); @Override void prepareGeographicSubset(NFileWriteable nFileWriteable, ExportParameter exportParameter); @Override void addDimensions(NFileWriteable nFileWriteable); @Override void writeData(NFileWriteable nFileWriteable);  }
@Test public void testExtractDimensions() { final HashMap<String, Integer> dimensionMap = new HashMap<>(); dimensionMap.put("width", 34); dimensionMap.put("height", 17); final Dimension dimension = L1CFormatExporter.extractDimensions("width height", dimensionMap); assertNotNull(dimension); assertEquals(34, dimension.width); assertEquals(17, dimension.height); }
@Test public void testExtractDimensions_noHeight() { final HashMap<String, Integer> dimensionMap = new HashMap<>(); dimensionMap.put("width", 34); dimensionMap.put("height", 17); final Dimension dimension = L1CFormatExporter.extractDimensions("width", dimensionMap); assertNotNull(dimension); assertEquals(34, dimension.width); assertEquals(-1, dimension.height); }