use of org.hisp.dhis.tracker.domain.Event 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());
}
use of org.hisp.dhis.tracker.domain.Event 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());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class EventDateValidationHookTest method testEventIsNotValidWhenCompletedAtIsNotPresentAndEventIsCompleted.
@Test
void testEventIsNotValidWhenCompletedAtIsNotPresentAndEventIsCompleted() {
// given
Event event = new Event();
event.setEvent(CodeGenerator.generateUid());
event.setProgram(PROGRAM_WITH_REGISTRATION_ID);
event.setOccurredAt(now());
event.setStatus(EventStatus.COMPLETED);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1042, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHookTest method verifyEventValidationSuccessWhenIsUpdate.
@Test
void verifyEventValidationSuccessWhenIsUpdate() {
// given
Event event = Event.builder().event(EVENT_UID).build();
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHookTest method verifyEventValidationFailsWhenIsCreateAndEventIsAlreadyPresent.
@Test
void verifyEventValidationFailsWhenIsCreateAndEventIsAlreadyPresent() {
// given
Event event = Event.builder().event(EVENT_UID).build();
// when
when(ctx.getStrategy(event)).thenReturn(TrackerImportStrategy.CREATE);
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1030, EVENT, event.getUid());
}
Aggregations