Search in sources :

Example 36 with JsonObject

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

the class DataApprovalControllerTest method testGetApproval.

@Test
void testGetApproval() {
    JsonArray statuses = GET("/dataApprovals/status?ou={ou}&pe=202101&wf={wf}&ds={ds}", ouId, wfId, dsId).content(HttpStatus.OK).getArray("dataApprovalStateResponses");
    assertEquals(1, statuses.size());
    JsonObject status_t0 = statuses.getObject(0);
    assertEquals("UNAPPROVED_READY", status_t0.getString("state").string());
    JsonObject permissions = status_t0.getObject("permissions");
    assertFalse(permissions.getString("acceptedBy").exists());
    assertFalse(permissions.getString("acceptedAt").exists());
    // now create an approval (approve it)
    assertStatus(HttpStatus.NO_CONTENT, POST("/dataApprovals?ou={ou}&pe=202101&wf={wf}", ouId, wfId));
    JsonObject status_t1 = GET("/dataApprovals/status?ou={ou}&pe=202101&wf={wf}&ds={ds}", ouId, wfId, dsId).content(HttpStatus.OK).getArray("dataApprovalStateResponses").getObject(0);
    assertEquals("APPROVED_HERE", status_t1.getString("state").string());
    permissions = status_t1.getObject("permissions");
    assertFalse(permissions.getBoolean("mayReadAcceptedBy").exists());
    assertTrue(permissions.getString("acceptedAt").exists());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 37 with JsonObject

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

the class DataApprovalControllerTest method testGetMultipleApprovalPermissions_Multiple.

@Test
void testGetMultipleApprovalPermissions_Multiple() {
    JsonArray statuses = GET("/dataApprovals/multiple?ou={ou}&pe=202101&wf={wf}", ouId, wfId).content(HttpStatus.OK);
    assertEquals(1, statuses.size());
    JsonObject status = statuses.getObject(0);
    assertTrue(status.has("wf", "pe", "ou", "aoc"));
    assertEquals(ouId, status.getString("ou").string());
    assertEquals(wfId, status.getString("wf").string());
    assertEquals("202101", status.getString("pe").string());
}
Also used : JsonArray(org.hisp.dhis.jsontree.JsonArray) JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 38 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_ObjectList.

@Test
void testDescribe_ObjectList() {
    JsonObject description = GET("/users/gist?describe=true", getSuperuserUid()).content();
    assertBaseDescription(description);
    assertFalse(description.getObject("hql").has("count"));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 39 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_Object.

@Test
void testDescribe_Object() {
    JsonObject description = GET("/users/{uid}/gist?describe=true", getSuperuserUid()).content();
    assertBaseDescription(description);
    assertFalse(description.getObject("hql").has("count"));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 40 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_Authorisation_Guest.

@Test
void testDescribe_Authorisation_Guest() {
    switchToGuestUser();
    JsonObject description = GET("/users/{uid}/gist?describe=true", getSuperuserUid()).content();
    assertFalse(description.has("hql"));
}
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