Search in sources :

Example 41 with YearFilterPagingRequest

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

the class OcdsControllerTest method ocdsReleases.

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

Example 42 with YearFilterPagingRequest

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

the class TenderPercentagesControllerTest method percentTendersWithLinkedProcurementPlan.

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

Example 43 with YearFilterPagingRequest

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

Example 44 with YearFilterPagingRequest

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

the class TopTenControllerTest method topTenLargestTenders.

@Test
public void topTenLargestTenders() throws Exception {
    final List<DBObject> topTenLargestTenders = topTenController.topTenLargestTenders(new YearFilterPagingRequest());
    Assert.assertEquals(3, topTenLargestTenders.size());
    final DBObject first = topTenLargestTenders.get(0);
    BasicDBObject tender = (BasicDBObject) first.get("tender");
    BasicDBObject value = (BasicDBObject) tender.get("value");
    double amount = (double) value.get("amount");
    Assert.assertEquals(600000.0, amount, 0);
    final DBObject second = topTenLargestTenders.get(1);
    tender = (BasicDBObject) second.get("tender");
    value = (BasicDBObject) tender.get("value");
    amount = (double) value.get("amount");
    Assert.assertEquals(400000.0, amount, 0);
    final DBObject third = topTenLargestTenders.get(2);
    tender = (BasicDBObject) third.get("tender");
    value = (BasicDBObject) tender.get("value");
    amount = (double) value.get("amount");
    Assert.assertEquals(9000.0, amount, 0);
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) Test(org.junit.Test)

Example 45 with YearFilterPagingRequest

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

the class TotalCancelledTendersByYearControllerTest method totalCancelledTendersByYear.

@Test
public void totalCancelledTendersByYear() throws Exception {
    final List<DBObject> totalCancelledTendersByYear = totalCancelledTendersByYearController.totalCancelledTendersByYear(new YearFilterPagingRequest());
    Assert.assertEquals(0, totalCancelledTendersByYear.size());
}
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