use of org.hisp.dhis.tracker.report.TrackerErrorCode.E1120 in project dhis2-core by dhis2.
the class AssignedUserValidationHookTest method testEventWithNullEnabledUserAssignment.
@Test
void testEventWithNullEnabledUserAssignment() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setAssignedUser(USER_ID);
event.setProgramStage(PROGRAM_STAGE);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
ProgramStage programStage = new ProgramStage();
programStage.setEnableUserAssignment(null);
when(validationContext.getProgramStage(PROGRAM_STAGE)).thenReturn(programStage);
this.hookToTest.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
assertTrue(reporter.hasWarnings());
assertTrue(reporter.hasWarningReport(r -> E1120.equals(r.getWarningCode()) && TrackerType.EVENT.equals(r.getTrackerType()) && event.getUid().equals(r.getUid())));
}
use of org.hisp.dhis.tracker.report.TrackerErrorCode.E1120 in project dhis2-core by dhis2.
the class AssignedUserValidationHookTest method testEventWithNotEnabledUserAssignment.
@Test
void testEventWithNotEnabledUserAssignment() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setAssignedUser(USER_ID);
event.setProgramStage(PROGRAM_STAGE);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
ProgramStage programStage = new ProgramStage();
programStage.setEnableUserAssignment(false);
when(validationContext.getProgramStage(PROGRAM_STAGE)).thenReturn(programStage);
this.hookToTest.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
assertTrue(reporter.hasWarnings());
assertTrue(reporter.hasWarningReport(r -> E1120.equals(r.getWarningCode()) && TrackerType.EVENT.equals(r.getTrackerType()) && event.getUid().equals(r.getUid())));
}
Aggregations