DAPDownloader { static List<String> getVariableNames(String constraintExpression) { if (StringUtils.isNullOrEmpty(constraintExpression)) { return null; } List<String> variableNames = new ArrayList<String>(); String[] constraints = constraintExpression.split(","); for (String constraint : constraints) { if (constraint.contains("[")) { variableNames.add(constraint.substring(0, constraint.indexOf("["))); } else { variableNames.add(constraint); } } return variableNames; } DAPDownloader(Map<String, Boolean> dapUris, List<String> fileURIs, DownloadContext downloadContext,
                         DownloadProgressBarPM pm); void saveProducts(File targetDir);  }
@Test public void testGetVariableNames() throws Exception { List<String> variableNames = DAPDownloader.getVariableNames( "iop_a_total_443[0:1:717][0:1:308],iop_a_ys_443[0:1:717][0:1:308]"); String[] expected = {"iop_a_total_443", "iop_a_ys_443"}; assertArrayEquals(expected, variableNames.toArray(new String[variableNames.size()])); variableNames = DAPDownloader.getVariableNames(""); assertNull(variableNames); variableNames = DAPDownloader.getVariableNames(null); assertNull(variableNames); variableNames = DAPDownloader.getVariableNames("someUnconstrainedVariable"); expected = new String[]{"someUnconstrainedVariable"}; assertArrayEquals(expected, variableNames.toArray(new String[variableNames.size()])); variableNames = DAPDownloader.getVariableNames( "someUnconstrainedVariable,someConstrainedVariable[0:1:717][0:1:308]"); expected = new String[]{"someUnconstrainedVariable", "someConstrainedVariable"}; assertArrayEquals(expected, variableNames.toArray(new String[variableNames.size()])); }