Search in sources :

Example 11 with JsonObject

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

the class GistFieldsControllerTest method testField_Access.

@Test
void testField_Access() {
    JsonArray groups = GET("/users/{uid}/userGroups/gist?fields=id,access&headless=true", getSuperuserUid()).content();
    assertEquals(1, groups.size());
    JsonObject group = groups.getObject(0);
    JsonObject access = group.getObject("access");
    assertTrue(access.has("manage", "externalize", "write", "read", "update", "delete"));
    assertTrue(access.getBoolean("manage").booleanValue());
    assertTrue(access.getBoolean("externalize").booleanValue());
    assertTrue(access.getBoolean("write").booleanValue());
    assertTrue(access.getBoolean("read").booleanValue());
    assertTrue(access.getBoolean("update").booleanValue());
    assertTrue(access.getBoolean("delete").booleanValue());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 12 with JsonObject

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

the class GistFieldsControllerTest method testField_ApiEndpoints_AbsoluteURLs.

@Test
void testField_ApiEndpoints_AbsoluteURLs() {
    JsonObject groups = GET("/users/{uid}/userGroups/gist?fields=name,users&absoluteUrls=true", getSuperuserUid()).content();
    assertTrue(groups.getArray("userGroups").getObject(0).getObject("apiEndpoints").getString("users").string().startsWith("http://"));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 13 with JsonObject

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

the class GistFieldsControllerTest method testField_ApiEndpoints_ContainsOnlyNonEmpty.

@Test
void testField_ApiEndpoints_ContainsOnlyNonEmpty() {
    String noUsersGroupId = assertStatus(HttpStatus.CREATED, POST("/userGroups/", "{'name':'groupX', 'users':[]}"));
    JsonObject group = GET("/userGroups/{uid}/gist?fields=name,users", noUsersGroupId).content();
    assertFalse(group.getObject("apiEndpoints").getString("users").exists());
    group = GET("/userGroups/{uid}/gist?fields=name,users::size", noUsersGroupId).content();
    assertFalse(group.getObject("apiEndpoints").getString("users").exists());
    group = GET("/userGroups/{uid}/gist?fields=name,users", userGroupId).content();
    assertTrue(group.getObject("apiEndpoints").getString("users").exists());
    group = GET("/userGroups/{uid}/gist?fields=name,users::size", userGroupId).content();
    assertTrue(group.getObject("apiEndpoints").getString("users").exists());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) JsonString(org.hisp.dhis.jsontree.JsonString) Test(org.junit.jupiter.api.Test)

Example 14 with JsonObject

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

the class GistPagerControllerTest method testPager_Total_ResultBased.

@Test
void testPager_Total_ResultBased() {
    JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users&total=true", getSuperuserUid()).content();
    assertHasPager(gist, 1, 50, 1);
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 15 with JsonObject

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

the class GistPagerControllerTest method testPager_Total_CountQueryNonExistingPage.

@Test
void testPager_Total_CountQueryNonExistingPage() {
    JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=name,users&total=true&page=6", getSuperuserUid()).content();
    assertHasPager(gist, 6, 50, 1);
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) 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