TotalCancelledTendersByYearController extends GenericOCDSController { @ApiOperation(value = "Total Cancelled tenders by year by cancel reason. " + "The tender amount is read from tender.value." + "The tender status has to be 'cancelled'. The year is retrieved from tender.tenderPeriod.startDate." + "The cancellation reason is read from tender.cancellationRationale.") @RequestMapping(value = "/api/totalCancelledTendersByYearByRationale", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") public List<DBObject> totalCancelledTendersByYearByRationale( @ModelAttribute @Valid final YearFilterPagingRequest filter) { DBObject project = new BasicDBObject(); project.put(Fields.UNDERSCORE_ID, 0); addYearlyMonthlyProjection(filter, project, "$tender.tenderPeriod.startDate"); project.put("tender.value.amount", 1); project.put("tender.cancellationRationale", 1); Aggregation agg = newAggregation( match(where("tender.status").is("cancelled").and("tender.tenderPeriod.startDate").exists(true) .andOperator(getYearDefaultFilterCriteria(filter, "tender.tenderPeriod.startDate"))), new CustomProjectionOperation(project), group(getYearlyMonthlyGroupingFields( filter, "$tender.cancellationRationale")) .sum("$tender.value.amount").as(Keys.TOTAL_CANCELLED_TENDERS_AMOUNT), getSortByYearMonth(filter)); AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class); List<DBObject> list = results.getMappedResults(); return list; }  @ApiOperation(value = "Total Cancelled tenders by year. The tender amount is read from tender.value." + "The tender status has to be 'cancelled'. The year is retrieved from tender.tenderPeriod.startDate.") @RequestMapping(value = "/api/totalCancelledTendersByYear", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") List<DBObject> totalCancelledTendersByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter); @ApiOperation(value = "Total Cancelled tenders by year by cancel reason. " + "The tender amount is read from tender.value." + "The tender status has to be 'cancelled'. The year is retrieved from tender.tenderPeriod.startDate." + "The cancellation reason is read from tender.cancellationRationale.") @RequestMapping(value = "/api/totalCancelledTendersByYearByRationale", method = { RequestMethod.POST, RequestMethod.GET }, produces = "application/json") List<DBObject> totalCancelledTendersByYearByRationale(
            @ModelAttribute @Valid final YearFilterPagingRequest filter);  }
@Test public void totalCancelledTendersByYearByRationale() throws Exception { final List<DBObject> totalCancelledTendersByYearByRationale = totalCancelledTendersByYearController .totalCancelledTendersByYearByRationale(new YearFilterPagingRequest()); Assert.assertEquals(0, totalCancelledTendersByYearByRationale.size()); }