Search in sources :

Example 91 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class OcdsControllerTest method ocdsPackages.

@Test
public void ocdsPackages() throws Exception {
    final List<ReleasePackage> releasePackages = ocdsController.ocdsPackages(new YearFilterPagingRequest());
    Assert.assertEquals(3, releasePackages.size());
}
Also used : ReleasePackage(org.devgateway.ocds.persistence.mongo.ReleasePackage) YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Test(org.junit.Test)

Example 92 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class TenderPercentagesControllerTest method percentTendersAwarded.

@Test
public void percentTendersAwarded() throws Exception {
    final List<DBObject> percentTendersAwarded = tenderPercentagesController.percentTendersAwarded(new YearFilterPagingRequest());
    final DBObject first = percentTendersAwarded.get(0);
    int year = (int) first.get(TenderPercentagesController.Keys.YEAR);
    int totalTendersWithOneOrMoreTenderers = (int) first.get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS);
    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, totalTendersWithOneOrMoreTenderers);
    Assert.assertEquals(1, totalTendersWithTwoOrMoreTenderers);
    Assert.assertEquals(100.0, percentTenders, 0);
    final DBObject second = percentTendersAwarded.get(1);
    year = (int) second.get(TenderPercentagesController.Keys.YEAR);
    totalTendersWithOneOrMoreTenderers = (int) second.get(TenderPercentagesController.Keys.TOTAL_TENDERS_WITH_ONE_OR_MORE_TENDERERS);
    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, totalTendersWithOneOrMoreTenderers);
    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)

Example 93 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer 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)

Example 94 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class TenderPercentagesControllerTest method percentTendersUsingEBid.

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

Example 95 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project oc-explorer by devgateway.

the class TenderPriceByTypeYearControllerTest method tenderPriceByProcurementMethod.

@Test
public void tenderPriceByProcurementMethod() throws Exception {
    final List<DBObject> tenderPriceByProcurementMethod = tenderPriceByTypeYearController.tenderPriceByProcurementMethod(new YearFilterPagingRequest());
    final DBObject first = tenderPriceByProcurementMethod.get(0);
    String procurementMethod = (String) first.get(TenderPriceByTypeYearController.Keys.PROCUREMENT_METHOD);
    Number totalTenderAmount = (Number) first.get(TenderPriceByTypeYearController.Keys.TOTAL_TENDER_AMOUNT);
    Assert.assertEquals("selective", procurementMethod);
    Assert.assertEquals(600000.0, totalTenderAmount.doubleValue(), 0);
    final DBObject second = tenderPriceByProcurementMethod.get(1);
    procurementMethod = (String) second.get(TenderPriceByTypeYearController.Keys.PROCUREMENT_METHOD);
    totalTenderAmount = (Number) second.get(TenderPriceByTypeYearController.Keys.TOTAL_TENDER_AMOUNT);
    Assert.assertEquals("open", procurementMethod);
    Assert.assertEquals(9000.0, totalTenderAmount.doubleValue(), 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)100 Test (org.junit.Test)98 DBObject (com.mongodb.DBObject)96 BasicDBObject (com.mongodb.BasicDBObject)13 AbstractEndPointControllerTest (org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)10 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)4 Collection (java.util.Collection)3 ApiOperation (io.swagger.annotations.ApiOperation)2 BigDecimal (java.math.BigDecimal)2 Valid (javax.validation.Valid)2 Release (org.devgateway.ocds.persistence.mongo.Release)2 ReleasePackage (org.devgateway.ocds.persistence.mongo.ReleasePackage)2 MongoConstants (org.devgateway.ocds.persistence.mongo.constants.MongoConstants)2 CacheConfig (org.springframework.cache.annotation.CacheConfig)2 Cacheable (org.springframework.cache.annotation.Cacheable)2 Aggregation (org.springframework.data.mongodb.core.aggregation.Aggregation)2 Aggregation.group (org.springframework.data.mongodb.core.aggregation.Aggregation.group)2 Aggregation.match (org.springframework.data.mongodb.core.aggregation.Aggregation.match)2