TotalCancelledTendersByYearController extends GenericOCDSController { @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") public List<Document> totalCancelledTendersByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter) { DBObject project = new BasicDBObject(); addYearlyMonthlyProjection(filter, project, ref(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)); project.put(MongoConstants.FieldNames.TENDER_VALUE_AMOUNT, 1); Aggregation agg = newAggregation( match(where(MongoConstants.FieldNames.TENDER_STATUS).is(Tender.Status.cancelled.toString()) .and(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE).exists(true) .andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), new CustomOperation(new Document("$project", project)), getYearlyMonthlyGroupingOperation(filter). sum(ref(MongoConstants.FieldNames.TENDER_VALUE_AMOUNT)).as(Keys.TOTAL_CANCELLED_TENDERS_AMOUNT), transformYearlyGrouping(filter).andInclude(Keys.TOTAL_CANCELLED_TENDERS_AMOUNT), getSortByYearMonth(filter)); return releaseAgg(agg); }  @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<Document> totalCancelledTendersByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter);  }
@Test public void totalCancelledTendersByYear() throws Exception { final List<Document> totalCancelledTendersByYear = totalCancelledTendersByYearController .totalCancelledTendersByYear(new YearFilterPagingRequest()); Assert.assertEquals(0, totalCancelledTendersByYear.size()); }