use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlA.
@Test
void testGetFromUrlA() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + deA.getUid() + ";" + deB.getUid() + ";" + deC.getUid() + ";" + deD.getUid());
dimensionParams.add("pe:2012;2012S1;2012S2");
dimensionParams.add(ouGroupSetA.getUid() + ":" + ouGroupA.getUid() + ";" + ouGroupB.getUid() + ";" + ouGroupC.getUid());
Set<String> filterParams = new HashSet<>();
filterParams.add("ou:" + ouA.getUid() + ";" + ouB.getUid() + ";" + ouC.getUid() + ";" + ouD.getUid() + ";" + ouE.getUid());
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).filter(filterParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(4, params.getDataElements().size());
assertEquals(3, params.getPeriods().size());
assertEquals(5, params.getFilterOrganisationUnits().size());
assertEquals(3, params.getDimensionOptions(ouGroupSetA.getUid()).size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlNoOrganisationUnits.
@Test
void testGetFromUrlNoOrganisationUnits() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
dimensionParams.add("ou");
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest));
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlInvalidOrganisationUnits.
@Test
void testGetFromUrlInvalidOrganisationUnits() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
dimensionParams.add("ou:aTr6yTgX7t5;gBgf2G2j4GR");
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
assertIllegalQueryEx(assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest)), ErrorCode.E7124);
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlOrgUnitLevel.
@Test
void testGetFromUrlOrgUnitLevel() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:LEVEL-2");
dimensionParams.add("dx:" + deA.getDimensionItem() + ";" + deB.getDimensionItem());
dimensionParams.add("pe:2011;2012");
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
DataQueryParams params = dataQueryService.getFromRequest(dataQueryRequest);
assertEquals(2, params.getOrganisationUnits().size());
assertEquals(2, params.getDataElements().size());
assertEquals(2, params.getPeriods().size());
}
use of org.hisp.dhis.common.DataQueryRequest in project dhis2-core by dhis2.
the class DataQueryServiceTest method testGetFromUrlNoPeriods.
@Test
void testGetFromUrlNoPeriods() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("dx:" + BASE_UID + "A;" + BASE_UID + "B;" + BASE_UID + "C;" + BASE_UID + "D");
dimensionParams.add("pe");
DataQueryRequest dataQueryRequest = DataQueryRequest.newBuilder().dimension(dimensionParams).build();
assertThrows(IllegalQueryException.class, () -> dataQueryService.getFromRequest(dataQueryRequest));
}
Aggregations