use of org.hisp.dhis.dxf2.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithRequiredAttributeOptionCombo.
@Test
public void testImportDataValuesWithRequiredAttributeOptionCombo() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setRequireAttributeOptionCombo(true);
ImportSummary summary = dataValueSetService.saveDataValueSet(in, options);
assertEquals(summary.getConflicts().toString(), 2, summary.getConflicts().size());
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.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlWithAttribute.
@Test
public void testImportDataValuesXmlWithAttribute() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBAttribute.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setIdScheme(IdScheme.ATTR_ID_SCHEME_PREFIX + ATTRIBUTE_UID).setDataElementIdScheme(IdScheme.ATTR_ID_SCHEME_PREFIX + ATTRIBUTE_UID).setOrgUnitIdScheme(IdScheme.ATTR_ID_SCHEME_PREFIX + ATTRIBUTE_UID);
ImportSummary summary = dataValueSetService.saveDataValueSet(in, importOptions);
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
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.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithStrictCategoryOptionCombos.
@Test
public void testImportDataValuesWithStrictCategoryOptionCombos() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setStrictCategoryOptionCombos(true);
ImportSummary summary = dataValueSetService.saveDataValueSet(in, options);
assertEquals(summary.getConflicts().toString(), 1, summary.getConflicts().size());
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());
}
use of org.hisp.dhis.dxf2.common.ImportOptions 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());
}
use of org.hisp.dhis.dxf2.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlWithCodeB.
@Test
public void testImportDataValuesXmlWithCodeB() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBCode.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setIdScheme("CODE").setDataElementIdScheme("CODE").setOrgUnitIdScheme("CODE");
ImportSummary summary = dataValueSetService.saveDataValueSet(in, importOptions);
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
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);
}
Aggregations