Search in sources :

Example 6 with TrackerEntityInstanceRequest

use of org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest in project dhis2-core by dhis2.

the class TrackedEntityInstanceStrategyHandlerImplTest method shouldCallAsyncTrackedEntityJsonAsyncStrategy.

@Test
void shouldCallAsyncTrackedEntityJsonAsyncStrategy() throws BadRequestException, IOException {
    when(trackedEntityInstanceService.getTrackedEntityInstancesJson(any())).thenReturn(trackedEntityInstanceList);
    TrackerEntityInstanceRequest trackerEntityInstanceRequest = TrackerEntityInstanceRequest.builder().mediaType(MediaType.APPLICATION_JSON_VALUE).importOptions(importOptions).jobConfiguration(jobConfiguration).inputStream(inputStream).build();
    trackedEntityInstanceAsyncStrategy.mergeOrDeleteTrackedEntityInstances(trackerEntityInstanceRequest);
    verify(trackedEntityInstanceService, times(1)).getTrackedEntityInstancesJson(inputStream);
    verify(taskExecutor, times(1)).executeTask(trackedEntitiesTaskArgumentCaptor.capture());
}
Also used : TrackerEntityInstanceRequest(org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest) Test(org.junit.jupiter.api.Test)

Example 7 with TrackerEntityInstanceRequest

use of org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest in project dhis2-core by dhis2.

the class TrackedEntityInstanceStrategyHandlerTest method shouldCallSyncTrackedEntitySyncStrategy.

@Test
void shouldCallSyncTrackedEntitySyncStrategy() throws BadRequestException, IOException {
    when(importOptions.isAsync()).thenReturn(false);
    TrackerEntityInstanceRequest trackerEntityInstanceRequest = TrackerEntityInstanceRequest.builder().mediaType(MediaType.APPLICATION_JSON).importOptions(importOptions).build();
    trackedEntityInstanceStrategyHandler.mergeOrDeleteTrackedEntityInstances(trackerEntityInstanceRequest);
    verify(trackedEntityInstanceAsyncStrategy, times(0)).mergeOrDeleteTrackedEntityInstances(any());
    verify(trackedEntityInstanceSyncStrategy, times(1)).mergeOrDeleteTrackedEntityInstances(any());
}
Also used : TrackerEntityInstanceRequest(org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest) Test(org.junit.jupiter.api.Test)

Example 8 with TrackerEntityInstanceRequest

use of org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest in project dhis2-core by dhis2.

the class TrackedEntityInstanceStrategyHandlerTest method shouldCallAsyncTrackedEntitySyncStrategy.

@Test
void shouldCallAsyncTrackedEntitySyncStrategy() throws BadRequestException, IOException {
    when(importOptions.isAsync()).thenReturn(true);
    TrackerEntityInstanceRequest trackerEntityInstanceRequest = TrackerEntityInstanceRequest.builder().mediaType(MediaType.APPLICATION_JSON).importOptions(importOptions).build();
    trackedEntityInstanceStrategyHandler.mergeOrDeleteTrackedEntityInstances(trackerEntityInstanceRequest);
    verify(trackedEntityInstanceAsyncStrategy, times(1)).mergeOrDeleteTrackedEntityInstances(any());
    verify(trackedEntityInstanceSyncStrategy, times(0)).mergeOrDeleteTrackedEntityInstances(any());
}
Also used : TrackerEntityInstanceRequest(org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest) Test(org.junit.jupiter.api.Test)

Aggregations

TrackerEntityInstanceRequest (org.hisp.dhis.webapi.strategy.old.tracker.imports.request.TrackerEntityInstanceRequest)8 Test (org.junit.jupiter.api.Test)7 InputStream (java.io.InputStream)1 ImportSummaries (org.hisp.dhis.dxf2.importsummary.ImportSummaries)1 ImportSummary (org.hisp.dhis.dxf2.importsummary.ImportSummary)1 JobConfiguration (org.hisp.dhis.scheduling.JobConfiguration)1