use of org.activityinfo.legacy.shared.reports.model.PivotTableReportElement in project activityinfo by bedatadriven.
the class PivotTableRendererTest method testNoColumnDimensions.
@Test
public void testNoColumnDimensions() {
// input test data : element + content
DummyPivotTableData2 testData = new DummyPivotTableData2();
PivotTableReportElement element = testData.testElement();
// Destination book
HSSFWorkbook book = new HSSFWorkbook();
// CLASS under test
ExcelPivotTableRenderer renderer = new ExcelPivotTableRenderer();
renderer.render(book, element);
// Write output to disk
try {
File outputFile = new File("build/report-tests");
outputFile.mkdirs();
OutputStream out = new FileOutputStream(new File(outputFile, "testNoColumnDimensions.xls"));
book.write(out);
out.close();
} catch (IOException e) {
e.printStackTrace();
}
// VERIFY output
Sheet sheet = book.getSheetAt(0);
Assert.assertEquals(100, (int) sheet.getRow(5).getCell(1).getNumericCellValue());
}
use of org.activityinfo.legacy.shared.reports.model.PivotTableReportElement in project activityinfo by bedatadriven.
the class PivotTableGeneratorTest method testIndicatorSortOrder.
@Test
public void testIndicatorSortOrder() {
// test input data: user
User user = new User();
user.setLocale("fr");
// test input data: PivotTableElement
PivotTableReportElement element = new PivotTableReportElement();
Dimension indicatorDim = new Dimension(DimensionType.Indicator);
element.addRowDimension(indicatorDim);
// test input data: aggregated results
List<Bucket> buckets = new ArrayList<Bucket>();
buckets.add(newBucket(300, category(indicatorDim, 1, "Nb. menages", 3)));
buckets.add(newBucket(400, category(indicatorDim, 2, "Nb. personnes", 1)));
buckets.add(newBucket(600, category(indicatorDim, 3, "Nb. deplaces", 2)));
// collaborator : PivotDAO
DispatcherSync dispatcher = createMock(DispatcherSync.class);
expect(dispatcher.execute(isA(PivotSites.class))).andReturn(new PivotSites.PivotResult(buckets));
replay(dispatcher);
// CLASS UNDER TEST!!
PivotTableGenerator generator = new PivotTableGenerator(dispatcher);
generator.generate(user, element, dummyFilter(), null);
Assert.assertNotNull("element content", element.getContent());
List<PivotTableData.Axis> rows = element.getContent().getData().getRootRow().getChildren();
Assert.assertEquals(2, ((EntityCategory) rows.get(0).getCategory()).getId());
Assert.assertEquals(3, ((EntityCategory) rows.get(1).getCategory()).getId());
Assert.assertEquals(1, ((EntityCategory) rows.get(2).getCategory()).getId());
}
Aggregations