TenderPercentagesExcelController extends ExcelChartOCDSController { @ApiOperation(value = "Exports *Cancelled funding (percentage)* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/cancelledFundingPercentageExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) public void cancelledFundingPercentageExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter, final HttpServletResponse response) throws IOException { final String chartTitle = translationService.getValue(filter.getLanguage(), "charts:cancelledPercents:title"); final List<Document> totalCancelledTenders = tenderPercentagesController.percentTendersCancelled(filter); final List<?> categories = excelChartHelper.getCategoriesFromDBObject(getExportYearMonthXAxis(filter), totalCancelledTenders); final List<List<? extends Number>> values = new ArrayList<>(); final List<Number> percentCancelled = excelChartHelper.getValuesFromDBObject(totalCancelledTenders, categories, getExportYearMonthXAxis(filter), TenderPercentagesController.Keys.PERCENT_CANCELLED); if (!percentCancelled.isEmpty()) { values.add(percentCancelled); } final List<String> seriesTitle; if (!values.isEmpty()) { seriesTitle = Arrays.asList( translationService.getValue(filter.getLanguage(), "charts:cancelledPercents:yAxisName")); } else { seriesTitle = new ArrayList<>(); } response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=" + chartTitle + ".xlsx"); response.getOutputStream().write( excelChartGenerator.getExcelChart( ChartType.area, chartTitle, seriesTitle, categories, values)); }  @ApiOperation(value = "Exports *Cancelled funding (percentage)* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/cancelledFundingPercentageExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void cancelledFundingPercentageExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                     final HttpServletResponse response); @ApiOperation(value = "Exports *Percent of Tenders Using e-Bid* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/percentTendersUsingEBidExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void percentTendersUsingEBidExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                  final HttpServletResponse response); @ApiOperation(value = "Exports *Number of eBid Awards* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/numberTendersUsingEBidExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void numberTendersUsingEBidExcelChart(@ModelAttribute @Valid final LangYearFilterPagingRequest filter,
                                                 final HttpServletResponse response); @ApiOperation(value = "Exports *Percentage of plans with tender* dashboard in Excel format.") @RequestMapping(value = "/api/ocds/tendersWithLinkedProcurementPlanExcelChart", method = {RequestMethod.GET, RequestMethod.POST}) void tendersWithLinkedProcurementPlanExcelChart(@ModelAttribute @Valid
                                                           final LangYearFilterPagingRequest filter,
                                                           final HttpServletResponse response);  }
@Test public void cancelledFundingPercentageExcelChart() throws Exception { LangYearFilterPagingRequest filter = getLangYearFilterMockRequest(); tenderPercentagesExcelController.cancelledFundingPercentageExcelChart( filter, mockHttpServletResponse); final byte[] responseOutput = mockHttpServletResponse.getContentAsByteArray(); final Workbook workbook = new XSSFWorkbook(new ByteArrayInputStream(responseOutput)); Assert.assertNotNull(workbook); final Sheet sheet = workbook.getSheet(ChartType.area.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:cancelledPercents: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 area chart", 1, ctChart.getPlotArea().getAreaChartArray().length); }