Search in sources :

Example 6 with YearFilterPagingRequest

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

the class VNImportAndEndpointsTest method testAverageNumberOfTenderersController.

@Test
public void testAverageNumberOfTenderersController() {
    List<DBObject> averageNumberOfTenderers = averageNumberOfTenderersController.averageNumberOfTenderers(new YearFilterPagingRequest());
    DBObject root = averageNumberOfTenderers.get(0);
    int year = (int) root.get("year");
    Assert.assertEquals(2012, year);
    double averageNoTenderers = (double) root.get("averageNoTenderers");
    Assert.assertEquals(2, averageNoTenderers, 0);
    root = averageNumberOfTenderers.get(1);
    year = (int) root.get("year");
    Assert.assertEquals(2013, year);
    averageNoTenderers = (double) root.get("averageNoTenderers");
    Assert.assertEquals(2, averageNoTenderers, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 7 with YearFilterPagingRequest

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

the class VNImportAndEndpointsTest method testAverageAwardPeriod.

@Test
public void testAverageAwardPeriod() {
    List<DBObject> averageAwardPeriod = averageTenderAndAwardPeriodsController.averageAwardPeriod(new YearFilterPagingRequest());
    DBObject root = averageAwardPeriod.get(0);
    int year = (int) root.get(AverageTenderAndAwardPeriodsController.Keys.YEAR);
    Assert.assertEquals(2014, year);
    double n = (double) root.get("averageAwardDays");
    Assert.assertEquals(536, n, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 8 with YearFilterPagingRequest

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

the class VNImportAndEndpointsTest method testCostEffectivenessAwardAmount.

@Test
public void testCostEffectivenessAwardAmount() {
    List<DBObject> costEffectivenessAwardAmount = costEffectivenessVisualsController.costEffectivenessAwardAmount(new YearFilterPagingRequest());
    DBObject root = costEffectivenessAwardAmount.get(0);
    int year = (int) root.get(CostEffectivenessVisualsController.Keys.YEAR);
    Assert.assertEquals(2012, year);
    double totalAwardAmount = (double) root.get("totalAwardAmount");
    Assert.assertEquals(1000, totalAwardAmount, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 9 with YearFilterPagingRequest

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

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

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