use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class TrackedEntityInstanceServiceTest method testAddAlreadyDeletedTeiInBulk.
@Test
void testAddAlreadyDeletedTeiInBulk() {
ImportOptions importOptions = new ImportOptions();
trackedEntityInstanceService.addTrackedEntityInstance(teiMaleA, importOptions);
trackedEntityInstanceService.deleteTrackedEntityInstance(teiMaleA.getTrackedEntityInstance());
manager.flush();
importOptions.setImportStrategy(ImportStrategy.CREATE);
teiMaleA.setDeleted(true);
teiMaleB.setTrackedEntityInstance("teiUid00002");
teiFemaleA.setTrackedEntityInstance("teiUid00003");
List<TrackedEntityInstance> teis = new ArrayList<>();
teis.add(teiMaleA);
teis.add(teiMaleB);
teis.add(teiFemaleA);
ImportSummaries importSummaries = trackedEntityInstanceService.addTrackedEntityInstances(teis, importOptions);
assertEquals(ImportStatus.ERROR, importSummaries.getStatus());
assertEquals(1, importSummaries.getIgnored());
assertEquals(2, importSummaries.getImported());
assertTrue(importSummaries.getImportSummaries().stream().anyMatch(is -> is.getDescription().contains("already exists or was deleted earlier")));
manager.flush();
List<String> uids = new ArrayList<>();
uids.add(teiMaleA.getTrackedEntityInstance());
uids.add(teiMaleB.getTrackedEntityInstance());
uids.add(teiFemaleA.getTrackedEntityInstance());
List<String> fetchedUids = teiDaoService.getTrackedEntityInstancesUidsIncludingDeleted(uids);
assertTrue(Sets.difference(new HashSet<>(uids), new HashSet<>(fetchedUids)).isEmpty());
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportReverseDeletedValuesXml.
/**
* Import 12 data values where 4 are marked as deleted. Then import 12 data
* values which reverse deletion of the 4 values and update the other 8
* values.
*/
@Test
void testImportReverseDeletedValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetBDeleted.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(12, summary.getImportCount().getImported());
assertDataValuesCount(8);
// Reverse deletion and update
in = readFile("datavalueset/dataValueSetB.xml");
summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(4, 8, 0, summary);
assertDataValuesCount(12);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testDeleteValuesXml.
/**
* Import 12 data values. Then import 12 values where 4 are marked as
* deleted.
*/
@Test
void testDeleteValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetB.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertEquals(12, summary.getImportCount().getImported());
assertDataValuesCount(12);
// Delete 4 values
in = readFile("datavalueset/dataValueSetBDeleted.xml");
summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(0, 8, 4, summary);
assertDataValuesCount(8);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class DataValueSetServiceIntegrationTest method testImportDeletedValuesXml.
/**
* Import 12 data values where 4 are marked as deleted. Deleted values
* should count as imports when there are no existing non-deleted matching
* values.
*/
@Test
void testImportDeletedValuesXml() {
assertDataValuesCount(0);
in = readFile("datavalueset/dataValueSetBDeleted.xml");
ImportSummary summary = dataValueSetService.importDataValueSetXml(in);
assertSuccessWithImportedUpdatedDeleted(12, 0, 0, summary);
assertDataValuesCount(8);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.DELETED in project dhis2-core by dhis2.
the class ProgramStageInstanceSupplierTest method verifySupplier.
@Test
void verifySupplier() throws SQLException {
// mock resultset data
when(mockResultSet.getLong("programstageinstanceid")).thenReturn(100L);
when(mockResultSet.getString("uid")).thenReturn("abcded");
when(mockResultSet.getString("status")).thenReturn("ACTIVE");
when(mockResultSet.getBoolean("deleted")).thenReturn(false);
// create event to import
Event event = new Event();
event.setUid(CodeGenerator.generateUid());
event.setEnrollment("abcded");
// mock resultset extraction
mockResultSetExtractor(mockResultSet);
Map<String, ProgramStageInstance> map = subject.get(ImportOptions.getDefaultImportOptions(), Collections.singletonList(event));
ProgramStageInstance programStageInstance = map.get("abcded");
assertThat(programStageInstance, is(notNullValue()));
assertThat(programStageInstance.getId(), is(100L));
assertThat(programStageInstance.getUid(), is("abcded"));
assertThat(programStageInstance.getStatus(), is(EventStatus.ACTIVE));
assertThat(programStageInstance.isDeleted(), is(false));
}
Aggregations