Search in sources :

Example 1 with YearFilterPagingRequest

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

the class AverageNumberOfTenderersControllerTest method averageNumberOfTenderers.

@Test
public void averageNumberOfTenderers() throws Exception {
    final List<DBObject> averageNumberOfTenderers = averageNumberOfTenderersController.averageNumberOfTenderers(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 2 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardIndicatorsStatsControllerTest method totalFlagsByIndicatorTypeTest.

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

Example 3 with YearFilterPagingRequest

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

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

Example 5 with YearFilterPagingRequest

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

the class CorruptionRiskDashboardCrosstabTest method testI038CrossTab.

@Test
public void testI038CrossTab() {
    List<DBObject> flagStats = flagI038CrosstabController.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)

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