use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatIdentifiersTest method testOrgUnitIdentifiers.
@Test
void testOrgUnitIdentifiers() {
List<Pair<String, TrackerIdentifier>> data = buildDataSet("PlKwabX2xRW", "COU1", "Country");
for (Pair<String, TrackerIdentifier> pair : data) {
Event event = new Event();
event.setOrgUnit(pair.getLeft());
TrackerImportParams params = buildParams(event, builder().orgUnitIdScheme(pair.getRight()).build());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertPreheatedObjectExists(preheat, OrganisationUnit.class, pair.getRight(), pair.getLeft());
}
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatIdentifiersTest method testCategoryOptionIdentifiers.
@Test
void testCategoryOptionIdentifiers() {
List<Pair<String, TrackerIdentifier>> data = buildDataSet("XXXrKDKCefk", "COA", "COAname");
for (Pair<String, TrackerIdentifier> pair : data) {
Event event = new Event();
event.setAttributeCategoryOptions(pair.getLeft());
TrackerImportParams params = buildParams(event, builder().categoryOptionIdScheme(pair.getRight()).build());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertPreheatedObjectExists(preheat, CategoryOption.class, pair.getRight(), pair.getLeft());
}
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatServiceTest method testPreheatEvents.
@Test
void testPreheatEvents() throws IOException {
setUpMetadata("tracker/event_metadata.json");
TrackerImportParams params = fromJson("tracker/event_events.json");
assertTrue(params.getTrackedEntities().isEmpty());
assertTrue(params.getEnrollments().isEmpty());
assertFalse(params.getEvents().isEmpty());
TrackerPreheat preheat = trackerPreheatService.preheat(params);
assertNotNull(preheat);
assertNotNull(preheat.getMap());
assertNotNull(preheat.getMap().get(DataElement.class));
assertNotNull(preheat.getMap().get(OrganisationUnit.class));
assertNotNull(preheat.getMap().get(ProgramStage.class));
assertNotNull(preheat.getMap().get(CategoryOptionCombo.class));
assertNotNull(preheat.get(CategoryOptionCombo.class, "XXXvX50cXC0"));
assertNotNull(preheat.get(CategoryOption.class, "XXXrKDKCefk"));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatServiceTest method testCollectIdentifiersEvents.
@Test
void testCollectIdentifiersEvents() throws IOException {
TrackerImportParams params = fromJson("tracker/event_events.json");
assertTrue(params.getTrackedEntities().isEmpty());
assertTrue(params.getEnrollments().isEmpty());
assertFalse(params.getEvents().isEmpty());
Map<Class<?>, Set<String>> collectedMap = identifierCollector.collect(params, Maps.newHashMap());
assertTrue(collectedMap.containsKey(DataElement.class));
assertTrue(collectedMap.containsKey(ProgramStage.class));
assertTrue(collectedMap.containsKey(OrganisationUnit.class));
assertTrue(collectedMap.containsKey(CategoryOptionCombo.class));
assertTrue(collectedMap.containsKey(CategoryOption.class));
Set<String> dataElements = collectedMap.get(DataElement.class);
assertTrue(dataElements.contains("DSKTW8qFP0z"));
assertTrue(dataElements.contains("VD2olWcRozZ"));
assertTrue(dataElements.contains("WS3e6pInnuA"));
assertTrue(dataElements.contains("h7hXjNVMiRl"));
assertTrue(dataElements.contains("KCLriKKezWO"));
assertTrue(dataElements.contains("A8qxpcalLtf"));
assertTrue(dataElements.contains("zal5vkVEpV0"));
assertTrue(dataElements.contains("kAfSfT69m0E"));
assertTrue(dataElements.contains("wIUShyK7lIa"));
assertTrue(dataElements.contains("ICfA0klVxkd"));
assertTrue(dataElements.contains("xaPkxL28aPx"));
assertTrue(dataElements.contains("Kvm949EFjjv"));
assertTrue(dataElements.contains("xaQ4gqDYGL9"));
assertTrue(dataElements.contains("MqGMwzt7M7w"));
assertTrue(dataElements.contains("WdTLfnn4S1I"));
assertTrue(dataElements.contains("hxUvZqnmBDv"));
assertTrue(dataElements.contains("JXF90RhgNiI"));
assertTrue(dataElements.contains("gfEoDU4GtXK"));
assertTrue(dataElements.contains("qw67QlOlzdp"));
Set<String> categoryCombos = collectedMap.get(CategoryOptionCombo.class);
assertTrue(categoryCombos.contains("HllvX50cXC0"));
Set<String> categoryOptions = collectedMap.get(CategoryOption.class);
assertTrue(categoryOptions.contains("xYerKDKCefk"));
}
use of org.hisp.dhis.tracker.TrackerImportParams in project dhis2-core by dhis2.
the class TrackerPreheatServiceTest method testCollectIdentifiersAttributeValues.
@Test
void testCollectIdentifiersAttributeValues() {
TrackerImportParams params = TrackerImportParams.builder().identifiers(TrackerIdentifierParams.builder().idScheme(TrackerIdentifier.builder().idScheme(TrackerIdScheme.ATTRIBUTE).value("ATTR1234567").build()).build()).trackedEntities(Lists.newArrayList(TrackedEntity.builder().trackedEntity("TEI12345678").orgUnit("OU123456789").build())).build();
assertFalse(params.getTrackedEntities().isEmpty());
assertTrue(params.getEnrollments().isEmpty());
assertTrue(params.getEvents().isEmpty());
Map<Class<?>, Set<String>> collectedMap = identifierCollector.collect(params, Maps.newHashMap());
assertTrue(collectedMap.containsKey(TrackedEntity.class));
Set<String> trackedEntities = collectedMap.get(TrackedEntity.class);
assertTrue(collectedMap.containsKey(OrganisationUnit.class));
Set<String> organisationUnits = collectedMap.get(OrganisationUnit.class);
assertTrue(organisationUnits.contains("OU123456789"));
assertEquals(1, organisationUnits.size());
assertTrue(trackedEntities.contains("TEI12345678"));
assertEquals(1, trackedEntities.size());
}
Aggregations