use of org.hisp.dhis.tracker.domain.Enrollment in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEnrollmentValidationFailsWhenProgramIsNotPresentInDb.
@Test
void verifyEnrollmentValidationFailsWhenProgramIsNotPresentInDb() {
// given
Enrollment enrollment = validEnrollment();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
when(ctx.getTrackedEntityInstance(TRACKED_ENTITY_UID)).thenReturn(new TrackedEntityInstance());
validatorToTest.validateEnrollment(reporter, enrollment);
// then
hasTrackerError(reporter, E1069, ENROLLMENT, enrollment.getUid());
}
use of org.hisp.dhis.tracker.domain.Enrollment 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.domain.Enrollment 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.domain.Enrollment 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.domain.Enrollment in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHookTest method verifyEnrollmentValidationFailsWhenIsUpdateAndEnrollmentIsNotPresent.
@Test
void verifyEnrollmentValidationFailsWhenIsUpdateAndEnrollmentIsNotPresent() {
// given
Enrollment enrollment = Enrollment.builder().enrollment(NOT_PRESENT_ENROLLMENT_UID).build();
// when
when(ctx.getStrategy(enrollment)).thenReturn(TrackerImportStrategy.UPDATE);
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEnrollment(reporter, enrollment);
// then
hasTrackerError(reporter, E1081, ENROLLMENT, enrollment.getUid());
}
Aggregations