Search in sources :

Example 6 with LangYearFilterPagingRequest

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

the class TendersByItemExcelControllerTest method numberOfTendersByItemExcelChart.

@Test
public void numberOfTendersByItemExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    tendersByItemExcelController.numberOfTendersByItemExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.barcol.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:bidsByItem: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) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) 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) 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)

Example 7 with LangYearFilterPagingRequest

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

the class ProcurementActivityByYearControllerTest method procurementActivityExcelChart.

@Test
public void procurementActivityExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    procurementActivityByYearController.procurementActivityExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.line.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:overview: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 line chart", 1, ctChart.getPlotArea().getLineChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) 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) 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)

Example 8 with LangYearFilterPagingRequest

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

the class AbstractExcelControllerTest method getLangYearFilterMockRequest.

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

Example 9 with LangYearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest in project oc-explorer by devgateway.

the class AverageTenderAndAwardsExcelControllerTest method bidTimelineExcelChart.

@Test
public void bidTimelineExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    averageTenderAndAwardsExcelController.bidTimelineExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.stackedbar.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:bidPeriod: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) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) 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) 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)

Example 10 with LangYearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest in project oc-explorer by devgateway.

the class ProcurementActivityByYearControllerTest method procurementActivityExcelChart.

@Test
public void procurementActivityExcelChart() throws Exception {
    LangYearFilterPagingRequest filter = getLangYearFilterMockRequest();
    procurementActivityByYearController.procurementActivityExcelChart(filter, mockHttpServletResponse);
    final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray();
    final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput));
    Assert.assertNotNull(workbook);
    final Sheet sheet = workbook.getSheet(ChartType.line.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:overview: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 line chart", 1, ctChart.getPlotArea().getLineChartArray().length);
}
Also used : XSSFChart(org.apache.poi.xssf.usermodel.XSSFChart) LangYearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.LangYearFilterPagingRequest) 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) 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

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