Search in sources :

Example 16 with TrackerImportParams

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());
    }
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerIdentifier(org.hisp.dhis.tracker.TrackerIdentifier) Event(org.hisp.dhis.tracker.domain.Event) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 17 with TrackerImportParams

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());
    }
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackerIdentifier(org.hisp.dhis.tracker.TrackerIdentifier) Event(org.hisp.dhis.tracker.domain.Event) ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 18 with TrackerImportParams

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"));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) CategoryOption(org.hisp.dhis.category.CategoryOption) ProgramStage(org.hisp.dhis.program.ProgramStage) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 19 with TrackerImportParams

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"));
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) DataElement(org.hisp.dhis.dataelement.DataElement) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Set(java.util.Set) CategoryOption(org.hisp.dhis.category.CategoryOption) ProgramStage(org.hisp.dhis.program.ProgramStage) CategoryOptionCombo(org.hisp.dhis.category.CategoryOptionCombo) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Example 20 with TrackerImportParams

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());
}
Also used : TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Set(java.util.Set) TrackedEntity(org.hisp.dhis.tracker.domain.TrackedEntity) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Aggregations

TrackerImportParams (org.hisp.dhis.tracker.TrackerImportParams)163 Test (org.junit.jupiter.api.Test)142 TrackerImportReport (org.hisp.dhis.tracker.report.TrackerImportReport)105 TrackerTest (org.hisp.dhis.tracker.TrackerTest)46 User (org.hisp.dhis.user.User)26 ClassPathResource (org.springframework.core.io.ClassPathResource)23 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)21 TransactionalIntegrationTest (org.hisp.dhis.TransactionalIntegrationTest)17 InputStream (java.io.InputStream)16 TrackedEntityAttributeValue (org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue)11 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)10 List (java.util.List)9 TrackerPreheat (org.hisp.dhis.tracker.preheat.TrackerPreheat)9 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)8 Event (org.hisp.dhis.tracker.domain.Event)7 Pair (org.apache.commons.lang3.tuple.Pair)6 ProgramInstance (org.hisp.dhis.program.ProgramInstance)6 TrackedEntityAttribute (org.hisp.dhis.trackedentity.TrackedEntityAttribute)6 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)5 Program (org.hisp.dhis.program.Program)5