Search in sources :

Example 11 with ValidationErrorReporter

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

the class PreCheckMandatoryFieldsValidationHookTest method verifyTrackedEntityValidationFailsOnMissingTrackedEntityType.

@Test
void verifyTrackedEntityValidationFailsOnMissingTrackedEntityType() {
    TrackedEntity trackedEntity = TrackedEntity.builder().trackedEntity(CodeGenerator.generateUid()).trackedEntityType(null).orgUnit(CodeGenerator.generateUid()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateTrackedEntity(reporter, trackedEntity);
    assertMissingPropertyForTrackedEntity(reporter, trackedEntity.getUid(), "trackedEntityType");
}
Also used : TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 12 with ValidationErrorReporter

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

the class PreCheckMandatoryFieldsValidationHookTest method verifyEventValidationFailsOnMissingProgram.

@Test
void verifyEventValidationFailsOnMissingProgram() {
    Event event = Event.builder().event(CodeGenerator.generateUid()).orgUnit(CodeGenerator.generateUid()).programStage(CodeGenerator.generateUid()).program(null).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEvent(reporter, event);
    assertMissingPropertyForEvent(reporter, event.getUid(), "program");
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 13 with ValidationErrorReporter

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

the class PreCheckMandatoryFieldsValidationHookTest method verifyRelationshipValidationSuccess.

@Test
void verifyRelationshipValidationSuccess() {
    Relationship relationship = Relationship.builder().relationship(CodeGenerator.generateUid()).relationshipType(CodeGenerator.generateUid()).from(RelationshipItem.builder().trackedEntity(CodeGenerator.generateUid()).build()).to(RelationshipItem.builder().trackedEntity(CodeGenerator.generateUid()).build()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateRelationship(reporter, relationship);
    assertFalse(reporter.hasErrors());
}
Also used : Relationship(org.hisp.dhis.tracker.domain.Relationship) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 14 with ValidationErrorReporter

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

the class PreCheckMandatoryFieldsValidationHookTest method verifyEnrollmentValidationFailsOnMissingProgram.

@Test
void verifyEnrollmentValidationFailsOnMissingProgram() {
    Enrollment enrollment = Enrollment.builder().enrollment(CodeGenerator.generateUid()).orgUnit(CodeGenerator.generateUid()).program(null).trackedEntity(CodeGenerator.generateUid()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEnrollment(reporter, enrollment);
    assertMissingPropertyForEnrollment(reporter, enrollment.getUid(), "program");
}
Also used : Enrollment(org.hisp.dhis.tracker.domain.Enrollment) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test)

Example 15 with ValidationErrorReporter

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

the class PreCheckMandatoryFieldsValidationHookTest method verifyEventValidationFailsOnMissingOrgUnit.

@Test
void verifyEventValidationFailsOnMissingOrgUnit() {
    Event event = Event.builder().event(CodeGenerator.generateUid()).orgUnit(null).programStage(CodeGenerator.generateUid()).program(CodeGenerator.generateUid()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateEvent(reporter, event);
    assertMissingPropertyForEvent(reporter, event.getUid(), "orgUnit");
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) 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