Search in sources :

Example 31 with Report

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

the class JaxbParseTest method parseXml.

public Report parseXml(String filename) throws JAXBException {
    JAXBContext jc = JAXBContext.newInstance(Report.class.getPackage().getName());
    Unmarshaller um = jc.createUnmarshaller();
    um.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
    return (Report) um.unmarshal(new InputStreamReader(getClass().getResourceAsStream("/report-def/parse-test/" + filename)));
}
Also used : InputStreamReader(java.io.InputStreamReader) Report(org.activityinfo.shared.report.model.Report) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 32 with Report

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

the class ReadWriteReportTest method readWriteReportTest.

@Test
public void readWriteReportTest() throws Throwable {
    Report report = new Report();
    MapReportElement map = new MapReportElement();
    map.getLayers().add(new BubbleMapLayer());
    PiechartMapLayer pielayer = new PiechartMapLayer();
    Slice slice1 = new Slice();
    slice1.setColor("FF00AA");
    slice1.setIndicatorId(1);
    Slice slice2 = new Slice();
    slice2.setColor("00FFAA");
    slice2.setIndicatorId(2);
    pielayer.getSlices().add(slice1);
    pielayer.getSlices().add(slice2);
    map.getLayers().add(pielayer);
    report.getElements().add(map);
    Report.class.getPackage();
    JAXBContext jc = JAXBContext.newInstance(Report.class.getPackage().getName());
    Marshaller marshaller = jc.createMarshaller();
    marshaller.setEventHandler(new javax.xml.bind.helpers.DefaultValidationEventHandler());
    marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    FileOutputStream fo = new FileOutputStream("SomeXmlTest.xml");
    marshaller.marshal(report, fo);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) Marshaller(javax.xml.bind.Marshaller) Report(org.activityinfo.shared.report.model.Report) Slice(org.activityinfo.shared.report.model.layers.PiechartMapLayer.Slice) FileOutputStream(java.io.FileOutputStream) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) JAXBContext(javax.xml.bind.JAXBContext) PiechartMapLayer(org.activityinfo.shared.report.model.layers.PiechartMapLayer) Test(org.junit.Test)

Example 33 with Report

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

the class ReportsTest method testConsolideDesActivitesReport.

@Test
public void testConsolideDesActivitesReport() throws Throwable {
    // Setup test
    Report report = getReport("realworld/ConsolideDesActivites.xml");
    reportGenerator.generate(user, report, null, null);
    TableElement pivotTable = (TableElement) report.getElements().get(2);
    MapReportElement map1 = pivotTable.getMap();
    BubbleMapLayer bubbleMap = (BubbleMapLayer) map1.getLayers().get(0);
    assertTrue("Arabic numbering expected", bubbleMap.getLabelSequence() instanceof ArabicNumberSequence);
    assertEquals("MinRadius of 8 expected", bubbleMap.getMinRadius(), 8);
    assertEquals("MaxRadius of 14 expected", bubbleMap.getMaxRadius(), 14);
    assertEquals("Graduated scaling expected", bubbleMap.getScaling(), ScalingType.Graduated);
}
Also used : MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ArabicNumberSequence(org.activityinfo.shared.report.model.labeling.ArabicNumberSequence) Report(org.activityinfo.shared.report.model.Report) BubbleMapLayer(org.activityinfo.shared.report.model.layers.BubbleMapLayer) TableElement(org.activityinfo.shared.report.model.TableElement) Test(org.junit.Test)

Example 34 with Report

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

the class ReportsTest method testFullReport.

@Test
@Ignore("need dbunit xml with matching data")
public void testFullReport() throws Throwable {
    Report report = getReport("full-test.xml");
    reportGenerator.generate(user, report, null, null);
    for (RenderElement.Format format : RenderElement.Format.values()) {
        if (format != RenderElement.Format.Excel && format != RenderElement.Format.Excel_Data) {
            Renderer renderer = factory.get(format);
            FileOutputStream fos = new FileOutputStream("target/report-tests/full-test" + renderer.getFileSuffix());
            renderer.render(report, fos);
            fos.close();
        }
    }
}
Also used : RenderElement(org.activityinfo.shared.command.RenderElement) Report(org.activityinfo.shared.report.model.Report) FileOutputStream(java.io.FileOutputStream) Renderer(org.activityinfo.server.report.renderer.Renderer) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 35 with Report

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

the class ReportsTest method testApplesReport.

@Test
public void testApplesReport() throws Throwable {
    Report report = getReport("realworld/ApplesReport.xml");
    reportGenerator.generate(user, report, null, null);
    ReportElement element = report.getElements().get(0);
    element.getContent();
    assertEquals("Expected different report title", report.getTitle(), "Phase one apple report");
    assertEquals("Expected different report description", report.getDescription(), "Apples come in different shapes, colors and taste");
    assertEquals("Expected only one filter", report.getFilter().getRestrictedDimensions().size(), 1);
    assertEquals("Expected one element", report.getElements().size(), 1);
    assertTrue("Expected pivottable element", element.getContent() instanceof PivotContent);
    assertEquals("Expected title: 'Apples, bananas and oranges'", element.getTitle(), "Apples, bananas and oranges");
}
Also used : Report(org.activityinfo.shared.report.model.Report) PivotContent(org.activityinfo.shared.report.content.PivotContent) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) ReportElement(org.activityinfo.shared.report.model.ReportElement) Test(org.junit.Test)

Aggregations

Report (org.activityinfo.shared.report.model.Report)37 Test (org.junit.Test)22 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)11 ReportContent (org.activityinfo.shared.report.content.ReportContent)9 PivotTableReportElement (org.activityinfo.shared.report.model.PivotTableReportElement)9 PivotChartReportElement (org.activityinfo.shared.report.model.PivotChartReportElement)8 FileOutputStream (java.io.FileOutputStream)5 DummyPivotTableData (org.activityinfo.server.report.DummyPivotTableData)4 TileBaseMap (org.activityinfo.shared.map.TileBaseMap)4 TableElement (org.activityinfo.shared.report.model.TableElement)4 TextReportElement (org.activityinfo.shared.report.model.TextReportElement)4 IOException (java.io.IOException)3 JAXBContext (javax.xml.bind.JAXBContext)3 Unmarshaller (javax.xml.bind.Unmarshaller)3 ReportDefinition (org.activityinfo.server.database.hibernate.entity.ReportDefinition)3 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)3 IconMapMarker (org.activityinfo.shared.report.content.IconMapMarker)3 MapContent (org.activityinfo.shared.report.content.MapContent)3 MapMarker (org.activityinfo.shared.report.content.MapMarker)3 PivotContent (org.activityinfo.shared.report.content.PivotContent)3