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");
}
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");
}
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());
}
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");
}
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");
}
Aggregations