EnviProductReader extends AbstractProductReader { static String[] getBandNames(final Header header) { String[] bandNames = header.getBandNames(); if (bandNames.length == 0) { int numBands = header.getNumBands(); if (numBands == 0) { return new String[]{"Band"}; } else { bandNames = new String[numBands]; for (int i = 0; i < bandNames.length; i++) { bandNames[i] = "Band_" + (i + 1); } return bandNames; } } else { return bandNames; } } EnviProductReader(ProductReaderPlugIn readerPlugIn); @Override void close(); @Override TreeNode<File> getProductComponents();  }
@Test public void testParseBandNames_emptyBandnameProperty() throws IOException { final StringReader reader = new StringReader(HeaderTest.createMandatoryHeader() + "band names = {}"); final Header header = new Header(new BufferedReader(reader)); final String[] bandNames = EnviProductReader.getBandNames(header); assertEquals(1, bandNames.length); assertEquals("Band", bandNames[0]); }
@Test public void testParseBandNames_noBandnameProperty() throws IOException { final StringReader reader = new StringReader(HeaderTest.createMandatoryHeader()); final Header header = new Header(new BufferedReader(reader)); final String[] bandNames = EnviProductReader.getBandNames(header); assertEquals(1, bandNames.length); assertEquals("Band", bandNames[0]); }
@Test public void testParseBandNames_withBandnameProperty() throws IOException { final StringReader reader = new StringReader(HeaderTest.createMandatoryHeader() + "band names = { myband_1, myband_2}"); final Header header = new Header(new BufferedReader(reader)); final String[] bandNames = EnviProductReader.getBandNames(header); assertEquals(2, bandNames.length); assertEquals("myband_1", bandNames[0]); assertEquals("myband_2", bandNames[1]); }
@Test public void testParseBandNames_withBandNumberProperty() throws IOException { final StringReader reader = new StringReader(HeaderTest.createMandatoryHeader() + "bands = 3"); final Header header = new Header(new BufferedReader(reader)); final String[] bandNames = EnviProductReader.getBandNames(header); assertEquals(3, bandNames.length); assertEquals("Band_1", bandNames[0]); assertEquals("Band_2", bandNames[1]); assertEquals("Band_3", bandNames[2]); }