use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class EventImportValidationTest method testCantWriteAccessCatCombo.
@Test
void testCantWriteAccessCatCombo() throws IOException {
TrackerImportParams trackerImportParams = createBundleFromJson("tracker/validations/events-cat-write-access.json");
User user = userService.getUser(USER_6);
trackerImportParams.setUser(user);
trackerImportParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(4, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1099))));
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1104))));
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1096))));
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1095))));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class EventImportValidationTest method testDeletedEventFails.
@SneakyThrows
private void testDeletedEventFails(TrackerImportStrategy importStrategy) {
// Given -> Creates an event
createEvent("tracker/validations/events-with-notes-data.json");
ProgramStageInstance event = programStageServiceInstance.getProgramStageInstance("uLxFbxfYDQE");
assertNotNull(event);
// When -> Soft-delete the event
programStageServiceInstance.deleteProgramStageInstance(event);
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events-with-notes-data.json");
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
// When
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), everyItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1082))));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class EventImportValidationTest method testTrackerAndProgramEventUpdateSuccess.
@Test
void testTrackerAndProgramEventUpdateSuccess() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/program_and_tracker_events.json");
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
trackerBundleParams.setImportStrategy(UPDATE);
trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class EventImportValidationTest method testCOFoundButAOCNotFound.
@Test
void testCOFoundButAOCNotFound() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events_cant-find-aoc-but-co-exists.json");
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1115))));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class EventImportValidationTest method successWhenTrackedEntityAttributeHasValidOptionValue.
@Test
void successWhenTrackedEntityAttributeHasValidOptionValue() throws IOException {
TrackerImportParams params = createBundleFromJson("tracker/validations/events-with_valid_option_value.json");
params.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(params);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
}
Aggregations