Search in sources :

Example 1 with DummyPivotTableData2

use of org.activityinfo.server.report.DummyPivotTableData2 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.legacy.shared.reports.content.FilterDescription) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 2 with DummyPivotTableData2

use of org.activityinfo.server.report.DummyPivotTableData2 in project activityinfo by bedatadriven.

the class PivotTableRendererTest method exportWithInvalidCharsInSheetnames.

// AI-1413
@Test
public void exportWithInvalidCharsInSheetnames() {
    PivotTableReportElement element = new DummyPivotTableData2().testElement();
    element.setTitle("CPSC: 4Ws");
    ExcelPivotTableRenderer renderer = new ExcelPivotTableRenderer();
    renderer.render(new HSSFWorkbook(), element);
}
Also used : DummyPivotTableData2(org.activityinfo.server.report.DummyPivotTableData2) PivotTableReportElement(org.activityinfo.legacy.shared.reports.model.PivotTableReportElement) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Example 3 with DummyPivotTableData2

use of org.activityinfo.server.report.DummyPivotTableData2 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());
}
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.legacy.shared.reports.model.PivotTableReportElement) File(java.io.File) Sheet(org.apache.poi.ss.usermodel.Sheet) HSSFWorkbook(org.apache.poi.hssf.usermodel.HSSFWorkbook) Test(org.junit.Test)

Aggregations

PivotTableReportElement (org.activityinfo.legacy.shared.reports.model.PivotTableReportElement)3 DummyPivotTableData2 (org.activityinfo.server.report.DummyPivotTableData2)3 HSSFWorkbook (org.apache.poi.hssf.usermodel.HSSFWorkbook)3 Test (org.junit.Test)3 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 FilterDescription (org.activityinfo.legacy.shared.reports.content.FilterDescription)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1