Search in sources :

Example 76 with YearFilterPagingRequest

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

the class TenderPercentagesControllerTest method percentTendersWithTwoOrMoreTenderers.

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

Example 77 with YearFilterPagingRequest

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

the class AverageNumberOfTenderersControllerTest method averageNumberOfTenderers.

@Test
public void averageNumberOfTenderers() throws Exception {
    final List<DBObject> averageNumberOfTenderers = averageNumberOfTenderersController.averageNumberOfTenderersYearly(new YearFilterPagingRequest());
    final DBObject sec = averageNumberOfTenderers.get(1);
    int year = (int) sec.get(AverageNumberOfTenderersController.Keys.YEAR);
    double averageNoTenderers = (double) sec.get(AverageNumberOfTenderersController.Keys.AVERAGE_NO_OF_TENDERERS);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(5.5, averageNoTenderers, 0);
    final DBObject first = averageNumberOfTenderers.get(0);
    year = (int) first.get(AverageNumberOfTenderersController.Keys.YEAR);
    averageNoTenderers = (double) first.get(AverageNumberOfTenderersController.Keys.AVERAGE_NO_OF_TENDERERS);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(5.0, averageNoTenderers, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 78 with YearFilterPagingRequest

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

the class AverageTenderAndAwardPeriodsControllerTest method averageAwardPeriod.

@Test
public void averageAwardPeriod() throws Exception {
    final List<DBObject> averageAwardPeriod = averageTenderAndAwardPeriodsController.averageAwardPeriod(new YearFilterPagingRequest());
    final DBObject first = averageAwardPeriod.get(0);
    int year = (int) first.get(AverageTenderAndAwardPeriodsController.Keys.YEAR);
    double averageAwardDays = (double) first.get(AverageTenderAndAwardPeriodsController.Keys.AVERAGE_AWARD_DAYS);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(365.0, averageAwardDays, 0);
    final DBObject second = averageAwardPeriod.get(1);
    year = (int) second.get(AverageTenderAndAwardPeriodsController.Keys.YEAR);
    averageAwardDays = (double) second.get(AverageTenderAndAwardPeriodsController.Keys.AVERAGE_AWARD_DAYS);
    Assert.assertEquals(2016, year);
    Assert.assertEquals(405.0, averageAwardDays, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 79 with YearFilterPagingRequest

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

the class AverageTenderAndAwardPeriodsControllerTest method averageTenderPeriod.

@Test
public void averageTenderPeriod() throws Exception {
    final List<DBObject> averageTenderPeriod = averageTenderAndAwardPeriodsController.averageTenderPeriod(new YearFilterPagingRequest());
    final DBObject first = averageTenderPeriod.get(0);
    int year = (int) first.get(AverageTenderAndAwardPeriodsController.Keys.YEAR);
    double averageTenderDays = (double) first.get(AverageTenderAndAwardPeriodsController.Keys.AVERAGE_TENDER_DAYS);
    Assert.assertEquals(2014, year);
    Assert.assertEquals(15.0, averageTenderDays, 0);
    final DBObject second = averageTenderPeriod.get(1);
    year = (int) second.get(AverageTenderAndAwardPeriodsController.Keys.YEAR);
    averageTenderDays = (double) second.get(AverageTenderAndAwardPeriodsController.Keys.AVERAGE_TENDER_DAYS);
    Assert.assertEquals(2015, year);
    Assert.assertEquals(46.0, averageTenderDays, 0);
}
Also used : YearFilterPagingRequest(org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest) DBObject(com.mongodb.DBObject) Test(org.junit.Test)

Example 80 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardIndicatorsStatsControllerTest method totalEligibleProjectsByIndicatorTypeByYearTest.

@Test
public void totalEligibleProjectsByIndicatorTypeByYearTest() throws Exception {
    final List<DBObject> result = corruptionRiskDashboardIndicatorsStatsController.totalEligibleProjectsByIndicatorTypeByYear(new YearFilterPagingRequest());
    Assert.assertEquals(6, result.size());
    Assert.assertEquals(FlagType.COLLUSION.toString(), result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.TYPE));
    Assert.assertEquals(2014, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.YEAR));
    Assert.assertEquals(1, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_COUNT));
    Assert.assertEquals(1, result.get(0).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_PROJECT_COUNT));
    Assert.assertEquals(FlagType.FRAUD.toString(), result.get(1).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.TYPE));
    Assert.assertEquals(2014, result.get(1).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.YEAR));
    Assert.assertEquals(1, result.get(1).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_COUNT));
    Assert.assertEquals(1, result.get(1).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_PROJECT_COUNT));
    Assert.assertEquals(FlagType.RIGGING.toString(), result.get(2).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.TYPE));
    Assert.assertEquals(2014, result.get(2).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.YEAR));
    Assert.assertEquals(1, result.get(2).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_COUNT));
    Assert.assertEquals(1, result.get(2).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_PROJECT_COUNT));
    Assert.assertEquals(FlagType.COLLUSION.toString(), result.get(3).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.TYPE));
    Assert.assertEquals(2015, result.get(3).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.YEAR));
    Assert.assertEquals(1, result.get(3).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_COUNT));
    Assert.assertEquals(1, result.get(3).get(CorruptionRiskDashboardIndicatorsStatsController.Keys.ELIGIBLE_PROJECT_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