Search in sources :

Example 66 with ValidationErrorReporter

use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.

the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenOrgUnitIsNotPresentInDb.

@Test
void verifyEventValidationFailsWhenOrgUnitIsNotPresentInDb() {
    // given
    Event event = validEvent();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    // when
    when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
    when(ctx.getProgramStage(PROGRAM_STAGE_UID)).thenReturn(new ProgramStage());
    validatorToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1011, EVENT, event.getUid());
}
Also used : Program(org.hisp.dhis.program.Program) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 67 with ValidationErrorReporter

use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.

the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenProgramStageIsNotPresentInDb.

@Test
void verifyEventValidationFailsWhenProgramStageIsNotPresentInDb() {
    // given
    Event event = validEvent();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    // when
    when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
    when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
    validatorToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1013, EVENT, event.getUid());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Program(org.hisp.dhis.program.Program) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 68 with ValidationErrorReporter

use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.

the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenProgramIsNotPresentInDb.

@Test
void verifyEventValidationFailsWhenProgramIsNotPresentInDb() {
    // given
    Event event = validEvent();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    // when
    when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
    when(ctx.getProgramStage(PROGRAM_STAGE_UID)).thenReturn(new ProgramStage());
    validatorToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1010, EVENT, event.getUid());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) ProgramStage(org.hisp.dhis.program.ProgramStage) Test(org.junit.jupiter.api.Test)

Example 69 with ValidationErrorReporter

use of org.hisp.dhis.tracker.report.ValidationErrorReporter 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());
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) 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 70 with ValidationErrorReporter

use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.

the class PreCheckMetaValidationHookTest method verifyTrackedEntityValidationFailsWhenOrgUnitIsNotPresentInDb.

@Test
void verifyTrackedEntityValidationFailsWhenOrgUnitIsNotPresentInDb() {
    // given
    TrackedEntity tei = validTei();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    // when
    when(ctx.getTrackedEntityType(TRACKED_ENTITY_TYPE_UID)).thenReturn(new TrackedEntityType());
    validatorToTest.validateTrackedEntity(reporter, tei);
    // then
    hasTrackerError(reporter, E1049, TRACKED_ENTITY, tei.getUid());
}
Also used : TrackedEntityType(org.hisp.dhis.trackedentity.TrackedEntityType) TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) 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