use of org.hisp.dhis.dxf2.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValueSetXmlPreheatCache.
@Test
public void testImportDataValueSetXmlPreheatCache() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setPreheatCache(true);
ImportSummary summary = dataValueSetService.saveDataValueSet(in, importOptions);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
Collection<DataValueAudit> auditValues = mockDataValueAuditBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(3, dataValues.size());
assertTrue(dataValues.contains(new DataValue(deA, peA, ouA, ocDef, ocDef)));
assertTrue(dataValues.contains(new DataValue(deB, peA, ouA, ocDef, ocDef)));
assertTrue(dataValues.contains(new DataValue(deC, peA, ouA, ocDef, ocDef)));
CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration(dsA, peA, ouA, ocDef);
assertNotNull(registration);
assertEquals(dsA, registration.getDataSet());
assertEquals(peA, registration.getPeriod());
assertEquals(ouA, registration.getSource());
assertEquals(getDate(2012, 1, 9), registration.getDate());
assertEquals(0, auditValues.size());
}
use of org.hisp.dhis.dxf2.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithStrictOrganisationUnits.
@Test
public void testImportDataValuesWithStrictOrganisationUnits() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setStrictOrganisationUnits(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 testImportDataValuesXmlWithAttributeIdSchemeInPayload.
@Test
public void testImportDataValuesXmlWithAttributeIdSchemeInPayload() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBAttributeIdScheme.xml").getInputStream();
// Identifier schemes specified in XML message
ImportOptions importOptions = new ImportOptions();
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 DataValueSetServiceIntegrationTest method testImportValuesDeleteStrategyXml.
/**
* Import 12 data values. Then import the same 12 data values with import
* strategy delete.
*/
@Test
public void testImportValuesDeleteStrategyXml() throws Exception {
assertEquals(0, dataValueService.getAllDataValues().size());
in = new ClassPathResource("datavalueset/dataValueSetB.xml").getInputStream();
ImportSummary summary = dataValueSetService.saveDataValueSet(in);
assertEquals(12, summary.getImportCount().getImported());
assertEquals(12, dataValueService.getAllDataValues().size());
// Import with delete strategy
in = new ClassPathResource("datavalueset/dataValueSetB.xml").getInputStream();
ImportOptions options = new ImportOptions().setStrategy(ImportStrategy.DELETE);
summary = dataValueSetService.saveDataValueSet(in, options);
assertEquals(0, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(12, summary.getImportCount().getDeleted());
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertEquals(0, dataValueService.getAllDataValues().size());
}
use of org.hisp.dhis.dxf2.common.ImportOptions in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithStrictPeriods.
@Test
public void testImportDataValuesWithStrictPeriods() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetNonStrict.xml").getInputStream();
ImportOptions options = new ImportOptions().setStrictPeriods(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());
}
Aggregations