DAPDownloader { static String getConstraintExpression(String sourceVariable, String constraintExpression) { final String[] constraintExpressions = constraintExpression.split(","); for (String expression : constraintExpressions) { if (expression.startsWith(sourceVariable + "[")) { return expression; } } throw new IllegalArgumentException( MessageFormat.format("Source variable ''{0}'' must be included in expression ''{1}''.", sourceVariable, constraintExpression)); } DAPDownloader(Map<String, Boolean> dapUris, List<String> fileURIs, DownloadContext downloadContext,
                         DownloadProgressBarPM pm); void saveProducts(File targetDir);  }
@Test public void testGetConstraintsExpressionForVariable() throws Exception { assertEquals("sst[0:1:10][0:1:10]", DAPDownloader.getConstraintExpression("sst", "sst[0:1:10][0:1:10],wind[0:1:10][0:1:10]")); assertEquals("wind[0:1:10][0:1:10]", DAPDownloader.getConstraintExpression("wind", "sst[0:1:10][0:1:10],wind[0:1:10][0:1:10]")); try { DAPDownloader.getConstraintExpression("pig_density", "sst[0:1:10][0:1:10],wind[0:1:10][0:1:10]"); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().contains("must be included")); } assertEquals("sst[0:1:10]", DAPDownloader.getConstraintExpression("sst", "sst_flag[0:1:10][0:1:10],wind[0:1:10][0:1:10],sst[0:1:10]")); assertEquals("sst[0:1:10]", DAPDownloader.getConstraintExpression("sst", "flag_sst[0:1:10][0:1:10],wind[0:1:10][0:1:10],sst[0:1:10]")); }