Search in sources :

Example 1 with LangGroupingFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest in project ocvn by devgateway.

the class AbstractExcelControllerTest method getLangGroupingFilterMockRequest.

public LangGroupingFilterPagingRequest getLangGroupingFilterMockRequest() {
    LangGroupingFilterPagingRequest filter = new LangGroupingFilterPagingRequest();
    filter.setLanguage(SettingsUtils.DEFAULT_LANGUAGE);
    return filter;
}
Also used : LangGroupingFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest)

Example 2 with LangGroupingFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest in project ocvn by devgateway.

the class CostEffectivenessExcelControllerTest method costEffectivenessExcelChart.

@Test
public void costEffectivenessExcelChart() throws Exception {
    LangGroupingFilterPagingRequest filter = getLangGroupingFilterMockRequest();
    costEffectivenessExcelController.costEffectivenessExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.stackedcol.toString());
    Assert.assertNotNull("check chart type, sheet name should be the same as the type", sheet);
    final XSSFDrawing drawing = (XSSFDrawing) sheet.getDrawingPatriarch();
    final List<XSSFChart> charts = drawing.getCharts();
    Assert.assertEquals("number of charts", 1, charts.size());
    final XSSFChart chart = charts.get(0);
    Assert.assertEquals("chart title", translationService.getValue(filter.getLanguage(), "charts:costEffectiveness:title"), chart.getTitle().getString());
    final List<? extends XSSFChartAxis> axis = chart.getAxis();
    Assert.assertEquals("number of axis", 2, axis.size());
    final CTChart ctChart = chart.getCTChart();
    Assert.assertEquals("Check if we have 1 bar chart", 1, ctChart.getPlotArea().getBarChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) CTChart(org.openxmlformats.schemas.drawingml.x2006.chart.CTChart) ByteArrayInputStream(java.io.ByteArrayInputStream) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Sheet(org.apache.poi.ss.usermodel.Sheet) LangGroupingFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest) XSSFWorkbook(org.apache.poi.xssf.usermodel.XSSFWorkbook) Workbook(org.apache.poi.ss.usermodel.Workbook) XSSFDrawing(org.apache.poi.xssf.usermodel.XSSFDrawing) Test(org.junit.Test)

Aggregations

LangGroupingFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.LangGroupingFilterPagingRequest)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 Workbook (org.apache.poi.ss.usermodel.Workbook)1 XSSFChart (org.apache.poi.xssf.usermodel.XSSFChart)1 XSSFDrawing (org.apache.poi.xssf.usermodel.XSSFDrawing)1 XSSFWorkbook (org.apache.poi.xssf.usermodel.XSSFWorkbook)1 Test (org.junit.Test)1 CTChart (org.openxmlformats.schemas.drawingml.x2006.chart.CTChart)1