Search in sources :

Example 1 with TrackedEntityInstanceService

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();
}
Also used : AbstractTrackedEntityInstanceService(org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) User(org.hisp.dhis.user.User) TrackedEntityInstance(org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance) TrackedEntityType(org.hisp.dhis.trackedentity.TrackedEntityType) NotificationLevel(org.hisp.dhis.system.notification.NotificationLevel) ImportSummaries(org.hisp.dhis.dxf2.importsummary.ImportSummaries) JobConfiguration(org.hisp.dhis.scheduling.JobConfiguration) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with TrackedEntityInstanceService

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;
}
Also used : TrackedEntityInstance(org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance) ImportTrackedEntitiesTask(org.hisp.dhis.dxf2.events.trackedentity.ImportTrackedEntitiesTask)

Aggregations

TrackedEntityInstance (org.hisp.dhis.dxf2.events.trackedentity.TrackedEntityInstance)2 AbstractTrackedEntityInstanceService (org.hisp.dhis.dxf2.events.trackedentity.AbstractTrackedEntityInstanceService)1 ImportTrackedEntitiesTask (org.hisp.dhis.dxf2.events.trackedentity.ImportTrackedEntitiesTask)1 ImportSummaries (org.hisp.dhis.dxf2.importsummary.ImportSummaries)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)1 NotificationLevel (org.hisp.dhis.system.notification.NotificationLevel)1 TrackedEntityType (org.hisp.dhis.trackedentity.TrackedEntityType)1 User (org.hisp.dhis.user.User)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1