FrequentTenderersController extends GenericOCDSController { @ApiOperation(value = "Counts the tenders/awards where the given supplier id is among the winners. " + "This assumes there is only one active award, which always seems to be the case, per tender. ") @RequestMapping(value = "/api/activeAwardsCount", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<DBObject> activeAwardsCount(@ModelAttribute @Valid final YearFilterPagingRequest filter) { Aggregation agg = newAggregation( match(where("awards.status").is("active") .andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), unwind("awards"), match(where("awards.status").is("active") .andOperator(getYearDefaultFilterCriteria(filter, MongoConstants.FieldNames.TENDER_PERIOD_START_DATE))), group().count().as("cnt"), project("cnt").andExclude(Fields.UNDERSCORE_ID) ); AggregationResults<DBObject> results = mongoTemplate.aggregate(agg, "release", DBObject.class); List<DBObject> tagCount = results.getMappedResults(); return tagCount; }  @ApiOperation(value = "Detect frequent pairs of tenderers that apply together to bids." + "We are only showing pairs if they applied to more than one bid together." + "We are sorting the results after the number of occurences, descending." + "You can use all the filters that are available along with pagination options.") @RequestMapping(value = "/api/frequentTenderers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") List<DBObject> frequentTenderers(@ModelAttribute @Valid final YearFilterPagingRequest filter); @ApiOperation(value = "Counts the tenders/awards where the given supplier id is among the winners. " + "This assumes there is only one active award, which always seems to be the case, per tender. ") @RequestMapping(value = "/api/activeAwardsCount", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") List<DBObject> activeAwardsCount(@ModelAttribute @Valid final YearFilterPagingRequest filter);  }
@Test public void activeAwardsCountTest() throws Exception { final List<DBObject> frequentTenderers = frequentTenderersController .activeAwardsCount(new YearFilterPagingRequest()); Assert.assertEquals(1, frequentTenderers.size()); Assert.assertEquals(2, frequentTenderers.get(0).get("cnt")); }