use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerProgramRuleBundleServiceTest method testRunRuleEngineForEventOnBundleCreate.
@Test
void testRunRuleEngineForEventOnBundleCreate() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/event_events_and_enrollment.json");
assertEquals(8, trackerImportParams.getEvents().size());
TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundle = trackerBundleService.runRuleEngine(trackerBundle);
assertEquals(trackerBundle.getEvents().size(), trackerBundle.getEventRuleEffects().size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class LastUpdateImportTest method shouldUpdateTeiIfEventIsUpdated.
@Test
void shouldUpdateTeiIfEventIsUpdated() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/event_with_data_values.json");
Date lastUpdateBefore = trackedEntityInstanceService.getTrackedEntityInstance(trackedEntity.getTrackedEntity()).getLastUpdated();
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
trackerImportParams = fromJson("tracker/event_with_updated_data_values.json");
trackerImportParams.setImportStrategy(TrackerImportStrategy.UPDATE);
assertNoImportErrors(trackerImportService.importTracker(trackerImportParams));
manager.clear();
assertTrue(manager.get(TrackedEntityInstance.class, trackedEntity.getTrackedEntity()).getLastUpdated().getTime() > lastUpdateBefore.getTime());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class LastUpdateImportTest method shouldUpdateTeiIfTeiIsUpdated.
@Test
void shouldUpdateTeiIfTeiIsUpdated() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/single_tei.json", user.getUid());
trackerImportParams.setImportStrategy(TrackerImportStrategy.UPDATE);
Attribute attribute = new Attribute();
attribute.setAttribute("toUpdate000");
attribute.setValue("value");
trackedEntity.setAttributes(Collections.singletonList(attribute));
Date lastUpdateBefore = trackedEntityInstanceService.getTrackedEntityInstance(trackedEntity.getTrackedEntity()).getLastUpdated();
assertNoImportErrors(trackerImportService.importTracker(trackerImportParams));
assertTrue(manager.get(TrackedEntityInstance.class, trackedEntity.getTrackedEntity()).getLastUpdated().getTime() > lastUpdateBefore.getTime());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class LastUpdateImportTest method shouldUpdateTeiIfEnrollmentIsUpdated.
@Test
void shouldUpdateTeiIfEnrollmentIsUpdated() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/single_enrollment.json", user.getUid());
Date lastUpdateBefore = trackedEntityInstanceService.getTrackedEntityInstance(trackedEntity.getTrackedEntity()).getLastUpdated();
Enrollment enrollment = trackerImportParams.getEnrollments().get(0);
enrollment.setStatus(EnrollmentStatus.COMPLETED);
trackerImportParams.setImportStrategy(TrackerImportStrategy.UPDATE);
TrackerImportReport trackerImportReport = trackerImportService.importTracker(trackerImportParams);
assertEquals(TrackerStatus.OK, trackerImportReport.getStatus());
manager.clear();
assertTrue(manager.get(TrackedEntityInstance.class, trackedEntity.getTrackedEntity()).getLastUpdated().getTime() > lastUpdateBefore.getTime());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class LastUpdateImportTest method initTest.
@Override
@Transactional
protected void initTest() throws IOException {
setUpMetadata("tracker/simple_metadata.json");
user = userService.getUser("M5zQapPyTZI");
TrackerImportParams trackerImportParams = fromJson("tracker/single_tei.json", user.getUid());
assertNoImportErrors(trackerImportService.importTracker(trackerImportParams));
trackedEntity = trackerImportParams.getTrackedEntities().get(0);
TrackerImportParams enrollmentParams = fromJson("tracker/single_enrollment.json", user.getUid());
assertNoImportErrors(trackerImportService.importTracker(enrollmentParams));
manager.flush();
}
Aggregations