use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class RegistrationMultiEventsServiceTest method testSaveRepeatableStageWithoutEventIdShouldCreateNewEvent.
@Test
@Category(IntegrationTest.class)
public void testSaveRepeatableStageWithoutEventIdShouldCreateNewEvent() {
Enrollment enrollment = createEnrollment(programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
ImportSummary importSummary = enrollmentService.addEnrollment(enrollment, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementA.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
event = createEvent(programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
sessionFactory.getCurrentSession().flush();
EventSearchParams params = new EventSearchParams();
params.setProgram(programA);
params.setOrgUnit(organisationUnitA);
params.setOrgUnitSelectionMode(OrganisationUnitSelectionMode.SELECTED);
assertEquals(2, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(3, eventService.getEvents(params).getEvents().size());
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class RegistrationMultiEventsServiceTest method testSaveRepeatableStageWithEventIdShouldNotCreateAdditionalEvents.
@Test
@Category(IntegrationTest.class)
public void testSaveRepeatableStageWithEventIdShouldNotCreateAdditionalEvents() {
Enrollment enrollment = createEnrollment(programA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance());
ImportSummary importSummary = enrollmentService.addEnrollment(enrollment, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementA.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
event = createEvent(programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
sessionFactory.getCurrentSession().flush();
EventSearchParams params = new EventSearchParams();
params.setProgram(programA);
params.setOrgUnit(organisationUnitA);
params.setOrgUnitSelectionMode(OrganisationUnitSelectionMode.SELECTED);
assertEquals(2, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageB.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementB.getUid());
event.setEvent(importSummary.getReference());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.SUCCESS, importSummary.getStatus());
assertEquals(2, eventService.getEvents(params).getEvents().size());
event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementA.getUid());
importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.ERROR, importSummary.getStatus());
assertEquals(2, eventService.getEvents(params).getEvents().size());
}
use of org.hisp.dhis.dxf2.common.ImportSummary in project dhis2-core by dhis2.
the class RegistrationMultiEventsServiceTest method testSaveWithoutEnrollmentShouldFail.
@Test
@Category(IntegrationTest.class)
public void testSaveWithoutEnrollmentShouldFail() {
Event event = createEvent(programA.getUid(), programStageA.getUid(), organisationUnitA.getUid(), trackedEntityInstanceMaleA.getTrackedEntityInstance(), dataElementA.getUid());
ImportSummary importSummary = eventService.addEvent(event, null);
assertEquals(ImportStatus.ERROR, importSummary.getStatus());
assertThat(importSummary.getDescription(), CoreMatchers.containsString("is not enrolled in program"));
}
use of org.hisp.dhis.dxf2.common.ImportSummary 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());
}
use of org.hisp.dhis.dxf2.common.ImportSummary 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