use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class ProgramRuleIntegrationTest method testImportEnrollmentSuccessWithWarningRaised.
@Test
void testImportEnrollmentSuccessWithWarningRaised() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
TrackerImportReport trackerImportTeiReport = trackerImportService.importTracker(params);
TrackerImportParams enrollmentParams = renderService.fromJson(new ClassPathResource("tracker/single_enrollment.json").getInputStream(), TrackerImportParams.class);
enrollmentParams.setUserId(userA.getUid());
TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(enrollmentParams);
assertNotNull(trackerImportTeiReport);
assertEquals(TrackerStatus.OK, trackerImportTeiReport.getStatus());
assertNotNull(trackerImportEnrollmentReport);
assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
assertEquals(1, trackerImportEnrollmentReport.getValidationReport().getWarnings().size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class AtomicModeIntegrationTest method testImportSuccessWithAtomicModeObjectIfThereIsAnErrorInOneTEI.
@Test
void testImportSuccessWithAtomicModeObjectIfThereIsAnErrorInOneTEI() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/one_valid_tei_and_one_invalid.json").getInputStream();
TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
params.setAtomicMode(AtomicMode.OBJECT);
TrackerImportReport trackerImportTeiReport = trackerImportService.importTracker(params);
assertNotNull(trackerImportTeiReport);
assertEquals(TrackerStatus.OK, trackerImportTeiReport.getStatus());
assertEquals(1, trackerImportTeiReport.getValidationReport().getErrors().size());
assertNotNull(trackedEntityInstanceService.getTrackedEntityInstance("VALIDTEIAAA"));
assertNull(trackedEntityInstanceService.getTrackedEntityInstance("INVALIDTEIA"));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatIdentifiersTest method testDataElementIdentifiers.
@Test
void testDataElementIdentifiers() {
List<Pair<String, TrackerIdentifier>> data = buildDataSet("DSKTW8qFP0z", "DEAGE", "DE Age");
for (Pair<String, TrackerIdentifier> pair : data) {
Event event = new Event();
event.setProgramStage("NpsdDv6kKSO");
DataValue dv1 = new DataValue();
dv1.setDataElement(pair.getLeft());
dv1.setValue("val1");
event.setDataValues(Collections.singleton(dv1));
TrackerImportParams params = buildParams(event, builder().dataElementIdScheme(pair.getRight()).build());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertPreheatedObjectExists(preheat, DataElement.class, pair.getRight(), pair.getLeft());
}
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatIdentifiersTest method testProgramStageIdentifiers.
@Test
void testProgramStageIdentifiers() {
List<Pair<String, TrackerIdentifier>> data = buildDataSet("NpsdDv6kKSO", "PRGA", "ProgramA");
for (Pair<String, TrackerIdentifier> pair : data) {
Event event = new Event();
event.setProgramStage(pair.getLeft());
TrackerImportParams params = buildParams(event, builder().programStageIdScheme(pair.getRight()).build());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertPreheatedObjectExists(preheat, ProgramStage.class, pair.getRight(), pair.getLeft());
}
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatIdentifiersTest method testCategoryOptionComboIdentifiers.
@Test
void testCategoryOptionComboIdentifiers() {
List<Pair<String, TrackerIdentifier>> data = buildDataSet("XXXvX50cXC0", "COCA", "COCAname");
for (Pair<String, TrackerIdentifier> pair : data) {
Event event = new Event();
event.setAttributeOptionCombo(pair.getLeft());
TrackerImportParams params = buildParams(event, builder().categoryOptionComboIdScheme(pair.getRight()).build());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertPreheatedObjectExists(preheat, CategoryOptionCombo.class, pair.getRight(), pair.getLeft());
}
}
Aggregations