Search in sources :

Example 56 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project ocvn by devgateway.

the class TenderPercentagesControllerTest method percentTendersWithTwoOrMoreTenderers.

@Test
public void percentTendersWithTwoOrMoreTenderers() throws Exception {
    final List<DBObject> percentTendersWithTwoOrMoreTenderers = tenderPercentagesController.percentTendersWithTwoOrMoreTenderers(new YearFilterPagingRequest());
    final DBObject first = percentTendersWithTwoOrMoreTenderers.get(0);
    int year = (int) first.get(TenderPercentagesController.Keys.YEAR);
    int totalTenders = (int) first.get(TenderPercentagesController.Keys.TOTAL_TENDERS);
    int totalTendersWithTwoOrMoreTenderers = (int) first.get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS);
    double percentTenders = (double) first.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(1, totalTenders);
    Assert.assertEquals(1, totalTendersWithTwoOrMoreTenderers);
    Assert.assertEquals(100.0, percentTenders, 0);
    final DBObject second = percentTendersWithTwoOrMoreTenderers.get(1);
    year = (int) second.get(TenderPercentagesController.Keys.YEAR);
    totalTenders = (int) second.get(TenderPercentagesController.Keys.TOTAL_TENDERS);
    totalTendersWithTwoOrMoreTenderers = (int) second.get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_TWO_OR_MORE_TENDERERS);
    percentTenders = (double) second.get(TenderPercentagesController.Keys.PERCENT_TENDERS);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(2, totalTenders);
    Assert.assertEquals(1, totalTendersWithTwoOrMoreTenderers);
    Assert.assertEquals(50.0, percentTenders, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Aggregations

YearFilterPagingRequest (org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest)56 Test (org.junit.Test)55 DBObject (com.mongodb.DBObject)54 BasicDBObject (com.mongodb.BasicDBObject)8 AbstractEndPointControllerTest (org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)5 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collection (java.util.Collection)2 ApiOperation (io.swagger.annotations.ApiOperation)1 BigDecimal (java.math.BigDecimal)1 LinkedHashSet (java.util.LinkedHashSet)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 Collectors (java.util.stream.Collectors)1 Valid (javax.validation.Valid)1 Release (org.devgateway.ocds.persistence.mongo.Release)1 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)1 MongoConstants (org.devgateway.ocds.persistence.mongo.constants.MongoConstants)1 BidSelectionMethodSearchController (org.devgateway.ocds.web.rest.controller.selector.BidSelectionMethodSearchController)1