@Test
public void testSelectingEmptyBands() throws Exception {
DefaultLoaderFactory loaderFactory = new DefaultLoaderFactory();
loaderFactory.setGroovyDataLoader(new GroovyDataLoader(new DefaultScriptingImpl()));
DataExtractorImpl dataExtractor = new DataExtractorImpl(loaderFactory) {
{
emptyMap = EMPTY_MAP;
}
};
dataExtractor.setPutEmptyRowIfNoDataSelected(true);
Report report = createReport();
BandData rootBand = rootBand();
dataExtractor.extractData(report, new HashMap<String, Object>(), rootBand);
System.out.println(rootBand);
Assert.assertEquals(1, rootBand.getChildrenList().size());
BandData band1 = rootBand.getChildrenList().get(0);
Assert.assertEquals(emptyMap, band1.getData());
Assert.assertEquals(1, band1.getChildrenList().size());
Assert.assertEquals(emptyMap, band1.getChildrenList().get(0).getData());
dataExtractor.setPutEmptyRowIfNoDataSelected(false);
rootBand = rootBand();
dataExtractor.extractData(report, new HashMap<String, Object>(), rootBand);
System.out.println(rootBand);
Assert.assertEquals(0, rootBand.getChildrenList().size());
}