use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventDateValidationHookTest method setUp.
@BeforeEach
public void setUp() {
hookToTest = new EventDateValidationHook();
User user = createUser('A');
TrackerBundle bundle = TrackerBundle.builder().user(user).build();
when(validationContext.getBundle()).thenReturn(bundle);
when(validationContext.getProgram(PROGRAM_WITH_REGISTRATION_ID)).thenReturn(getProgramWithRegistration());
when(validationContext.getProgram(PROGRAM_WITHOUT_REGISTRATION_ID)).thenReturn(getProgramWithoutRegistration());
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class PreCheckMetaValidationHookTest method setUp.
@BeforeEach
public void setUp() {
validatorToTest = new PreCheckMetaValidationHook();
TrackerBundle bundle = TrackerBundle.builder().build();
when(ctx.getBundle()).thenReturn(bundle);
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class EventNoteValidationHookTest 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);
event.setNotes(Collections.singletonList(note));
// When
this.hook.validateEvent(reporter, event);
// Then
assertFalse(reporter.hasErrors());
assertThat(event.getNotes(), hasSize(0));
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class TrackedEntityAttributeValidationHookTest method setUp.
@BeforeEach
public void setUp() {
TrackerBundle bundle = TrackerBundle.builder().build();
when(validationContext.getBundle()).thenReturn(bundle);
when(dhisConfigurationProvider.getEncryptionStatus()).thenReturn(EncryptionStatus.OK);
}
use of org.hisp.dhis.tracker.bundle.TrackerBundle in project dhis2-core by dhis2.
the class DefaultTrackerImportService method importTracker.
@Override
public TrackerImportReport importTracker(TrackerImportParams params) {
User user = trackerUserService.getUser(params.getUserId());
params.setUser(user);
TrackerTimingsStats opsTimer = new TrackerTimingsStats();
startImport(params);
TrackerValidationReport validationReport = new TrackerValidationReport();
TrackerBundleReport bundleReport;
try {
TrackerBundle trackerBundle = preHeat(params, opsTimer);
Map<TrackerType, Integer> bundleSize = calculatePayloadSize(trackerBundle);
preProcess(opsTimer, trackerBundle);
if (addToValidationReport(params, opsTimer, validationReport, trackerBundle)) {
return buildReportAndNotify(params, validationReport, opsTimer, bundleSize);
}
bundleReport = commit(params, opsTimer, trackerBundle);
postCommit(trackerBundle);
TrackerImportReport trackerImportReport = TrackerImportReport.withImportCompleted(TrackerStatus.OK, bundleReport, validationReport, opsTimer.stopTimer(), bundleSize);
endImport(params, trackerImportReport);
return trackerImportReport;
} catch (Exception e) {
log.error("Exception thrown during import.", e);
TrackerImportReport report = TrackerImportReport.withError("Exception:" + e.getMessage(), validationReport, opsTimer.stopTimer());
endImportWithError(params, report, e);
return report;
}
}
Aggregations