use of org.hisp.dhis.trackedentity.DefaultTrackedEntityInstanceService in project dhis2-core by dhis2.
the class TrackerCrudTest method shouldUpdateTrackedEntityWithUpdateStrategy.
@Test
void shouldUpdateTrackedEntityWithUpdateStrategy() {
List<TrackedEntityInstance> trackedEntityInstanceList = Collections.singletonList(trackedEntityInstance);
when(importOptions.getImportStrategy()).thenReturn(ImportStrategy.UPDATE);
ImportSummaries importSummaries = trackedEntityInstanceService.mergeOrDeleteTrackedEntityInstances(trackedEntityInstanceList, importOptions, jobConfiguration);
assertFalse(importSummaries.getImportSummaries().stream().anyMatch(is -> is.isStatus(ImportStatus.ERROR)));
verify(defaultTrackedEntityInstanceService, times(1)).getTrackedEntityInstance(trackedEntityInstanceUid, user);
verify(defaultTrackedEntityInstanceService, times(1)).updateTrackedEntityInstance(any());
}
use of org.hisp.dhis.trackedentity.DefaultTrackedEntityInstanceService in project dhis2-core by dhis2.
the class TrackerCrudTest method shouldDeleteTrackedEntityWithDeleteStrategy.
@Test
void shouldDeleteTrackedEntityWithDeleteStrategy() {
List<TrackedEntityInstance> trackedEntityInstanceList = Collections.singletonList(trackedEntityInstance);
when(defaultTrackedEntityInstanceService.trackedEntityInstanceExists(trackedEntityInstanceUid)).thenReturn(true);
when(importOptions.getImportStrategy()).thenReturn(ImportStrategy.DELETE);
ImportSummaries importSummaries = trackedEntityInstanceService.mergeOrDeleteTrackedEntityInstances(trackedEntityInstanceList, importOptions, jobConfiguration);
assertFalse(importSummaries.getImportSummaries().stream().anyMatch(is -> is.isStatus(ImportStatus.ERROR)));
verify(defaultTrackedEntityInstanceService, times(1)).deleteTrackedEntityInstance(any());
}
use of org.hisp.dhis.trackedentity.DefaultTrackedEntityInstanceService in project dhis2-core by dhis2.
the class TrackerCrudTest method shouldAddTrackedEntityWithCreateStrategy.
@Test
void shouldAddTrackedEntityWithCreateStrategy() {
List<TrackedEntityInstance> trackedEntityInstanceList = Collections.singletonList(trackedEntityInstance);
when(importOptions.getImportStrategy()).thenReturn(ImportStrategy.CREATE);
ImportSummaries importSummaries = trackedEntityInstanceService.mergeOrDeleteTrackedEntityInstances(trackedEntityInstanceList, importOptions, jobConfiguration);
assertFalse(importSummaries.getImportSummaries().stream().anyMatch(is -> is.isStatus(ImportStatus.ERROR)));
verify(defaultTrackedEntityInstanceService, times(1)).addTrackedEntityInstance(any());
}
Aggregations