Search in sources :

Example 71 with YearFilterPagingRequest

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

Example 72 with YearFilterPagingRequest

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

the class TendersByItemClassificationTest method tendersByItemClassification.

@Test
public void tendersByItemClassification() throws Exception {
    final List<DBObject> numberOfTendersByItem = tendersByItemClassification.tendersByItemClassification(new YearFilterPagingRequest());
    final DBObject first = numberOfTendersByItem.get(0);
    String id = (String) first.get(Fields.UNDERSCORE_ID);
    String description = (String) first.get(TendersByItemClassification.Keys.DESCRIPTION);
    int totalTenders = (int) first.get(TendersByItemClassification.Keys.TOTAL_TENDERS);
    double totalTenderAmount = (double) first.get(TendersByItemClassification.Keys.TOTAL_TENDER_AMOUNT);
    Assert.assertEquals("09100000", id);
    Assert.assertEquals("Fuels", description);
    Assert.assertEquals(1, totalTenders);
    Assert.assertEquals(9000.0, totalTenderAmount, 0);
    final DBObject second = numberOfTendersByItem.get(1);
    id = (String) second.get(Fields.UNDERSCORE_ID);
    description = (String) second.get(TendersByItemClassification.Keys.DESCRIPTION);
    totalTenders = (int) second.get(TendersByItemClassification.Keys.TOTAL_TENDERS);
    totalTenderAmount = (double) second.get(TendersByItemClassification.Keys.TOTAL_TENDER_AMOUNT);
    Assert.assertEquals("45233130", id);
    Assert.assertEquals("Construction work for highways", description);
    Assert.assertEquals(2, totalTenders);
    Assert.assertEquals(1000000, totalTenderAmount, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 73 with YearFilterPagingRequest

use of org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest in project ocvn 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 74 with YearFilterPagingRequest

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

the class TenderPercentagesControllerTest method percentTendersUsingEgp.

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

Example 75 with YearFilterPagingRequest

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

the class TenderPercentagesControllerTest method percentTendersCancelled.

@Test
public void percentTendersCancelled() throws Exception {
    final List<DBObject> percentTendersCancelled = tenderPercentagesController.percentTendersCancelled(new YearFilterPagingRequest());
    final DBObject first = percentTendersCancelled.get(0);
    int year = (int) first.get(TenderPercentagesController.Keys.YEAR);
    int totalTenders = (int) first.get(TenderPercentagesController.Keys.TOTAL_TENDERS);
    int totalCancelled = (int) first.get(TenderPercentagesController.Keys.TOTAL_CANCELLED);
    double percentCancelled = (double) first.get(TenderPercentagesController.Keys.PERCENT_CANCELLED);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(1, totalTenders);
    Assert.assertEquals(0, totalCancelled);
    Assert.assertEquals(0.0, percentCancelled, 0);
    final DBObject second = percentTendersCancelled.get(1);
    year = (int) second.get(TenderPercentagesController.Keys.YEAR);
    totalTenders = (int) second.get(TenderPercentagesController.Keys.TOTAL_TENDERS);
    totalCancelled = (int) second.get(TenderPercentagesController.Keys.TOTAL_CANCELLED);
    percentCancelled = (double) second.get(TenderPercentagesController.Keys.PERCENT_CANCELLED);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(2, totalTenders);
    Assert.assertEquals(0, totalCancelled);
    Assert.assertEquals(0.0, percentCancelled, 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