use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNoCategoryOptionCombo.
@Test
void testNoCategoryOptionCombo() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events_cant-find-cat-opt-combo.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.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNonRepeatableProgramStage.
@Test
void testNonRepeatableProgramStage() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/validations/events_non-repeatable-programstage_part1.json", userService.getUser(ADMIN_USER_UID));
trackerImportParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(0, trackerImportReport.getValidationReport().getErrors().size());
trackerImportParams = fromJson("tracker/validations/events_non-repeatable-programstage_part2.json", userService.getUser(ADMIN_USER_UID));
trackerImportParams.setImportStrategy(TrackerImportStrategy.CREATE);
trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1039))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNonDefaultCategoryCombo.
@Test
void testNonDefaultCategoryCombo() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events_non-default-combo.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.E1055))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testNoWriteAccessToOrg.
@Test
void testNoWriteAccessToOrg() throws IOException {
TrackerImportParams trackerBundleParams = createBundleFromJson("tracker/validations/events-data.json");
User user = userService.getUser(USER_2);
trackerBundleParams.setUser(user);
trackerBundleParams.setImportStrategy(TrackerImportStrategy.CREATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerBundleParams);
assertEquals(1, trackerImportReport.getValidationReport().getErrors().size());
assertThat(trackerImportReport.getValidationReport().getErrors(), hasItem(hasProperty("errorCode", equalTo(TrackerErrorCode.E1000))));
}
use of org.hisp.dhis.tracker.report.TrackerImportReport in project dhis2-core by dhis2.
the class EventImportValidationTest method testValidateAndAddNotesToUpdatedEvent.
@Test
void testValidateAndAddNotesToUpdatedEvent() throws IOException {
Date now = new Date();
// Given -> Creates an event with 3 notes
createEvent("tracker/validations/events-with-notes-data.json");
// When -> Update the event and adds 3 more notes
TrackerImportReport trackerImportReport = createEvent("tracker/validations/events-with-notes-update-data.json");
// Then
final ProgramStageInstance programStageInstance = getEventFromReport(trackerImportReport);
assertThat(programStageInstance.getComments(), hasSize(6));
// validate note content
Stream.of("first note", "second note", "third note", "4th note", "5th note", "6th note").forEach(t -> {
TrackedEntityComment comment = getByComment(programStageInstance.getComments(), t);
assertTrue(CodeGenerator.isValidUid(comment.getUid()));
assertTrue(comment.getCreated().getTime() > now.getTime());
assertTrue(comment.getLastUpdated().getTime() > now.getTime());
assertNotNull(comment.getCreator());
assertEquals(ADMIN_USER_UID, comment.getLastUpdatedBy().getUid());
});
}
Aggregations