use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckUpdatableFieldsValidationHookTest method verifyEventValidationFailsWhenUpdateEnrollment.
@Test
void verifyEventValidationFailsWhenUpdateEnrollment() {
// given
Event event = validEvent();
event.setEnrollment("NewEnrollmentId");
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1128, EVENT, event.getUid());
assertThat(reporter.getReportList().get(0).getErrorMessage(), containsString("enrollment"));
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckUpdatableFieldsValidationHookTest method verifyEventValidationSuccess.
@Test
void verifyEventValidationSuccess() {
// given
Event event = validEvent();
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckUpdatableFieldsValidationHookTest method verifyEventValidationFailsWhenUpdateProgramStage.
@Test
void verifyEventValidationFailsWhenUpdateProgramStage() {
// given
Event event = validEvent();
event.setProgramStage("NewProgramStageId");
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1128, EVENT, event.getUid());
assertThat(reporter.getReportList().get(0).getErrorMessage(), containsString("programStage"));
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class RepeatedEventsValidationHookTest method programEvent.
private Event programEvent(String uid) {
Event event = new Event();
event.setEvent(uid);
event.setProgramStage(NOT_REPEATABLE_PROGRAM_STAGE_WITHOUT_REGISTRATION);
return event;
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class RepeatedEventsValidationHookTest method testTwoEventInRepeatableProgramStageArePassingValidation.
@Test
void testTwoEventInRepeatableProgramStageArePassingValidation() {
List<Event> events = Lists.newArrayList(repeatableEvent("A"), repeatableEvent("B"));
bundle.setEvents(events);
events.forEach(e -> bundle.setStrategy(e, TrackerImportStrategy.CREATE_AND_UPDATE));
ValidationErrorReporter errorReporter = ValidationErrorReporter.emptyReporter();
validatorToTest.validate(errorReporter, ctx);
assertTrue(errorReporter.getReportList().isEmpty());
}
Aggregations