use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckUidValidationHookTest method verifyRelationshipValidationSuccess.
@Test
void verifyRelationshipValidationSuccess() {
// given
Relationship relationship = Relationship.builder().relationship(CodeGenerator.generateUid()).build();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateRelationship(reporter, relationship);
// then
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckUidValidationHookTest method verifyTrackedEntityValidationSuccess.
@Test
void verifyTrackedEntityValidationSuccess() {
// given
TrackedEntity trackedEntity = TrackedEntity.builder().trackedEntity(CodeGenerator.generateUid()).orgUnit(CodeGenerator.generateUid()).build();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateTrackedEntity(reporter, trackedEntity);
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventDateValidationHookTest method testEventIsNotValidWhenDateBelongsToExpiredPeriod.
@Test
void testEventIsNotValidWhenDateBelongsToExpiredPeriod() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgram(PROGRAM_WITH_REGISTRATION_ID);
event.setOccurredAt(sevenDaysAgo());
event.setStatus(EventStatus.ACTIVE);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1047, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventDateValidationHookTest method testEventIsNotValidWhenOccurredDateIsNotPresentAndEventIsActive.
@Test
void testEventIsNotValidWhenOccurredDateIsNotPresentAndEventIsActive() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgram(PROGRAM_WITH_REGISTRATION_ID);
event.setStatus(EventStatus.ACTIVE);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1031, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventDateValidationHookTest method testEventIsNotValidWhenOccurredDateIsNotPresentAndProgramIsWithoutRegistration.
@Test
void testEventIsNotValidWhenOccurredDateIsNotPresentAndProgramIsWithoutRegistration() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgram(PROGRAM_WITHOUT_REGISTRATION_ID);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1031, EVENT, event.getUid());
}
Aggregations