test_class.declarator: topTenController
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private TopTenController topTenController;
test_class.type: TopTenController
test_class.var_name: topTenController
test_class.file: web/src/test/java/org/devgateway/ocds/web/rest/controller/TopTenControllerTest.java
test_class.identifier: TopTenControllerTest
test_class.superclass: extends AbstractEndPointControllerTest
test_case.body: @Test
      public void topTenLargestSuppliers() throws Exception {
          final List<Document> topTenLargestSuppliers = topTenController
                  .topTenLargestSuppliers(new YearFilterPagingRequest());
  
  
          final Document first = topTenLargestSuppliers.get(0);
          Assert.assertEquals(6000000d, first.get(TopTenController.Keys.TOTAL_AWARD_AMOUNT));
          Assert.assertEquals(1, first.get(TopTenController.Keys.TOTAL_CONTRACTS));
          Assert.assertEquals("E09000005",
                  ((Collection) first.get(TopTenController.Keys.PROCURING_ENTITY_IDS)).iterator().next());
          Assert.assertEquals("GB-COH-1234567845", first.get(TopTenController.Keys.SUPPLIER_ID));
          Assert.assertEquals(1, first.get(TopTenController.Keys.PROCURING_ENTITY_IDS_COUNT));
  
          Assert.assertEquals(2, topTenLargestSuppliers.size());
  
      }
test_case.class_method_signature: TopTenControllerTest.topTenLargestSuppliers()
test_case.full_signature: @Test public void topTenLargestSuppliers()
test_case.identifier: topTenLargestSuppliers
test_case.invocations: topTenLargestSuppliers get assertEquals get assertEquals get assertEquals next iterator get assertEquals get assertEquals get assertEquals size
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void topTenLargestSuppliers()
focal_class.file: web/src/main/java/org/devgateway/ocds/web/rest/controller/TopTenController.java
focal_class.identifier: TopTenController
focal_class.class_method_signature: TopTenController.topTenLargestAwards(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation(value = "Returns the top ten largest active awards." + " The amount is taken from the award.value field. The returned data will contain" + "the following fields: " + "awards.date, awards.suppliers.name, " + "awards.value.amount, awards.suppliers.name, planning.budget (if any)") @RequestMapping(value = "/api/topTenLargestAwards", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> topTenLargestAwards(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: topTenLargestAwards
focal_class.modifiers: @ApiOperation(value = "Returns the top ten largest active awards." + " The amount is taken from the award.value field. The returned data will contain" + "the following fields: " + "awards.date, awards.suppliers.name, " + "awards.value.amount, awards.suppliers.name, planning.budget (if any)") @RequestMapping(value = "/api/topTenLargestAwards", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> topTenLargestAwards(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TopTenController.topTenLargestTenders(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation(value = "Returns the top ten largest active tenders." + " The amount is taken from the tender.value.amount field." + " The returned data will contain" + "the following fields: " + "tender.date, tender.value.amount, tender.tenderPeriod, " + "tender.procuringEntity.name") @RequestMapping(value = "/api/topTenLargestTenders", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> topTenLargestTenders(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: topTenLargestTenders
focal_class.modifiers: @ApiOperation(value = "Returns the top ten largest active tenders." + " The amount is taken from the tender.value.amount field." + " The returned data will contain" + "the following fields: " + "tender.date, tender.value.amount, tender.tenderPeriod, " + "tender.procuringEntity.name") @RequestMapping(value = "/api/topTenLargestTenders", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> topTenLargestTenders(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.class_method_signature: TopTenController.topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.full_signature: @ApiOperation(value = "This endpoint should return the following data for the Top 10 suppliers (by award value)." + "Returns supplier id, total awarded amount of all awarded contracts, count of awarded contracts," + "Ids of the procuring entities from which they have received an award, and their count. " + "All filters ally here, the year filter uses the awards.date field.") @RequestMapping(value = "/api/topTenSuppliers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.identifier: topTenLargestSuppliers
focal_class.modifiers: @ApiOperation(value = "This endpoint should return the following data for the Top 10 suppliers (by award value)." + "Returns supplier id, total awarded amount of all awarded contracts, count of awarded contracts," + "Ids of the procuring entities from which they have received an award, and their count. " + "All filters ally here, the year filter uses the awards.date field.") @RequestMapping(value = "/api/topTenSuppliers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.return: List<Document>
focal_class.signature: List<Document> topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_class.superclass: extends GenericOCDSController
focal_method.body: @ApiOperation(value = "This endpoint should return the following data for the Top 10 suppliers (by award value)."
              + "Returns supplier id, total awarded amount of all awarded contracts, count of awarded contracts,"
              + "Ids of the procuring entities from which they have received an award, and their count. "
              + "All filters ally here, the year filter uses the awards.date field.")
      @RequestMapping(value = "/api/topTenSuppliers", method = {RequestMethod.POST,
              RequestMethod.GET},
              produces = "application/json")
      public List<Document> topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter) {
  
          BasicDBObject project = new BasicDBObject();
          project.put(Fields.UNDERSCORE_ID, 0);
          project.put(MongoConstants.FieldNames.AWARDS_SUPPLIERS_ID, 1);
          project.put(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT, 1);
          project.put(MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_ID, 1);
  
          BasicDBObject group = new BasicDBObject();
          group.put(Fields.UNDERSCORE_ID, ref(MongoConstants.FieldNames.AWARDS_SUPPLIERS_ID));
          group.put(
                  Keys.TOTAL_AWARD_AMOUNT, new BasicDBObject("$sum", ref(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT)));
          group.put(Keys.TOTAL_CONTRACTS, new BasicDBObject("$sum", 1));
          group.put(
                  Keys.PROCURING_ENTITY_IDS,
                  new BasicDBObject("$addToSet", ref(MongoConstants.FieldNames.TENDER_PROCURING_ENTITY_ID))
          );
  
  
          Aggregation agg = newAggregation(
                  match(where(MongoConstants.FieldNames.AWARDS_VALUE_AMOUNT).exists(true)
                          .and(MongoConstants.FieldNames.AWARDS_STATUS)
                          .is(Award.Status.active.toString())
                          .andOperator(getDefaultFilterCriteria(filter))),
                  unwind("awards"),
                  match(where(MongoConstants.FieldNames.AWARDS_STATUS).is(Award.Status.active.toString())),
                  unwind("awards.suppliers"),
                  match(getYearFilterCriteria(filter.awardFiltering(), MongoConstants.FieldNames.AWARDS_DATE)),
                  new CustomProjectionOperation(project),
                  new CustomGroupingOperation(group),
                  sort(Direction.DESC, Keys.TOTAL_AWARD_AMOUNT),
                  limit(10),
                  project().and(Fields.UNDERSCORE_ID).
                          as(Keys.SUPPLIER_ID).
                          andInclude(Keys.TOTAL_AWARD_AMOUNT, Keys.TOTAL_CONTRACTS, Keys.PROCURING_ENTITY_IDS)
                          .andExclude(Fields.UNDERSCORE_ID)
                          .and(Keys.PROCURING_ENTITY_IDS).size().as(Keys.PROCURING_ENTITY_IDS_COUNT)
          );
  
          return releaseAgg(agg);
      }
focal_method.class_method_signature: TopTenController.topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_method.full_signature: @ApiOperation(value = "This endpoint should return the following data for the Top 10 suppliers (by award value)." + "Returns supplier id, total awarded amount of all awarded contracts, count of awarded contracts," + "Ids of the procuring entities from which they have received an award, and their count. " + "All filters ally here, the year filter uses the awards.date field.") @RequestMapping(value = "/api/topTenSuppliers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_method.identifier: topTenLargestSuppliers
focal_method.invocations: put put put put put ref put ref put put ref newAggregation match andOperator is and exists where toString getDefaultFilterCriteria unwind match is where toString unwind match getYearFilterCriteria awardFiltering sort limit as size and andExclude andInclude as and project releaseAgg
focal_method.modifiers: @ApiOperation(value = "This endpoint should return the following data for the Top 10 suppliers (by award value)." + "Returns supplier id, total awarded amount of all awarded contracts, count of awarded contracts," + "Ids of the procuring entities from which they have received an award, and their count. " + "All filters ally here, the year filter uses the awards.date field.") @RequestMapping(value = "/api/topTenSuppliers", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_method.parameters: (@ModelAttribute @Valid final YearFilterPagingRequest filter)
focal_method.return: List<Document>
focal_method.signature: List<Document> topTenLargestSuppliers(@ModelAttribute @Valid final YearFilterPagingRequest filter)