use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityProgramAttributeTest method testTrackedEntityProgramAttributeValueUpdateAndDelete.
@Test
void testTrackedEntityProgramAttributeValueUpdateAndDelete() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/te_program_with_tea_data.json");
TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
List<TrackedEntityInstance> trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(1, trackedEntityInstances.size());
TrackedEntityInstance trackedEntityInstance = trackedEntityInstances.get(0);
List<TrackedEntityAttributeValue> attributeValues = trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntityInstance);
assertEquals(4, attributeValues.size());
manager.clear();
// update
trackerImportParams = fromJson("tracker/te_program_with_tea_update_data.json");
trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(1, trackedEntityInstances.size());
trackedEntityInstance = trackedEntityInstances.get(0);
attributeValues = trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntityInstance);
assertEquals(4, attributeValues.size());
manager.clear();
// delete
trackerImportParams = fromJson("tracker/te_program_with_tea_delete_data.json");
trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(1, trackedEntityInstances.size());
trackedEntityInstance = trackedEntityInstances.get(0);
attributeValues = trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntityInstance);
assertEquals(1, attributeValues.size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerImporterServiceTest method testSkipSideEffect.
@Test
void testSkipSideEffect() {
TrackerImportParams parameters = TrackerImportParams.builder().events(params.getEvents()).enrollments(new ArrayList<>()).relationships(new ArrayList<>()).trackedEntities(new ArrayList<>()).skipSideEffects(true).userId("123").build();
when(trackerBundleService.create(any(TrackerImportParams.class))).thenReturn(ParamsConverter.convert(parameters));
subject.importTracker(parameters);
verify(trackerBundleService, times(0)).handleTrackerSideEffects(anyList());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackedEntityProgramAttributeFileResourceTest method testTrackedEntityProgramAttributeFileResourceValue.
@Test
void testTrackedEntityProgramAttributeFileResourceValue() throws IOException {
FileResource fileResource = new FileResource("test.pdf", "application/pdf", 0, "d41d8cd98f00b204e9800998ecf8427e", FileResourceDomain.DOCUMENT);
fileResource.setUid("Jzf6hHNP7jx");
File file = File.createTempFile("file-resource", "test");
fileResourceService.saveFileResource(fileResource, file);
assertFalse(fileResource.isAssigned());
TrackerImportParams trackerImportParams = fromJson("tracker/te_program_with_tea_fileresource_data.json");
TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
List<TrackedEntityInstance> trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(1, trackedEntityInstances.size());
TrackedEntityInstance trackedEntityInstance = trackedEntityInstances.get(0);
List<TrackedEntityAttributeValue> attributeValues = trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntityInstance);
assertEquals(5, attributeValues.size());
fileResource = fileResourceService.getFileResource(fileResource.getUid());
assertTrue(fileResource.isAssigned());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerBundleServiceTest method testTrackedEntityInstanceImport.
@Test
void testTrackedEntityInstanceImport() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/trackedentity_basic_data.json");
assertEquals(13, trackerImportParams.getTrackedEntities().size());
TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
List<TrackedEntityInstance> trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
assertEquals(13, trackedEntityInstances.size());
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerEventBundleServiceTest method testUpdateSingleEventData.
@Test
void testUpdateSingleEventData() throws IOException {
TrackerImportParams trackerImportParams = fromJson("tracker/event_events_and_enrollment.json");
trackerImportParams.setImportStrategy(TrackerImportStrategy.CREATE_AND_UPDATE);
TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
trackerBundleService.commit(trackerBundle);
assertEquals(8, programStageInstanceStore.getAll().size());
trackerBundle = trackerBundleService.create(TrackerImportParams.builder().events(trackerBundle.getEvents()).enrollments(trackerBundle.getEnrollments()).trackedEntities(trackerBundle.getTrackedEntities()).user(currentUserService.getCurrentUser()).build());
trackerBundleService.commit(trackerBundle);
assertEquals(8, programStageInstanceStore.getAll().size());
}
Aggregations