use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEnrollmentValidationFailsWhenTrackedEntityIsNotPresentInDbOrPayload.
@Test
void verifyEnrollmentValidationFailsWhenTrackedEntityIsNotPresentInDbOrPayload() {
// given
Enrollment enrollment = validEnrollment();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
validatorToTest.validateEnrollment(reporter, enrollment);
// then
hasTrackerError(reporter, E1068, ENROLLMENT, enrollment.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEnrollmentValidationFailsWhenOrgUnitIsNotPresentInDb.
@Test
void verifyEnrollmentValidationFailsWhenOrgUnitIsNotPresentInDb() {
// given
Enrollment enrollment = validEnrollment();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
when(ctx.getTrackedEntityInstance(TRACKED_ENTITY_UID)).thenReturn(new TrackedEntityInstance());
validatorToTest.validateEnrollment(reporter, enrollment);
// then
hasTrackerError(reporter, E1070, ENROLLMENT, enrollment.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckUidValidationHookTest method verifyTrackedEntityWithInvalidUidFails.
@Test
void verifyTrackedEntityWithInvalidUidFails() {
// given
TrackedEntity trackedEntity = TrackedEntity.builder().trackedEntity(INVALID_UID).orgUnit(CodeGenerator.generateUid()).build();
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateTrackedEntity(reporter, trackedEntity);
// then
hasTrackerError(reporter, E1048, TRACKED_ENTITY, trackedEntity.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckUidValidationHookTest method verifyEnrollmentWithInvalidUidFails.
@Test
void verifyEnrollmentWithInvalidUidFails() {
// given
Enrollment enrollment = Enrollment.builder().enrollment(INVALID_UID).build();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEnrollment(reporter, enrollment);
// then
hasTrackerError(reporter, E1048, ENROLLMENT, enrollment.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckUidValidationHookTest method verifyRelationshipWithInvalidUidFails.
@Test
void verifyRelationshipWithInvalidUidFails() {
// given
Relationship relationship = Relationship.builder().relationship(INVALID_UID).build();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateRelationship(reporter, relationship);
// then
hasTrackerError(reporter, E1048, RELATIONSHIP, relationship.getUid());
}
Aggregations