use of org.hisp.dhis.dxf2.datavalue.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValueSetXml.
// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------
@Test
public void testImportDataValueSetXml() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportSummary summary = dataValueSetService.saveDataValueSet(in);
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.datavalue.DataValue 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.datavalue.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesUpdatedAudit.
@Test
public void testImportDataValuesUpdatedAudit() throws Exception {
mockDataValueBatchHandler.withFindSelf(true);
in = new ClassPathResource("datavalueset/dataValueSetA.xml").getInputStream();
ImportSummary summary = dataValueSetService.saveDataValueSet(in);
assertNotNull(summary);
assertNotNull(summary.getImportCount());
assertEquals(ImportStatus.SUCCESS, summary.getStatus());
assertEquals(summary.getConflicts().toString(), 0, summary.getConflicts().size());
Collection<DataValue> dataValues = mockDataValueBatchHandler.getUpdates();
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)));
assertEquals(3, auditValues.size());
}
use of org.hisp.dhis.dxf2.datavalue.DataValue in project dhis2-core by dhis2.
the class RegistrationMultiEventsServiceTest method createEvent.
private Event createEvent(String program, String programStage, String orgUnit, String person, String dataElement) {
Event event = new Event();
event.setProgram(program);
event.setProgramStage(programStage);
event.setOrgUnit(orgUnit);
event.setTrackedEntityInstance(person);
event.setEventDate("2013-01-01");
event.getDataValues().add(new DataValue(dataElement, "10"));
return event;
}
use of org.hisp.dhis.dxf2.datavalue.DataValue in project dhis2-core by dhis2.
the class DataValueSetServiceTest method testImportDataValuesWithNonExistingDataElementOrgUnit.
@Test
public void testImportDataValuesWithNonExistingDataElementOrgUnit() throws Exception {
in = new ClassPathResource("datavalueset/dataValueSetG.xml").getInputStream();
ImportSummary summary = dataValueSetService.saveDataValueSet(in);
assertEquals(summary.getConflicts().toString(), 2, summary.getConflicts().size());
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());
}
Aggregations