use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService in project dhis2-core by dhis2.
the class TrackerCrudTest method setUp.
@BeforeEach
public void setUp() {
trackedEntityInstanceService = mock(AbstractTrackedEntityInstanceService.class, CALLS_REAL_METHODS);
when(importOptions.getUser()).thenReturn(user);
when(importOptions.getIdSchemes()).thenReturn(idSchemes);
when(idSchemes.getTrackedEntityIdScheme()).thenReturn(IdScheme.UID);
when(idSchemes.getOrgUnitIdScheme()).thenReturn(IdScheme.UID);
when(notifier.notify(any(JobConfiguration.class), any(NotificationLevel.class), anyString(), anyBoolean())).thenReturn(notifier);
when(notifier.notify(any(JobConfiguration.class), anyString())).thenReturn(notifier);
when(notifier.clear(any())).thenReturn(notifier);
when(defaultTrackedEntityInstanceService.getTrackedEntityInstance(trackedEntityInstanceUid, user)).thenReturn(new org.hisp.dhis.trackedentity.TrackedEntityInstance());
when(defaultTrackedEntityInstanceService.getTrackedEntityInstance(trackedEntityInstanceUid)).thenReturn(new org.hisp.dhis.trackedentity.TrackedEntityInstance());
when(defaultTrackedEntityInstanceService.getTrackedEntityInstancesUidsIncludingDeleted(anyList())).thenReturn(new ArrayList<>());
when(enrollmentService.deleteEnrollments(anyList(), any(), anyBoolean())).thenReturn(new ImportSummaries());
when(enrollmentService.updateEnrollments(anyList(), any(), anyBoolean())).thenReturn(new ImportSummaries());
when(enrollmentService.addEnrollments(anyList(), any(), any(), anyBoolean())).thenReturn(new ImportSummaries());
when(enrollmentService.addEnrollmentList(anyList(), any())).thenReturn(new ImportSummaries());
when(relationshipService.processRelationshipList(anyList(), any())).thenReturn(new ImportSummaries());
when(userService.getUser(anyString())).thenReturn(new User());
when(identifiableObjectManager.getObject(TrackedEntityType.class, IdScheme.UID, trackedEntityTypeUid)).thenReturn(new TrackedEntityType());
when(identifiableObjectManager.getObject(OrganisationUnit.class, IdScheme.UID, orgUnitUid)).thenReturn(new OrganisationUnit());
when(trackerAccessManager.canWrite(any(), any(org.hisp.dhis.trackedentity.TrackedEntityInstance.class))).thenReturn(new ArrayList<>());
when(trackedEntityInstance.getOrgUnit()).thenReturn(orgUnitUid);
when(trackedEntityInstance.getAttributes()).thenReturn(new ArrayList<>());
when(trackedEntityInstance.getTrackedEntityType()).thenReturn(trackedEntityTypeUid);
when(trackedEntityInstance.getTrackedEntityInstance()).thenReturn(trackedEntityInstanceUid);
setFieldInAbstractService();
}
use of org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstanceService in project dhis2-core by dhis2.
the class TrackedEntityInstanceAsyncStrategyImpl method mergeOrDeleteTrackedEntityInstances.
@Override
public ImportSummaries mergeOrDeleteTrackedEntityInstances(TrackerEntityInstanceRequest trackerEntityInstanceRequest) throws IOException, BadRequestException {
List<TrackedEntityInstance> trackedEntityInstanceList = getTrackedEntityInstancesListByMediaType(trackerEntityInstanceRequest.getMediaType(), trackerEntityInstanceRequest.getInputStream());
taskExecutor.executeTask(new ImportTrackedEntitiesTask(trackedEntityInstanceList, trackedEntityInstanceService, trackerEntityInstanceRequest.getImportOptions(), trackerEntityInstanceRequest.getJobConfiguration()));
return null;
}
Aggregations