use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportValueDefaultCatComboOk.
/**
* User has data write access for DataSet DataValue use default category
* combo Expect success
*
* @throws IOException
*/
@Test
void testImportValueDefaultCatComboOk() throws IOException {
clearSecurityContext();
enableDataSharing(user, dsA, AccessStringHelper.DATA_READ_WRITE);
dataSetService.updateDataSet(dsA);
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithRequiredCategoryOptionCombo.
@Test
void testImportDataValuesWithRequiredCategoryOptionCombo() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setRequireCategoryOptionCombo(true);
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, options);
String description = summary.getConflictsDescription();
assertEquals(2, summary.getTotalConflictOccurrenceCount(), description);
assertEquals(1, summary.getConflictCount(), description);
assertArrayEquals(new int[] { 1, 2 }, summary.getConflicts().iterator().next().getIndexes());
assertEquals(1, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(2, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.WARNING, summary.getStatus());
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithRequiredAttributeOptionCombo.
@Test
void testImportDataValuesWithRequiredAttributeOptionCombo() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setRequireAttributeOptionCombo(true);
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, options);
String description = summary.getConflictsDescription();
assertEquals(2, summary.getTotalConflictOccurrenceCount(), description);
assertEquals(1, summary.getConflictCount(), description);
assertArrayEquals(new int[] { 0, 2 }, summary.getConflicts().iterator().next().getIndexes());
assertEquals(1, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(2, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.WARNING, summary.getStatus());
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlWithCodeB.
@Test
void testImportDataValuesXmlWithCodeB() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBCode.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setIdScheme("CODE").setDataElementIdScheme("CODE").setOrgUnitIdScheme("CODE");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, importOptions);
assertHasNoConflicts(summary);
assertEquals(12, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(0, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertImportDataValues(summary);
}
use of org.hisp.dhis.dxf2.datavalueset.DataValueSet in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithStrictAttributeOptionCombos.
@Test
void testImportDataValuesWithStrictAttributeOptionCombos() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setStrictAttributeOptionCombos(true);
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, options);
assertEquals(1, summary.getConflictCount(), summary.getConflictsDescription());
assertEquals(2, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(1, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.WARNING, summary.getStatus());
}
Aggregations