### Question:
CountPlansTendersAwardsController extends GenericOCDSController { @ApiOperation(value = "Count the awards and group the results by year. " + "The year is calculated from the awards.date field.") @RequestMapping(value = "/api/countAwardsByYear", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> countAwardsByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter) { DBObject project0 = new BasicDBObject(); project0.put("awards", 1); DBObject project = new BasicDBObject(); addYearlyMonthlyProjection(filter, project, ref(MongoConstants.FieldNames.AWARDS_DATE)); Aggregation agg = Aggregation.newAggregation(match(where("awards.0").exists(true). andOperator(getDefaultFilterCriteria(filter))), new CustomOperation(new Document("$project", project0)), unwind("awards"), match(where(MongoConstants.FieldNames.AWARDS_DATE).exists(true). andOperator( getYearFilterCriteria(filter.awardFiltering(), MongoConstants.FieldNames.AWARDS_DATE))), new CustomOperation(new Document("$project", project)), group(getYearlyMonthlyGroupingFields(filter)).count().as(Keys.COUNT), transformYearlyGrouping(filter).andInclude(Keys.COUNT), getSortByYearMonth(filter), skip(filter.getSkip()), limit(filter.getPageSize()) ); return releaseAgg(agg); }  @ApiOperation(value = "Count the tenders and group the results by year. The year is calculated from " + "tender.tenderPeriod.startDate.") @RequestMapping(value = "/api/countTendersByYear", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") List<Document> countTendersByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter); @ApiOperation(value = "Count the awards and group the results by year. " + "The year is calculated from the awards.date field.") @RequestMapping(value = "/api/countAwardsByYear", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") List<Document> countAwardsByYear(@ModelAttribute @Valid final YearFilterPagingRequest filter);  }### Answer:
@Test public void countAwardsByYear() throws Exception { final List<Document> countAwardsByYear = countPlansTendersAwardsController .countAwardsByYear(new YearFilterPagingRequest()); final Document first = countAwardsByYear.get(0); int year = (int) first.get(CountPlansTendersAwardsController.Keys.YEAR); int count = (int) first.get(CountPlansTendersAwardsController.Keys.COUNT); Assert.assertEquals(2015, year); Assert.assertEquals(1, count); final Document second = countAwardsByYear.get(1); year = (int) second.get(CountPlansTendersAwardsController.Keys.YEAR); count = (int) second.get(CountPlansTendersAwardsController.Keys.COUNT); Assert.assertEquals(2016, year); Assert.assertEquals(2, count); }