Search in sources :

Example 1 with JsonString

use of org.hisp.dhis.jsontree.JsonString in project dhis2-core by dhis2.

the class GistFieldsControllerTest method testField_DisplayName_WithLocale.

@Test
void testField_DisplayName_WithLocale() {
    assertStatus(HttpStatus.NO_CONTENT, PUT("/organisationUnits/" + orgUnitId + "/translations", "{'translations': [" + "{'locale':'sv', 'property':'name', 'value':'enhet A'}, " + "{'locale':'de', 'property':'name', 'value':'Einheit A'}]}"));
    JsonString displayName = GET("/organisationUnits/{id}/gist?fields=displayName&locale=de&headless=true", orgUnitId).content();
    assertEquals("Einheit A", displayName.string());
    displayName = GET("/organisationUnits/{id}/gist?fields=displayName&locale=sv&headless=true", orgUnitId).content();
    assertEquals("enhet A", displayName.string());
}
Also used : JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Example 2 with JsonString

use of org.hisp.dhis.jsontree.JsonString in project dhis2-core by dhis2.

the class DataIntegrityReportControllerTest method testOrphanedOrganisationUnits.

@Test
void testOrphanedOrganisationUnits() {
    // should match:
    String ouId = addOrganisationUnit("OrphanedUnit");
    // should not match:
    String ouRootId = addOrganisationUnit("root");
    addOrganisationUnit("leaf", ouRootId);
    assertEquals(singletonList("OrphanedUnit:" + ouId), getDataIntegrityReport().getOrphanedOrganisationUnits().toList(JsonString::string));
}
Also used : JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Example 3 with JsonString

use of org.hisp.dhis.jsontree.JsonString in project dhis2-core by dhis2.

the class DataIntegrityReportControllerTest method testOrganisationUnitsViolatingExclusiveGroupSets.

@Test
void testOrganisationUnitsViolatingExclusiveGroupSets() {
    String ouIdA = addOrganisationUnit("A");
    String ouIdB = addOrganisationUnit("B");
    addOrganisationUnit("C");
    // all groups created are compulsory
    String groupA0Id = addOrganisationUnitGroup("A0", ouIdA);
    String groupB1Id = addOrganisationUnitGroup("B1", ouIdB);
    String groupB2Id = addOrganisationUnitGroup("B2", ouIdB);
    addOrganisationUnitGroupSet("K", groupA0Id);
    addOrganisationUnitGroupSet("X", groupB1Id, groupB2Id);
    assertEquals(singletonMap("B:" + ouIdB, asList("B1:" + groupB1Id, "B2:" + groupB2Id)), getDataIntegrityReport().getOrganisationUnitsViolatingExclusiveGroupSets().toMap(JsonString::string, String::compareTo));
}
Also used : JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Example 4 with JsonString

use of org.hisp.dhis.jsontree.JsonString in project dhis2-core by dhis2.

the class DataIntegrityReportControllerTest method testOrganisationUnitsWithCyclicReferences.

@Test
void testOrganisationUnitsWithCyclicReferences() {
    String ouIdA = addOrganisationUnit("A");
    String ouIdB = addOrganisationUnit("B", ouIdA);
    // create cyclic references (seemingly not possible via REST API)
    OrganisationUnit ouA = organisationUnitStore.getByUid(ouIdA);
    OrganisationUnit ouB = organisationUnitStore.getByUid(ouIdB);
    ouA.setParent(ouB);
    ouB.getChildren().add(ouA);
    organisationUnitStore.save(ouB);
    assertContainsOnly(getDataIntegrityReport().getOrganisationUnitsWithCyclicReferences().toList(JsonString::string), "A:" + ouIdA, "B:" + ouIdB);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Example 5 with JsonString

use of org.hisp.dhis.jsontree.JsonString in project dhis2-core by dhis2.

the class DataIntegrityReportControllerTest method testOrganisationUnitsWithoutGroups.

@Test
void testOrganisationUnitsWithoutGroups() {
    // should match:
    String ouId = addOrganisationUnit("noGroupSet");
    // should not match:
    addOrganisationUnitGroup("group", addOrganisationUnit("hasGroupSet"));
    assertEquals(singletonList("noGroupSet:" + ouId), getDataIntegrityReport().getOrganisationUnitsWithoutGroups().toList(JsonString::string));
}
Also used : JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Aggregations

JsonString (org.hisp.dhis.jsontree.JsonString)5 Test (org.junit.jupiter.api.Test)5 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1