Search in sources :

Example 71 with ValidationErrorReporter

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());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Program(org.hisp.dhis.program.Program) Enrollment(org.hisp.dhis.tracker.domain.Enrollment) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 72 with ValidationErrorReporter

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());
}
Also used : Program(org.hisp.dhis.program.Program) Enrollment(org.hisp.dhis.tracker.domain.Enrollment) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) Test(org.junit.jupiter.api.Test)

Example 73 with ValidationErrorReporter

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());
}
Also used : TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 74 with ValidationErrorReporter

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());
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 75 with ValidationErrorReporter

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());
}
Also used : Relationship(org.hisp.dhis.tracker.domain.Relationship) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Aggregations

ValidationErrorReporter (org.hisp.dhis.tracker.report.ValidationErrorReporter)206 Test (org.junit.jupiter.api.Test)192 Event (org.hisp.dhis.tracker.domain.Event)89 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)48 Enrollment (org.hisp.dhis.tracker.domain.Enrollment)48 TrackedEntity (org.hisp.dhis.tracker.domain.TrackedEntity)43 ProgramStage (org.hisp.dhis.program.ProgramStage)38 DataElement (org.hisp.dhis.dataelement.DataElement)25 ProgramStageDataElement (org.hisp.dhis.program.ProgramStageDataElement)25 TrackerImportValidationContext (org.hisp.dhis.tracker.validation.TrackerImportValidationContext)24 Relationship (org.hisp.dhis.tracker.domain.Relationship)23 DataValue (org.hisp.dhis.tracker.domain.DataValue)21 Program (org.hisp.dhis.program.Program)19 TrackerBundle (org.hisp.dhis.tracker.bundle.TrackerBundle)19 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)17 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)16 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 RelationshipType (org.hisp.dhis.relationship.RelationshipType)12 BeforeEach (org.junit.jupiter.api.BeforeEach)12 ProgramInstance (org.hisp.dhis.program.ProgramInstance)11