use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class ValidationErrorReporterTest method hasErrorReportFound.
@Test
void hasErrorReportFound() {
ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
TrackerBundle bundle = mock(TrackerBundle.class);
TrackerErrorReport error = TrackerErrorReport.builder().errorCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
reporter.getReportList().add(error);
assertTrue(reporter.hasErrorReport(r -> TrackerType.EVENT.equals(r.getTrackerType())));
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class ValidationErrorReporterTest method hasWarningReportNotFound.
@Test
void hasWarningReportNotFound() {
ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
TrackerBundle bundle = mock(TrackerBundle.class);
TrackerWarningReport warning = TrackerWarningReport.builder().warningCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
reporter.getWarningsReportList().add(warning);
assertFalse(reporter.hasWarningReport(r -> TrackerType.TRACKED_ENTITY.equals(r.getTrackerType())));
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class ValidationErrorReporterTest method hasWarningReportFound.
@Test
void hasWarningReportFound() {
ValidationErrorReporter reporter = ValidationErrorReporter.emptyReporter();
TrackerBundle bundle = mock(TrackerBundle.class);
TrackerWarningReport warning = TrackerWarningReport.builder().warningCode(TrackerErrorCode.E1000).trackerType(TrackerType.EVENT).build(bundle);
reporter.getWarningsReportList().add(warning);
assertTrue(reporter.hasWarningReport(r -> TrackerType.EVENT.equals(r.getTrackerType())));
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EnrollmentNoteValidationHookTest method testNoteWithExistingUidAndNoTextIsIgnored.
@Test
void testNoteWithExistingUidAndNoTextIsIgnored() {
// Given
final Note note = rnd.nextObject(Note.class);
note.setValue(null);
TrackerBundle trackerBundle = mock(TrackerBundle.class);
TrackerImportValidationContext ctx = mock(TrackerImportValidationContext.class);
when(ctx.getBundle()).thenReturn(trackerBundle);
when(trackerBundle.getValidationMode()).thenReturn(ValidationMode.FULL);
when(ctx.getNote(note.getNote())).thenReturn(Optional.of(new TrackedEntityComment()));
ValidationErrorReporter reporter = new ValidationErrorReporter(ctx);
enrollment.setNotes(Collections.singletonList(note));
// When
this.hook.validateEnrollment(reporter, enrollment);
// Then
assertFalse(reporter.hasErrors());
assertThat(enrollment.getNotes(), hasSize(0));
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventDateValidationHookTest method testEventIsValid.
@Test
void testEventIsValid() {
// given
Event event = new Event();
event.setProgram(PROGRAM_WITHOUT_REGISTRATION_ID);
event.setOccurredAt(now());
event.setStatus(EventStatus.ACTIVE);
TrackerBundle bundle = TrackerBundle.builder().user(getEditExpiredUser()).build();
when(validationContext.getBundle()).thenReturn(bundle);
ValidationErrorReporter reporter = new ValidationErrorReporter(validationContext);
// when
this.hookToTest.validateEvent(reporter, event);
// then
assertFalse(reporter.hasErrors());
}
Aggregations