AbstractFormatExporter implements FormatExporter { static int getNumDimensions(String dimensionNames) { if (StringUtils.isBlank(dimensionNames)) { throw new IllegalArgumentException("empty dimension names"); } final String[] splittednames = StringUtils.split(dimensionNames, ' '); return splittednames.length; }  @Override void initialize(Product product, ExportParameter exportParameter); @Override void prepareGeographicSubset(NFileWriteable nFileWriteable, ExportParameter exportParameter); @Override void addGlobalAttributes(NFileWriteable nFileWriteable, MetadataElement metadataRoot, ExportParameter exportParameter); @Override void addVariables(NFileWriteable nFileWriteable, ExportParameter exportParameter); @Override abstract void addDimensions(NFileWriteable nFileWriteable);  }
@Test public void testGetNumDimensions() { assertEquals(1, AbstractFormatExporter.getNumDimensions("onedimensional")); assertEquals(2, AbstractFormatExporter.getNumDimensions("two dims")); }
@Test public void testGetNumDimensions_emptyArgument() { try { AbstractFormatExporter.getNumDimensions(""); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } try { AbstractFormatExporter.getNumDimensions(null); fail("IllegalArgumentException expected"); } catch (IllegalArgumentException expected) { } }