PixExRasterNamesFactory implements RasterNamesFactory { @Override public String[] getRasterNames(Product product) { final String productType = product.getProductType(); if (rasterNamesMap.containsKey(productType)) { return rasterNamesMap.get(productType); } else { final String[] rasterNames = extractRasterNames(product, aggregatorStrategy); rasterNamesMap.put(productType, rasterNames); return rasterNames; } } PixExRasterNamesFactory(boolean exportBands, boolean exportTiePoints, boolean exportMasks,
                                   AggregatorStrategy aggregatorStrategy); @Override String[] getRasterNames(Product product); @Override String[] getUniqueRasterNames(Product product);  }
@Test public void testGetRasterNamesToBeExported_exportAll() { final boolean exportBands = true; final boolean exportTiePoints = true; final boolean exportMasks = true; final PixExRasterNamesFactory pixExRasterNamesFactory = new PixExRasterNamesFactory(exportBands, exportTiePoints, exportMasks, null); final String[] rasterNames = pixExRasterNamesFactory.getRasterNames(product); final String[] expected = {"val1", "val2", "val3", "tp1", "tp2", "tp3", "mask1", "mask2", "mask3"}; assertThat(rasterNames, equalTo(expected)); }
@Test public void testGetRasterNamesToBeExported_exportBandsOnly() { final boolean exportBands = true; final PixExRasterNamesFactory pixExRasterNamesFactory = new PixExRasterNamesFactory(exportBands, false, false, null); final String[] rasterNames = pixExRasterNamesFactory.getRasterNames(product); final String[] expected = {"val1", "val2", "val3"}; assertThat(rasterNames, equalTo(expected)); }
@Test public void testGetRasterNamesToBeExported_exportTiepointsOnyl() { final boolean exportTiePoints = true; final PixExRasterNamesFactory pixExRasterNamesFactory = new PixExRasterNamesFactory(false, exportTiePoints, false, null); final String[] rasterNames = pixExRasterNamesFactory.getRasterNames(product); final String[] expected = {"tp1", "tp2", "tp3"}; assertThat(rasterNames, equalTo(expected)); }
@Test public void testGetRasterNamesToBeExported_exportMasksOnly() { final boolean exportMasks = true; final PixExRasterNamesFactory pixExRasterNamesFactory = new PixExRasterNamesFactory(false, false, exportMasks, null); final String[] rasterNames = pixExRasterNamesFactory.getRasterNames(product); final String[] expected = {"mask1", "mask2", "mask3"}; assertThat(rasterNames, equalTo(expected)); }
@Test public void testGetRasterNamesWithAggregationStrategy() { final AggregatorStrategy aggregatorStrategy = new AggregatorStrategy() { @Override public Number[] getValues(Record record, int rasterIndex) { return new Number[0]; } @Override public int getValueCount() { return 3; } @Override public String[] getSuffixes() { return new String[]{"first", "second", "last"}; } }; final PixExRasterNamesFactory pixExRasterNamesFactory = new PixExRasterNamesFactory(true, false, false, aggregatorStrategy); final String[] rasterNames = pixExRasterNamesFactory.getRasterNames(product); final String[] expected = { "val1_first", "val1_second", "val1_last", "val2_first", "val2_second", "val2_last", "val3_first", "val3_second", "val3_last" }; assertThat(rasterNames, equalTo(expected)); }