VariableExtractor { public DAPVariable[] extractVariables(OpendapLeaf leaf) { DDS dds = getDDS(leaf.getDdsUri()); return extractVariables(dds); }  DAPVariable[] extractVariables(OpendapLeaf leaf); DAPVariable[] extractVariables(DDS dds);  }
@Test public void testThatNoVariableCanBeExtractedFromEmptyDDS() { OpendapLeaf leaf = new OpendapLeaf("empty", new InvDataset(null, "") { }); final DAPVariable[] dapVariables = new VariableExtractor().extractVariables(leaf); assertEquals(0, dapVariables.length); }
@Test public void testThatByteVariableCanBeRead() throws DAP2Exception, ParseException { DDS dds = createDDSWithByteVariable(); final DAPVariable[] dapVariables = new VariableExtractor().extractVariables(dds); assertEquals(1, dapVariables.length); assertEquals("metadata", dapVariables[0].getName()); assertEquals("atomic", dapVariables[0].getType()); assertEquals("Byte", dapVariables[0].getDataType()); assertEquals(0, dapVariables[0].getNumDimensions()); }
@Test public void testThatFloatVariableCanBeRead() throws DAP2Exception, ParseException { DDS dds = createDDSWithFloatVariable(); final DAPVariable[] dapVariables = new VariableExtractor().extractVariables(dds); assertEquals(1, dapVariables.length); assertEquals("metadata", dapVariables[0].getName()); assertEquals("atomic", dapVariables[0].getType()); assertEquals("Float32", dapVariables[0].getDataType()); assertEquals(0, dapVariables[0].getNumDimensions()); }
@Test public void testThatMultipleVariablesCanBeExtractedFromADDSWithMultipleVariables() throws DAP2Exception, ParseException { DDS dds = createDDSWithMultipleVariables(); final DAPVariable[] dapVariables = new VariableExtractor().extractVariables(dds); assertEquals(6, dapVariables.length); assertEquals("Chlorophyll", dapVariables[0].getName()); assertEquals("Total_suspended_matter", dapVariables[1].getName()); assertEquals("Yellow_substance", dapVariables[2].getName()); assertEquals("l2_flags", dapVariables[3].getName()); assertEquals("X", dapVariables[4].getName()); assertEquals("Y", dapVariables[5].getName()); }