use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventDataValuesValidationHookTest method succeedsOnSkippedEventWithDataElementValueIsNullAndEventStatusSkippedOrScheduled.
@Test
void succeedsOnSkippedEventWithDataElementValueIsNullAndEventStatusSkippedOrScheduled() {
setUpIdentifiers();
DataElement validDataElement = dataElement();
when(context.getDataElement(dataElementUid)).thenReturn(validDataElement);
ProgramStage programStage = programStage(validDataElement, true);
when(context.getProgramStage(programStageUid)).thenReturn(programStage);
ValidationErrorReporter reporter = new ValidationErrorReporter(context);
DataValue validDataValue = dataValue();
validDataValue.setValue(null);
Event event = Event.builder().programStage(programStage.getUid()).status(EventStatus.SKIPPED).dataValues(Set.of(validDataValue)).build();
hook.validateEvent(reporter, event);
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventGeoValidationHookTest method testProgramStageWithFeatureTypeNoneFailsGeometryValidation.
@Test
void testProgramStageWithFeatureTypeNoneFailsGeometryValidation() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgramStage(PROGRAM_STAGE);
event.setGeometry(new GeometryFactory().createPoint());
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
ProgramStage programStage = new ProgramStage();
programStage.setFeatureType(NONE);
when(validationContext.getProgramStage(event.getProgramStage())).thenReturn(programStage);
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1012, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventGeoValidationHookTest method testProgramStageWithNullFeatureTypeFailsGeometryValidation.
@Test
void testProgramStageWithNullFeatureTypeFailsGeometryValidation() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgramStage(PROGRAM_STAGE);
event.setGeometry(new GeometryFactory().createPoint());
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
when(validationContext.getProgramStage(event.getProgramStage())).thenReturn(new ProgramStage());
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1074, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class EventGeoValidationHookTest method testGeometryIsValid.
@Test
void testGeometryIsValid() {
// given
Event event = new Event();
event.setProgramStage(PROGRAM_STAGE);
event.setGeometry(new GeometryFactory().createPoint());
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.report.ValidationErrorReporter in project dhis2-core by dhis2.
the class PreCheckDataRelationsValidationHookTest method setUp.
@BeforeEach
void setUp() {
hook = new PreCheckDataRelationsValidationHook(categoryService);
bundle = TrackerBundle.builder().preheat(preheat).build();
ctx = new TrackerImportValidationContext(bundle);
reporter = new ValidationErrorReporter(ctx);
}
Aggregations