use of org.hisp.dhis.tracker.report.ValidationErrorReporter 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());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class RepeatedEventsValidationHookTest method testTwoEventsInNotRepeatableProgramStageWhenOneIsInvalidArePassingValidation.
@Test
void testTwoEventsInNotRepeatableProgramStageWhenOneIsInvalidArePassingValidation() {
Event invalidEvent = notRepeatableEvent("A");
List<Event> events = Lists.newArrayList(invalidEvent, notRepeatableEvent("B"));
bundle.setEvents(events);
events.forEach(e -> bundle.setStrategy(e, TrackerImportStrategy.CREATE_AND_UPDATE));
ValidationErrorReporter errorReporter = ValidationErrorReporter.emptyReporter();
errorReporter.getInvalidDTOs().put(TrackerType.EVENT, Lists.newArrayList(invalidEvent.getUid()));
validatorToTest.validate(errorReporter, ctx);
assertTrue(errorReporter.getReportList().isEmpty());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class RepeatedEventsValidationHookTest method testTwoEventInNotRepeatableProgramStageAreNotPassingValidation.
@Test
void testTwoEventInNotRepeatableProgramStageAreNotPassingValidation() {
List<Event> events = Lists.newArrayList(notRepeatableEvent("A"), notRepeatableEvent("B"));
bundle.setEvents(events);
events.forEach(e -> bundle.setStrategy(e, TrackerImportStrategy.CREATE_AND_UPDATE));
ValidationErrorReporter errorReporter = new ValidationErrorReporter(new TrackerImportValidationContext(bundle));
validatorToTest.validate(errorReporter, ctx);
assertEquals(2, errorReporter.getReportList().size());
assertThat(errorReporter.getReportList().get(0).getErrorCode(), is(TrackerErrorCode.E1039));
assertThat(errorReporter.getReportList().get(0).getTrackerType(), is(EVENT));
assertThat(errorReporter.getReportList().get(0).getUid(), is(events.get(0).getUid()));
assertThat(errorReporter.getReportList().get(0).getErrorMessage(), is("ProgramStage: `" + NOT_REPEATABLE_PROGRAM_STAGE_WITH_REGISTRATION + "`, is not repeatable and an event already exists."));
assertThat(errorReporter.getReportList().get(1).getErrorCode(), is(TrackerErrorCode.E1039));
assertThat(errorReporter.getReportList().get(1).getTrackerType(), is(EVENT));
assertThat(errorReporter.getReportList().get(1).getUid(), is(events.get(1).getUid()));
assertThat(errorReporter.getReportList().get(1).getErrorMessage(), is("ProgramStage: `" + NOT_REPEATABLE_PROGRAM_STAGE_WITH_REGISTRATION + "`, is not repeatable and an event already exists."));
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class RepeatedEventsValidationHookTest method testSingleEventIsPassingValidation.
@Test
void testSingleEventIsPassingValidation() {
List<Event> events = Lists.newArrayList(notRepeatableEvent("A"));
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());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHookTest method verifyEventValidationFailsWhenIsSoftDeleted.
@Test
void verifyEventValidationFailsWhenIsSoftDeleted() {
// given
Event event = Event.builder().event(SOFT_DELETED_EVENT_UID).build();
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1082, EVENT, event.getUid());
}
Aggregations