use of org.hisp.dhis.datavalue.DataExportParams in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testExportOutputIdSchemeAttribute.
@Test
void testExportOutputIdSchemeAttribute() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
String attributeIdScheme = IdScheme.ATTR_ID_SCHEME_PREFIX + atA.getUid();
IdSchemes idSchemes = new IdSchemes().setDataElementIdScheme(attributeIdScheme).setOrgUnitIdScheme(attributeIdScheme).setCategoryOptionComboIdScheme(attributeIdScheme);
DataExportParams params = new DataExportParams().setDataSets(Sets.newHashSet(dsB)).setOrganisationUnits(Sets.newHashSet(ouA)).setPeriods(Sets.newHashSet(peB)).setOutputIdSchemes(idSchemes);
dataValueSetService.exportDataValueSetJson(params, out);
DataValueSet dvs = jsonMapper.readValue(out.toByteArray(), DataValueSet.class);
assertNotNull(dvs);
assertNotNull(dvs.getDataSet());
assertEquals(dsB.getUid(), dvs.getDataSet());
assertEquals(2, dvs.getDataValues().size());
for (org.hisp.dhis.dxf2.datavalue.DataValue dv : dvs.getDataValues()) {
assertNotNull(dv);
assertEquals(avA.getValue(), dv.getDataElement());
assertEquals(avB.getValue(), dv.getOrgUnit());
}
}
use of org.hisp.dhis.datavalue.DataExportParams in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testMissingDataSetElementGroup.
@Test
void testMissingDataSetElementGroup() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataExportParams params = new DataExportParams().setOrganisationUnits(Sets.newHashSet(ouB)).setPeriods(Sets.newHashSet(peA));
assertIllegalQueryEx(assertThrows(IllegalQueryException.class, () -> dataValueSetService.exportDataValueSetJson(params, out)), ErrorCode.E2001);
}
use of org.hisp.dhis.datavalue.DataExportParams in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testAccessOutsideOrgUnitHierarchy.
@Test
void testAccessOutsideOrgUnitHierarchy() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataExportParams params = new DataExportParams().setDataSets(Sets.newHashSet(dsA)).setOrganisationUnits(Sets.newHashSet(ouC)).setPeriods(Sets.newHashSet(peA));
assertIllegalQueryEx(assertThrows(IllegalQueryException.class, () -> dataValueSetService.exportDataValueSetJson(params, out)), ErrorCode.E2012);
}
use of org.hisp.dhis.datavalue.DataExportParams in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testExportAttributeOptionCombo.
@Test
void testExportAttributeOptionCombo() throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataExportParams params = new DataExportParams().setDataSets(Sets.newHashSet(dsA)).setOrganisationUnits(Sets.newHashSet(ouB)).setPeriods(Sets.newHashSet(peA)).setAttributeOptionCombos(Sets.newHashSet(cocA));
dataValueSetService.exportDataValueSetJson(params, out);
DataValueSet dvs = jsonMapper.readValue(out.toByteArray(), DataValueSet.class);
assertNotNull(dvs);
assertNotNull(dvs.getDataSet());
assertEquals(2, dvs.getDataValues().size());
for (org.hisp.dhis.dxf2.datavalue.DataValue dv : dvs.getDataValues()) {
assertNotNull(dv);
assertEquals(ouB.getUid(), dv.getOrgUnit());
assertEquals(peAUid, dv.getPeriod());
}
}
use of org.hisp.dhis.datavalue.DataExportParams in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testPeriodAndStartEndDate.
@Test
void testPeriodAndStartEndDate() {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataExportParams params = new DataExportParams().setDataSets(Sets.newHashSet(dsA)).setOrganisationUnits(Sets.newHashSet(ouB)).setPeriods(Sets.newHashSet(peA)).setStartDate(getDate(2019, 1, 1)).setEndDate(getDate(2019, 1, 31));
assertIllegalQueryEx(assertThrows(IllegalQueryException.class, () -> dataValueSetService.exportDataValueSetJson(params, out)), ErrorCode.E2003);
}
Aggregations