Search in sources :

Example 21 with PivotTableReportElement

use of org.activityinfo.shared.report.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("target/report-tests");
        outputFile.mkdirs();
        OutputStream out = new FileOutputStream(outputFile.getAbsoluteFile() + "/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());
}
Also used : DummyPivotTableData2(org.activityinfo.server.report.DummyPivotTableData2) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) File(java.io.File) Sheet(org.apache.poi.ss.usermodel.Sheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 22 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class PivotTableRendererTest method veryLongFilter.

@Test
public void veryLongFilter() {
    // input test data : element + content
    DummyPivotTableData2 testData = new DummyPivotTableData2();
    PivotTableReportElement element = testData.testElement();
    // Filtering on 4000 indicators....
    Map<Integer, String> labelMap = Maps.newHashMap();
    for (int i = 1; i != 10000; ++i) {
        element.getFilter().addRestriction(DimensionType.Indicator, i);
        labelMap.put(i, "Very long indicator name " + i);
    }
    element.getContent().getFilterDescriptions().add(new FilterDescription(DimensionType.Indicator, labelMap));
    // Destination book
    HSSFWorkbook book = new HSSFWorkbook();
    // CLASS under test
    ExcelPivotTableRenderer renderer = new ExcelPivotTableRenderer();
    renderer.render(book, element);
}
Also used : DummyPivotTableData2(org.activityinfo.server.report.DummyPivotTableData2) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 23 with PivotTableReportElement

use of org.activityinfo.shared.report.model.PivotTableReportElement in project activityinfo by bedatadriven.

the class GeneratePivotTableHandlerTest method withNullAttribute.

@Test
public void withNullAttribute() throws CommandException {
    PivotTableReportElement element = new PivotTableReportElement();
    element.setRowDimensions(Arrays.asList(new Dimension(DimensionType.Indicator)));
    element.setColumnDimensions(Arrays.asList((Dimension) new AttributeGroupDimension(1)));
    Filter filter = new Filter();
    filter.addRestriction(DimensionType.Indicator, Arrays.asList(1, 2, 103));
    element.setFilter(filter);
    execute(new GeneratePivotTable(element));
}
Also used : Dimension(org.activityinfo.shared.report.model.Dimension) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) PivotTableReportElement(org.activityinfo.shared.report.model.PivotTableReportElement) AttributeGroupDimension(org.activityinfo.shared.report.model.AttributeGroupDimension) Test(org.junit.Test)

Aggregations

PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)23 Test (org.junit.Test)15 Dimension (org.activityinfo.shared.report.model.Dimension)10 Report (org.activityinfo.shared.report.model.Report)7 PivotContent (org.activityinfo.shared.report.content.PivotContent)6 AdminDimension (org.activityinfo.shared.report.model.AdminDimension)5 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)5 ArrayList (java.util.ArrayList)4 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)4 AttributeGroupDimension (org.activityinfo.shared.report.model.AttributeGroupDimension)4 PivotTableData (org.activityinfo.shared.report.content.PivotTableData)3 ReportContent (org.activityinfo.shared.report.content.ReportContent)3 DateDimension (org.activityinfo.shared.report.model.DateDimension)3 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2