use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithNonExistingDataElementOrgUnit.
@Test
void testImportDataValuesWithNonExistingDataElementOrgUnit() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetG.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(2, summary.getConflictCount(), summary.getConflictsDescription());
assertEquals(1, summary.getImportCount().getImported());
assertEquals(0, summary.getImportCount().getUpdated());
assertEquals(0, summary.getImportCount().getDeleted());
assertEquals(3, summary.getImportCount().getIgnored());
assertEquals(ImportStatus.WARNING, summary.getStatus());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(1, dataValues.size());
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesInvalidAttributeOptionComboOrgUnit.
@Test
void testImportDataValuesInvalidAttributeOptionComboOrgUnit() throws Exception {
clearSecurityContext();
categoryOptionA.setOrganisationUnits(Sets.newHashSet(ouA, ouB));
categoryService.updateCategoryOption(categoryOptionA);
in = new ClassPathResource("datavalueset/dataValueSetH.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
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());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(2, dataValues.size());
assertTrue(dataValues.contains(new DataValue(deA, peA, ouA, ocDef, ocA)));
assertTrue(dataValues.contains(new DataValue(deB, peB, ouB, ocDef, ocA)));
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesBooleanCsv.
@Test
void testImportDataValuesBooleanCsv() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetBooleanTest.csv").getInputStream();
ImportConflicts summary = dataValueSetService.importDataValueSetCsv(in, null, null);
String description = summary.getConflictsDescription();
assertEquals(4, summary.getTotalConflictOccurrenceCount(), description);
assertEquals(4, summary.getConflictOccurrenceCount(ErrorCode.E7619), description);
assertEquals(2, summary.getConflictCount(), description);
Iterator<ImportConflict> conflicts = summary.getConflicts().iterator();
assertArrayEquals(new int[] { 10, 11 }, conflicts.next().getIndexes());
assertArrayEquals(new int[] { 16, 17 }, conflicts.next().getIndexes());
List<String> expectedBools = Lists.newArrayList("true", "false");
List<DataValue> resultBools = mockDataValueBatchHandler.getInserts();
for (DataValue dataValue : resultBools) {
assertTrue(expectedBools.contains(dataValue.getValue()));
}
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValueSetXml.
// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------
@Test
void testImportDataValueSetXml() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertHasNoConflicts(summary);
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)));
assertEquals("10002", ((List<DataValue>) dataValues).get(1).getValue());
assertEquals("10003", ((List<DataValue>) dataValues).get(2).getValue());
assertEquals(0, auditValues.size());
// TODO This throw an error : "org.postgresql.util.PSQLException: ERROR:
// cannot execute UPDATE in a read-only transaction"
// Need to investigate
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());
}
use of org.hisp.dhis.dxf2.events.event.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesXmlDryRun.
@Test
void testImportDataValuesXmlDryRun() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetB.xml").getInputStream();
ImportOptions importOptions = new ImportOptions().setDryRun(true).setIdScheme("UID").setDataElementIdScheme("UID").setOrgUnitIdScheme("UID");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in, importOptions);
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertHasNoConflicts(summary);
Collection<DataValue> dataValues = mockDataValueBatchHandler.getInserts();
assertNotNull(dataValues);
assertEquals(0, dataValues.size());
}
Aggregations