Search in sources :

Example 76 with ValidationErrorReporter

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

the class PreCheckUidValidationHookTest method verifyRelationshipValidationSuccess.

@Test
void verifyRelationshipValidationSuccess() {
    // given
    Relationship relationship = Relationship.builder().relationship(CodeGenerator.generateUid()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateRelationship(reporter, relationship);
    // then
    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 77 with ValidationErrorReporter

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

the class PreCheckUidValidationHookTest method verifyTrackedEntityValidationSuccess.

@Test
void verifyTrackedEntityValidationSuccess() {
    // given
    TrackedEntity trackedEntity = TrackedEntity.builder().trackedEntity(CodeGenerator.generateUid()).orgUnit(CodeGenerator.generateUid()).build();
    ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
    validationHook.validateTrackedEntity(reporter, trackedEntity);
    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 78 with ValidationErrorReporter

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

the class EventDateValidationHookTest method testEventIsNotValidWhenDateBelongsToExpiredPeriod.

@Test
void testEventIsNotValidWhenDateBelongsToExpiredPeriod() {
    // given
    Event event = new Event();
    event.setEvent(CodeGenerator.generateUid());
    event.setProgram(PROGRAM_WITH_REGISTRATION_ID);
    event.setOccurredAt(sevenDaysAgo());
    event.setStatus(EventStatus.ACTIVE);
    ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
    // when
    this.hookToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1047, EVENT, event.getUid());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 79 with ValidationErrorReporter

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

the class EventDateValidationHookTest method testEventIsNotValidWhenOccurredDateIsNotPresentAndEventIsActive.

@Test
void testEventIsNotValidWhenOccurredDateIsNotPresentAndEventIsActive() {
    // given
    Event event = new Event();
    event.setEvent(CodeGenerator.generateUid());
    event.setProgram(PROGRAM_WITH_REGISTRATION_ID);
    event.setStatus(EventStatus.ACTIVE);
    ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
    // when
    this.hookToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1031, EVENT, event.getUid());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

Example 80 with ValidationErrorReporter

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

the class EventDateValidationHookTest method testEventIsNotValidWhenOccurredDateIsNotPresentAndProgramIsWithoutRegistration.

@Test
void testEventIsNotValidWhenOccurredDateIsNotPresentAndProgramIsWithoutRegistration() {
    // given
    Event event = new Event();
    event.setEvent(CodeGenerator.generateUid());
    event.setProgram(PROGRAM_WITHOUT_REGISTRATION_ID);
    ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
    // when
    this.hookToTest.validateEvent(reporter, event);
    // then
    hasTrackerError(reporter, E1031, EVENT, event.getUid());
}
Also used : Event(org.hisp.dhis.tracker.domain.Event) ValidationErrorReporter(org.hisp.dhis.tracker.report.ValidationErrorReporter) Test(org.junit.jupiter.api.Test) DhisConvenienceTest(org.hisp.dhis.DhisConvenienceTest)

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