Search in sources :

Example 31 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardIndicatorsStatsControllerTest method totalFlaggedProjectsByIndicatorTypeByYearTest.

@Test
public void totalFlaggedProjectsByIndicatorTypeByYearTest() throws Exception {
    final List<DBObject> result = corruptionRiskDashboardIndicatorsStatsController.totalFlaggedProjectsByIndicatorTypeByYear(new YearFilterPagingRequest());
    Assert.assertEquals(1, result.size());
    Assert.assertEquals(FlagType.RIGGING.toString(), result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.TYPE));
    Assert.assertEquals(2015, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.YEAR));
    Assert.assertEquals(2, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.FLAGGED_COUNT));
    Assert.assertEquals(1, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.FLAGGED_PROJECT_COUNT));
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 32 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardIndicatorsStatsControllerTest method totalFlagsTest.

@Test
public void totalFlagsTest() throws Exception {
    final List<DBObject> result = corruptionRiskDashboardIndicatorsStatsController.totalFlags(new YearFilterPagingRequest());
    Assert.assertEquals(2, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.FLAGGED_COUNT));
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 33 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardTablesControllerTest method corruptionRiskOverviewTableTest.

@Test
public void corruptionRiskOverviewTableTest() throws Exception {
    final List<DBObject> result = corruptionRiskDashboardTablesController.corruptionRiskOverviewTable(new YearFilterPagingRequest());
    Assert.assertEquals(1, result.size());
    Assert.assertEquals("[ocds-endpoint-001] procuringEntity name", ((DBObject) result.get(0).get("procuringEntity")).get("name"));
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 34 with YearFilterPagingRequest

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

the class CostEffectivenessVisualsControllerTest method costEffectivenessAwardAmount.

@Test
public void costEffectivenessAwardAmount() throws Exception {
    final List<DBObject> costEffectivenessAwardAmount = costEffectivenessVisualsController.costEffectivenessAwardAmount(new YearFilterPagingRequest());
    final DBObject first = costEffectivenessAwardAmount.get(0);
    int year = (int) first.get(CostEffectivenessVisualsController.Keys.YEAR);
    double totalAwardAmount = (double) first.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARD_AMOUNT);
    int totalAwards = (int) first.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARDS);
    int totalAwardsWithTender = (int) first.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARDS_WITH_TENDER);
    double percentageAwardsWithTender = (double) first.get(CostEffectivenessVisualsController.Keys.PERCENTAGE_AWARDS_WITH_TENDER);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(6000000.0, totalAwardAmount, 0);
    Assert.assertEquals(1, totalAwards);
    Assert.assertEquals(1, totalAwardsWithTender);
    Assert.assertEquals(100.0, percentageAwardsWithTender, 0);
    final DBObject second = costEffectivenessAwardAmount.get(1);
    year = (int) second.get(CostEffectivenessVisualsController.Keys.YEAR);
    totalAwardAmount = (double) second.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARD_AMOUNT);
    totalAwards = (int) second.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARDS);
    totalAwardsWithTender = (int) second.get(CostEffectivenessVisualsController.Keys.TOTAL_AWARDS_WITH_TENDER);
    percentageAwardsWithTender = (double) second.get(CostEffectivenessVisualsController.Keys.PERCENTAGE_AWARDS_WITH_TENDER);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(40000.0, totalAwardAmount, 0);
    Assert.assertEquals(1, totalAwards);
    Assert.assertEquals(1, totalAwardsWithTender);
    Assert.assertEquals(100.0, percentageAwardsWithTender, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 35 with YearFilterPagingRequest

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

the class CountPlansTendersAwardsControllerTest method countTendersByYear.

@Test
public void countTendersByYear() throws Exception {
    final List<DBObject> countTendersByYear = countPlansTendersAwardsController.countTendersByYear(new YearFilterPagingRequest());
    final DBObject first = countTendersByYear.get(0);
    int year = (int) first.get(CountPlansTendersAwardsController.Keys.YEAR);
    int count = (int) first.get(CountPlansTendersAwardsController.Keys.COUNT);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(1, count);
    final DBObject second = countTendersByYear.get(1);
    year = (int) second.get(CountPlansTendersAwardsController.Keys.YEAR);
    count = (int) second.get(CountPlansTendersAwardsController.Keys.COUNT);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(2, count);
}
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