test_class.declarator: tendersAwardsYears
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private TendersAwardsYears tendersAwardsYears;
test_class.type: TendersAwardsYears
test_class.var_name: tendersAwardsYears
test_class.file: web/src/test/java/org/devgateway/ocds/web/rest/controller/TendersAwardsYearsTest.java
test_class.identifier: TendersAwardsYearsTest
test_class.superclass: extends AbstractEndPointControllerTest
test_case.body: @Test
      public void tendersAwardsYears() throws Exception {
          final List<Document> response = tendersAwardsYears.tendersAwardsYears();
  
          final Document first = response.get(0);
          int year = (int) first.get(Fields.UNDERSCORE_ID);
          Assert.assertEquals(2014, year);
  
          final Document second = response.get(1);
          year = (int) second.get(Fields.UNDERSCORE_ID);
          Assert.assertEquals(2015, year);
  
          final Document third = response.get(2);
          year = (int) third.get(Fields.UNDERSCORE_ID);
          Assert.assertEquals(2016, year);
      }
test_case.class_method_signature: TendersAwardsYearsTest.tendersAwardsYears()
test_case.full_signature: @Test public void tendersAwardsYears()
test_case.identifier: tendersAwardsYears
test_case.invocations: tendersAwardsYears get get assertEquals get get assertEquals get get assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void tendersAwardsYears()
focal_class.file: web/src/main/java/org/devgateway/ocds/web/rest/controller/TendersAwardsYears.java
focal_class.identifier: TendersAwardsYears
focal_class.class_method_signature: TendersAwardsYears.tendersAwardsYears()
focal_class.full_signature: @ApiOperation(value = "Computes all available years from awards.date, tender.tenderPeriod.startDate") @RequestMapping(value = "/api/tendersAwardsYears", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> tendersAwardsYears()
focal_class.identifier: tendersAwardsYears
focal_class.modifiers: @ApiOperation(value = "Computes all available years from awards.date, tender.tenderPeriod.startDate") @RequestMapping(value = "/api/tendersAwardsYears", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_class.parameters: ()
focal_class.return: List<Document>
focal_class.signature: List<Document> tendersAwardsYears()
focal_class.superclass: extends GenericOCDSController
focal_method.body: @ApiOperation(value = "Computes all available years from awards.date, tender.tenderPeriod.startDate")
      @RequestMapping(value = "/api/tendersAwardsYears", method = {RequestMethod.POST,
              RequestMethod.GET}, produces = "application/json")
      public List<Document> tendersAwardsYears() {
  
          BasicDBObject project1 = new BasicDBObject();
  
          project1.put(
                  "tenderYear",
                  new BasicDBObject(
                          "$cond",
                          Arrays.asList(
                                  new BasicDBObject(
                                          "$gt",
                                          Arrays.asList(ref(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE), null)
                                  ),
                                  new BasicDBObject("$year", ref(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)),
                                  null
                          )
                  )
          );
  
          project1.put(
                  "awardYear",
                  new BasicDBObject("$cond", Arrays.asList(
                          new BasicDBObject("$gt", Arrays.asList(ref(MongoConstants.FieldNames.AWARDS_DATE), null)),
                          new BasicDBObject("$year", ref(MongoConstants.FieldNames.AWARDS_DATE)), null
                  ))
          );
          project1.put(Fields.UNDERSCORE_ID, 0);
  
          BasicDBObject project2 = new BasicDBObject();
          project2.put("year", Arrays.asList("$tenderYear", "$awardYear"));
  
          Aggregation agg = Aggregation.newAggregation(
                  project().and(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)
                          .as(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE)
                          .and(MongoConstants.FieldNames.AWARDS_DATE)
                          .as(MongoConstants.FieldNames.AWARDS_DATE),
                  match(new Criteria().orOperator(
                          where(MongoConstants.FieldNames.TENDER_PERIOD_START_DATE).exists(true),
                          where(MongoConstants.FieldNames.AWARDS_DATE).exists(true)
                  )),
                  new CustomUnwindOperation("$awards", true), new CustomProjectionOperation(project1),
                  new CustomProjectionOperation(project2), new CustomUnwindOperation("$year"),
                  match(where("year").ne(null)),
                  new CustomGroupingOperation(new BasicDBObject(Fields.UNDERSCORE_ID, "$year")),
                  new CustomSortingOperation(new BasicDBObject(Fields.UNDERSCORE_ID, 1))
          );
  
          return releaseAgg(agg);
      }
focal_method.class_method_signature: TendersAwardsYears.tendersAwardsYears()
focal_method.full_signature: @ApiOperation(value = "Computes all available years from awards.date, tender.tenderPeriod.startDate") @RequestMapping(value = "/api/tendersAwardsYears", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public List<Document> tendersAwardsYears()
focal_method.identifier: tendersAwardsYears
focal_method.invocations: put asList asList ref ref put asList asList ref ref put put asList newAggregation as and as and project match orOperator exists where exists where match ne where releaseAgg
focal_method.modifiers: @ApiOperation(value = "Computes all available years from awards.date, tender.tenderPeriod.startDate") @RequestMapping(value = "/api/tendersAwardsYears", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json") public
focal_method.parameters: ()
focal_method.return: List<Document>
focal_method.signature: List<Document> tendersAwardsYears()