use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventBaseCheckTest method verifyErrorOnInvalidDueDate.
@Test
void verifyErrorOnInvalidDueDate() {
event.setEvent(event.getUid());
event.setDueDate("111-12-122");
ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
assertHasError(importSummary, event, null);
assertHasConflict(importSummary, event, "Invalid event due date: " + event.getDueDate());
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventBaseCheckTest method verifyErrorOnInvalidCreatedAtClientDate.
@Test
void verifyErrorOnInvalidCreatedAtClientDate() {
event.setEvent(event.getUid());
event.setCreatedAtClient("111-12-122");
ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
assertHasError(importSummary, event, null);
assertHasConflict(importSummary, event, "Invalid event created at client date: " + event.getCreatedAtClient());
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventBaseCheckTest method verifyErrorOnEventWithDateNewerThanCompletedProgramInstance.
@Test
void verifyErrorOnEventWithDateNewerThanCompletedProgramInstance() {
// Given
ImportOptions importOptions = ImportOptions.getDefaultImportOptions();
importOptions.setUser(new User());
event.setEvent(event.getUid());
Map<String, ProgramInstance> programInstanceMap = new HashMap<>();
ProgramInstance programInstance = new ProgramInstance();
programInstance.setStatus(ProgramStatus.COMPLETED);
// Set program instance end date to NOW - one month
programInstance.setEndDate(Date.from(ZonedDateTime.now().minusMonths(1).toInstant()));
programInstanceMap.put(event.getUid(), programInstance);
when(workContext.getProgramInstanceMap()).thenReturn(programInstanceMap);
when(workContext.getImportOptions()).thenReturn(importOptions);
// When
ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
// Then
assertHasError(importSummary, event, null);
}
use of org.hisp.dhis.dxf2.events.importer.context.WorkContext in project dhis2-core by dhis2.
the class EventBaseCheckTest method verifyErrorOnMissingProgramInstance.
@Test
void verifyErrorOnMissingProgramInstance() {
event.setEvent(event.getUid());
ImportSummary importSummary = rule.check(new ImmutableEvent(event), workContext);
assertHasError(importSummary, event, null);
assertHasConflict(importSummary, event, "No program instance found for event: " + event.getEvent());
}
Aggregations