use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class OwnershipTest method testCreateEnrollmentWithoutOwnership.
@Test
void testCreateEnrollmentWithoutOwnership() throws IOException {
TrackerImportParams enrollmentParams = fromJson("tracker/ownership_enrollment.json", nonSuperUser.getUid());
List<ProgramInstance> pis = manager.getAll(ProgramInstance.class);
assertEquals(2, pis.size());
enrollmentParams.setImportStrategy(TrackerImportStrategy.DELETE);
TrackerImportReport updatedReport = trackerImportService.importTracker(enrollmentParams);
assertNoImportErrors(updatedReport);
assertEquals(1, updatedReport.getStats().getDeleted());
TrackedEntityInstance tei = manager.get(TrackedEntityInstance.class, "IOR1AXXl24H");
OrganisationUnit ou = manager.get(OrganisationUnit.class, "B1nCbRV3qtP");
Program pgm = manager.get(Program.class, "BFcipDERJnf");
trackerOwnershipManager.transferOwnership(tei, pgm, ou, true, false);
enrollmentParams.setImportStrategy(TrackerImportStrategy.CREATE);
enrollmentParams.getEnrollments().get(0).setEnrollment(CodeGenerator.generateUid());
updatedReport = trackerImportService.importTracker(enrollmentParams);
assertEquals(1, updatedReport.getStats().getIgnored());
assertEquals(TrackerErrorCode.E1102, updatedReport.getValidationReport().getErrors().get(0).getErrorCode());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryDeleteIntegrationTest method testEnrollmentDeletion.
@Test
void testEnrollmentDeletion() throws IOException {
assertEquals(4, manager.getAll(ProgramInstance.class).size());
assertEquals(2, manager.getAll(ProgramStageInstance.class).size());
TrackerImportParams params = fromJson("tracker/enrollment_basic_data_for_deletion.json");
params.setImportStrategy(TrackerImportStrategy.DELETE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertDeletedObjects(trackerImportReport.getBundleReport(), 1, TrackerType.ENROLLMENT);
// remaining
assertEquals(3, manager.getAll(ProgramInstance.class).size());
// delete associated events as well
assertEquals(1, manager.getAll(ProgramStageInstance.class).size());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryDeleteIntegrationTest method testDeleteMultipleEntities.
@Test
void testDeleteMultipleEntities() throws IOException {
TrackerImportParams params = fromJson("tracker/tracker_data_for_deletion.json");
params.setImportStrategy(TrackerImportStrategy.DELETE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertDeletedObjects(trackerImportReport.getBundleReport(), 1, TrackerType.ENROLLMENT);
assertDeletedObjects(trackerImportReport.getBundleReport(), 1, TrackerType.TRACKED_ENTITY);
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryDeleteIntegrationTest method testNonExistentEnrollment.
@Test
void testNonExistentEnrollment() throws IOException {
TrackerImportParams params = fromJson("tracker/non_existent_enrollment_basic_data_for_deletion.json");
params.setImportStrategy(TrackerImportStrategy.DELETE);
TrackerImportReport importReport = trackerImportService.importTracker(params);
assertEquals(TrackerStatus.ERROR, importReport.getStatus());
assertTrue(importReport.getValidationReport().hasErrors());
List<TrackerErrorReport> trackerErrorReports = importReport.getValidationReport().getErrors();
assertEquals(TrackerErrorCode.E1081, trackerErrorReports.get(0).getErrorCode());
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class ReportSummaryDeleteIntegrationTest method testEventDeletion.
@Test
void testEventDeletion() throws IOException {
TrackerImportParams params = fromJson("tracker/event_basic_data_for_deletion.json");
params.setImportStrategy(TrackerImportStrategy.DELETE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertDeletedObjects(trackerImportReport.getBundleReport(), 1, TrackerType.EVENT);
// remaining
assertEquals(1, manager.getAll(ProgramStageInstance.class).size());
}
Aggregations