Search in sources :

Example 56 with ValidationErrorReporter

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

the class PreCheckUpdatableFieldsValidationHookTest method verifyTrackedEntityValidationSuccess.

@Test
void verifyTrackedEntityValidationSuccess() {
    // given
    TrackedEntity trackedEntity = validTei();
    // when
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateTrackedEntity(reporter, trackedEntity);
    // then
    assertFalse(reporter.hasErrors());
}
Also used : TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 57 with ValidationErrorReporter

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

the class PreCheckUpdatableFieldsValidationHookTest method verifyEventValidationSuccess.

@Test
void verifyEventValidationSuccess() {
    // given
    Event event = validEvent();
    // when
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEvent(reporter, event);
    // then
    assertFalse(reporter.hasErrors());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 58 with ValidationErrorReporter

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

the class PreCheckUpdatableFieldsValidationHookTest method verifyEnrollmentValidationSuccess.

@Test
void verifyEnrollmentValidationSuccess() {
    // given
    Enrollment enrollment = validEnrollment();
    // when
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEnrollment(reporter, enrollment);
    // then
    assertFalse(reporter.hasErrors());
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 59 with ValidationErrorReporter

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

the class PreCheckUpdatableFieldsValidationHookTest method verifyEventValidationFailsWhenUpdateProgramStage.

@Test
void verifyEventValidationFailsWhenUpdateProgramStage() {
    // given
    Event event = validEvent();
    event.setProgramStage("NewProgramStageId");
    // when
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1128, EVENT, event.getUid());
    assertThat(reporter.getReportList().get(0).getErrorMessage(), containsString("programStage"));
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 60 with ValidationErrorReporter

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

the class PreCheckUpdatableFieldsValidationHookTest method verifyEnrollmentValidationFailsWhenUpdateTrackedEntity.

@Test
void verifyEnrollmentValidationFailsWhenUpdateTrackedEntity() {
    // given
    Enrollment enrollment = validEnrollment();
    enrollment.setTrackedEntity("NewTrackedEntityId");
    // when
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEnrollment(reporter, enrollment);
    // then
    hasTrackerError(reporter, E1127, ENROLLMENT, enrollment.getUid());
    assertThat(reporter.getReportList().get(0).getErrorMessage(), containsString("trackedEntity"));
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment) 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