use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class LastUpdateImportTest method shouldUpdateTeiIfEventIsUpdated.
@Test
void shouldUpdateTeiIfEventIsUpdated() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/event_with_data_values.json");
Date lastUpdateBefore = trackedEntityInstanceService.getTrackedEntityInstance(trackedEntity.getTrackedEntity()).getLastUpdated();
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
trackerImportParams = fromJson("tracker/event_with_updated_data_values.json");
trackerImportParams.setImportStrategy(TrackerImportStrategy.UPDATE);
assertNoImportErrors(trackerImportService.importTracker(trackerImportParams));
manager.clear();
assertTrue(manager.get(TrackedEntityInstance.class, trackedEntity.getTrackedEntity()).getLastUpdated().getTime() > lastUpdateBefore.getTime());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class LastUpdateImportTest method shouldUpdateTeiIfEnrollmentIsUpdated.
@Test
void shouldUpdateTeiIfEnrollmentIsUpdated() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/single_enrollment.json", user.getUid());
Date lastUpdateBefore = trackedEntityInstanceService.getTrackedEntityInstance(trackedEntity.getTrackedEntity()).getLastUpdated();
Enrollment enrollment = trackerImportParams.getEnrollments().get(0);
enrollment.setStatus(EnrollmentStatus.COMPLETED);
trackerImportParams.setImportStrategy(TrackerImportStrategy.UPDATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
manager.clear();
assertTrue(manager.get(TrackedEntityInstance.class, trackedEntity.getTrackedEntity()).getLastUpdated().getTime() > lastUpdateBefore.getTime());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedEnrollment.
@Test
void testStatsCountForOneCreatedEnrollment() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
trackerImportService.importTracker(params);
inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(params);
assertNotNull(trackerImportEnrollmentReport);
assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
assertEquals(1, trackerImportEnrollmentReport.getStats().getCreated());
assertEquals(0, trackerImportEnrollmentReport.getStats().getUpdated());
assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
assertEquals(0, trackerImportEnrollmentReport.getStats().getDeleted());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryIntegrationTest method testStatsCountForOneCreatedEvent.
@Test
void testStatsCountForOneCreatedEvent() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/single_tei.json").getInputStream();
TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
trackerImportService.importTracker(params);
inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
trackerImportService.importTracker(params);
inputStream = new ClassPathResource("tracker/single_event.json").getInputStream();
params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
TrackerImportReport trackerImportEventReport = trackerImportService.importTracker(params);
assertNotNull(trackerImportEventReport);
assertEquals(TrackerStatus.OK, trackerImportEventReport.getStatus());
assertTrue(trackerImportEventReport.getValidationReport().getErrors().isEmpty());
assertEquals(1, trackerImportEventReport.getStats().getCreated());
assertEquals(0, trackerImportEventReport.getStats().getUpdated());
assertEquals(0, trackerImportEventReport.getStats().getIgnored());
assertEquals(0, trackerImportEventReport.getStats().getDeleted());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryIntegrationTest method testStatsCountForOneUpdateEnrollmentAndOneCreatedEnrollment.
@Test
void testStatsCountForOneUpdateEnrollmentAndOneCreatedEnrollment() throws IOException {
InputStream inputStream = new ClassPathResource("tracker/one_update_tei_and_one_new_tei.json").getInputStream();
TrackerImportParams params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
trackerImportService.importTracker(params);
inputStream = new ClassPathResource("tracker/single_enrollment.json").getInputStream();
params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
trackerImportService.importTracker(params);
inputStream = new ClassPathResource("tracker/one_update_enrollment_and_one_new_enrollment.json").getInputStream();
params = renderService.fromJson(inputStream, TrackerImportParams.class);
params.setUserId(userA.getUid());
params.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
TrackerImportReport trackerImportEnrollmentReport = trackerImportService.importTracker(params);
assertNotNull(trackerImportEnrollmentReport);
assertEquals(TrackerStatus.OK, trackerImportEnrollmentReport.getStatus());
assertTrue(trackerImportEnrollmentReport.getValidationReport().getErrors().isEmpty());
assertEquals(1, trackerImportEnrollmentReport.getStats().getCreated());
assertEquals(1, trackerImportEnrollmentReport.getStats().getUpdated());
assertEquals(0, trackerImportEnrollmentReport.getStats().getIgnored());
assertEquals(0, trackerImportEnrollmentReport.getStats().getDeleted());
}
Aggregations