Search in sources :

Example 81 with JsonObject

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

the class GistTransformControllerTest method testTransform_Ids.

@Test
void testTransform_Ids() {
    JsonObject gist = GET("/dataSets/{id}/organisationUnits/gist?fields=*,dataSets::ids", dataSetId).content();
    assertHasPager(gist, 1, 50);
    JsonObject orgUnit = gist.getArray("organisationUnits").getObject(0);
    assertEquals(dataSetId, orgUnit.getArray("dataSets").getString(0).string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 82 with JsonObject

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

the class GistTransformControllerTest method testTransform_Auto_MediumUsesSize.

@Test
void testTransform_Auto_MediumUsesSize() {
    JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users&auto=M", getSuperuserUid()).content();
    assertHasPager(gist, 1, 50);
    assertEquals(1, gist.getArray("userGroups").getObject(0).getNumber("users").intValue());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 83 with JsonObject

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

the class GistTransformControllerTest method testTransform_Auto_LargeUsesIds.

@Test
void testTransform_Auto_LargeUsesIds() {
    JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users&auto=L", getSuperuserUid()).content();
    assertHasPager(gist, 1, 50);
    assertEquals(getSuperuserUid(), gist.getArray("userGroups").getObject(0).getArray("users").getString(0).string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 84 with JsonObject

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

the class GistTransformControllerTest method testTransform_Rename.

@Test
void testTransform_Rename() {
    JsonObject user = GET("/users/{uid}/gist?fields=surname~rename(name),username~rename(alias)", getSuperuserUid()).content();
    assertEquals("admin", user.getString("name").string());
    assertEquals(2, user.size());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 85 with JsonObject

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

the class SystemSettingControllerTest method testGetSystemSettingOrTranslationAsJson.

@Test
void testGetSystemSettingOrTranslationAsJson() {
    assertStatus(HttpStatus.OK, POST("/systemSettings/keyUiLocale?value=de"));
    JsonObject setting = GET("/systemSettings/keyUiLocale").content(HttpStatus.OK);
    assertTrue(setting.isObject());
    assertEquals(1, setting.size());
    assertEquals("de", setting.getString("keyUiLocale").string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Aggregations

JsonObject (org.hisp.dhis.jsontree.JsonObject)106 Test (org.junit.jupiter.api.Test)92 DhisControllerConvenienceTest (org.hisp.dhis.webapi.DhisControllerConvenienceTest)51 JsonArray (org.hisp.dhis.jsontree.JsonArray)16 ProgramInstance (org.hisp.dhis.program.ProgramInstance)6 TrackedEntityInstance (org.hisp.dhis.trackedentity.TrackedEntityInstance)6 Relationship (org.hisp.dhis.relationship.Relationship)5 RelationshipType (org.hisp.dhis.relationship.RelationshipType)5 GeoJsonObject (org.geojson.GeoJsonObject)3 JsonString (org.hisp.dhis.jsontree.JsonString)3 HttpStatus (org.springframework.http.HttpStatus)3 ObjectType (org.hisp.dhis.attribute.Attribute.ObjectType)2 ProgramStageInstance (org.hisp.dhis.program.ProgramStageInstance)2 Arrays.stream (java.util.Arrays.stream)1 Date (java.util.Date)1 JsonResponse (org.hisp.dhis.jsontree.JsonResponse)1 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)1 Program (org.hisp.dhis.program.Program)1 ApiToken (org.hisp.dhis.security.apikey.ApiToken)1 SettingKey (org.hisp.dhis.setting.SettingKey)1