use of org.hisp.dhis.common.EventDataQueryRequest in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromUrlA.
@Test
void testGetFromUrlA() {
final String coordinateField = "EVENT";
final String fallbackCoordinateField = "ougeometry";
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
dimensionParams.add(atA.getUid() + ":LE:5");
Set<String> filterParams = new HashSet<>();
filterParams.add("pe:201401;201402");
EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).coordinateField(coordinateField).fallbackCoordinateField(fallbackCoordinateField).coordinateOuFallback(true).build();
EventQueryParams params = dataQueryService.getFromRequest(request);
assertEquals(prA, params.getProgram());
assertEquals(1, params.getOrganisationUnits().size());
assertEquals(1, params.getItems().size());
assertEquals(2, params.getFilterPeriods().size());
assertEquals("psigeometry", params.getCoordinateField());
assertEquals(fallbackCoordinateField, params.getFallbackCoordinateField());
assertTrue(params.isCoordinateOuFallback());
}
use of org.hisp.dhis.common.EventDataQueryRequest in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromUrlB.
@Test
void testGetFromUrlB() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
dimensionParams.add(atA.getUid() + ":LE:5");
Set<String> filterParams = new HashSet<>();
filterParams.add("pe:201401");
EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).value(deA.getUid()).aggregationType(AggregationType.AVERAGE).build();
EventQueryParams params = dataQueryService.getFromRequest(request);
assertEquals(prA, params.getProgram());
assertEquals(1, params.getOrganisationUnits().size());
assertEquals(1, params.getItems().size());
assertEquals(1, params.getFilterPeriods().size());
assertEquals(deA, params.getValue());
assertEquals(AnalyticsAggregationType.AVERAGE, params.getAggregationType());
assertFalse(params.isCoordinateOuFallback());
assertEquals("psigeometry", params.getCoordinateField());
assertEquals("ougeometry", params.getFallbackCoordinateField());
}
use of org.hisp.dhis.common.EventDataQueryRequest in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testGetFromUrlWithOrgUnitNameSorting.
@Test
void testGetFromUrlWithOrgUnitNameSorting() {
Set<String> dimensionParams = new HashSet<>();
dimensionParams.add("ou:" + ouA.getUid() + ";" + ouB.getId());
dimensionParams.add(atA.getUid() + ":LE:5");
Set<String> filterParams = new HashSet<>();
filterParams.add("pe:201401");
Set<String> desc = new HashSet<>();
desc.add("ouname");
EventDataQueryRequest request = EventDataQueryRequest.builder().program(prA.getUid()).dimension(dimensionParams).filter(filterParams).value(deA.getUid()).aggregationType(AggregationType.AVERAGE).desc(desc).build();
EventQueryParams params = dataQueryService.getFromRequest(request);
assertEquals(prA, params.getProgram());
assertEquals(1, params.getOrganisationUnits().size());
assertEquals(1, params.getItems().size());
assertEquals(1, params.getFilterPeriods().size());
assertEquals(deA, params.getValue());
assertEquals(1, params.getDesc().size());
assertEquals("ouname", params.getDesc().get(0).getItem().getName());
assertEquals(AnalyticsAggregationType.AVERAGE, params.getAggregationType());
}
Aggregations