use of org.hisp.dhis.tracker.report.TrackerImportReport 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.report.TrackerImportReport 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.report.TrackerImportReport in project dhis2-core by dhis2.
the class RelationshipImportTest method successUpdateRelationships.
@Test
void successUpdateRelationships() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/relationships.json");
trackerImportService.importTracker(trackerImportParams);
trackerImportParams = fromJson("tracker/relationshipToUpdate.json");
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertThat(trackerImportReport.getStatus(), is(TrackerStatus.OK));
assertThat(trackerImportReport.getStats().getCreated(), is(0));
assertThat(trackerImportReport.getStats().getIgnored(), is(1));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class RelationshipImportTest method successImportingRelationships.
@Test
void successImportingRelationships() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/relationships.json");
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertThat(trackerImportReport.getStatus(), is(TrackerStatus.OK));
assertThat(trackerImportReport.getStats().getCreated(), is(2));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedTEI.
@Test
void testStatsCountForOneCreatedTEI() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/single_tei.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());
assertTrue(trackerImportTeiReport.getValidationReport().getErrors().isEmpty());
assertEquals(1, trackerImportTeiReport.getStats().getCreated());
assertEquals(0, trackerImportTeiReport.getStats().getUpdated());
assertEquals(0, trackerImportTeiReport.getStats().getIgnored());
assertEquals(0, trackerImportTeiReport.getStats().getDeleted());
}
Aggregations