Search in sources :

Example 96 with YearFilterPagingRequest

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

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

the class TopTenControllerTest method topTenLargestAwards.

@Test
public void topTenLargestAwards() throws Exception {
    final List<DBObject> topTenLargestAwards = topTenController.topTenLargestAwards(new YearFilterPagingRequest());
    Assert.assertEquals(2, topTenLargestAwards.size());
    final DBObject first = topTenLargestAwards.get(0);
    BasicDBObject awards = (BasicDBObject) first.get("awards");
    BasicDBObject value = (BasicDBObject) awards.get("value");
    double amount = (double) value.get("amount");
    Assert.assertEquals(6000000.0, amount, 0);
    final DBObject second = topTenLargestAwards.get(1);
    awards = (BasicDBObject) second.get("awards");
    value = (BasicDBObject) awards.get("value");
    amount = (double) value.get("amount");
    Assert.assertEquals(40000.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 98 with YearFilterPagingRequest

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

the class TopTenControllerTest method topTenLargestSuppliers.

@Test
public void topTenLargestSuppliers() throws Exception {
    final List<DBObject> topTenLargestSuppliers = topTenController.topTenLargestSuppliers(new YearFilterPagingRequest());
    final DBObject first = topTenLargestSuppliers.get(0);
    Assert.assertEquals(6000000d, first.get(TopTenController.Keys.TOTAL_AWARD_AMOUNT));
    Assert.assertEquals(1, first.get(TopTenController.Keys.TOTAL_CONTRACTS));
    Assert.assertEquals("E09000005", ((Collection) first.get(TopTenController.Keys.PROCURING_ENTITY_IDS)).iterator().next());
    Assert.assertEquals("GB-COH-1234567845", first.get(TopTenController.Keys.SUPPLIER_ID));
    Assert.assertEquals(1, first.get(TopTenController.Keys.PROCURING_ENTITY_IDS_COUNT));
    Assert.assertEquals(2, topTenLargestSuppliers.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) Collection(java.util.Collection) DBObject(com.mongodb.DBObject) BasicDBObject(com.mongodb.BasicDBObject) Test(org.junit.Test)

Example 99 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardCrosstabTest method testI077CrossTab.

@Test
public void testI077CrossTab() {
    List<DBObject> flagStats = flagI077CrosstabController.flagStats(new YearFilterPagingRequest());
    Assert.assertEquals(0, flagStats.size());
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractEndPointControllerTest(org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)

Example 100 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardCrosstabTest method testI019CrossTab.

@Test
public void testI019CrossTab() {
    List<DBObject> flagStats = flagI019CrosstabController.flagStats(new YearFilterPagingRequest());
    Assert.assertEquals(1, flagStats.get(0).get(flagI019CrosstabController.getFlagDesignation(FlagsConstants.I007_VALUE)));
    Assert.assertEquals(1, flagStats.get(0).get(flagI019CrosstabController.getFlagDesignation(FlagsConstants.I019_VALUE)));
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractEndPointControllerTest(org.devgateway.ocds.web.rest.controller.AbstractEndPointControllerTest)

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