use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckExistenceValidationHookTest method verifyEventValidationFailsWhenIsSoftDeleted.
@Test
void verifyEventValidationFailsWhenIsSoftDeleted() {
// given
Event event = Event.builder().event(SOFT_DELETED_EVENT_UID).build();
// when
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
validationHook.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1082, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenOrgUnitIsNotPresentInDb.
@Test
void verifyEventValidationFailsWhenOrgUnitIsNotPresentInDb() {
// given
Event event = validEvent();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
when(ctx.getProgramStage(PROGRAM_STAGE_UID)).thenReturn(new ProgramStage());
validatorToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1011, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenProgramStageIsNotPresentInDb.
@Test
void verifyEventValidationFailsWhenProgramStageIsNotPresentInDb() {
// given
Event event = validEvent();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
when(ctx.getProgram(PROGRAM_UID)).thenReturn(new Program());
validatorToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1013, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.domain.Event in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method verifyEventValidationFailsWhenProgramIsNotPresentInDb.
@Test
void verifyEventValidationFailsWhenProgramIsNotPresentInDb() {
// given
Event event = validEvent();
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
// when
when(ctx.getOrganisationUnit(ORG_UNIT_UID)).thenReturn(new OrganisationUnit());
when(ctx.getProgramStage(PROGRAM_STAGE_UID)).thenReturn(new ProgramStage());
validatorToTest.validateEvent(reporter, event);
// then
hasTrackerError(reporter, E1010, EVENT, event.getUid());
}
use of org.hisp.dhis.tracker.domain.Event 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());
}
Aggregations