use of org.hisp.dhis.common.IdSchemes in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testExportLastUpdated.
@Test
public void testExportLastUpdated() {
Date lastUpdated = getDate(1970, 1, 1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
dataValueSetService.writeDataValueSetJson(lastUpdated, out, new IdSchemes());
DataValueSet dvs = JacksonUtils.fromJson(out.toByteArray(), DataValueSet.class);
assertNotNull(dvs);
assertEquals(12, dvs.getDataValues().size());
for (org.hisp.dhis.dxf2.datavalue.DataValue dv : dvs.getDataValues()) {
assertNotNull(dv);
}
}
use of org.hisp.dhis.common.IdSchemes in project dhis2-core by dhis2.
the class DataValueSetServiceExportTest method testExportOutputIdSchemeAttribute.
@Test
public void testExportOutputIdSchemeAttribute() {
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.writeDataValueSetJson(params, out);
DataValueSet dvs = JacksonUtils.fromJson(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.common.IdSchemes in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlUpdatesOnly.
@Test
public void testImportDataValuesXmlUpdatesOnly() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetB.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setImportStrategy(ImportStrategy.UPDATES);
IdSchemes idSchemes = new IdSchemes();
idSchemes.setIdScheme("UID");
idSchemes.setDataElementIdScheme("UID");
idSchemes.setOrgUnitIdScheme("UID");
importOptions.setIdSchemes(idSchemes);
ImportSummary summary = dataValueSetService.saveDataValueSet(in, importOptions);
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
assertEquals(0, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(12, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(0, dataValues.size());
}
Aggregations