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());
}
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());
}
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"));
}
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"));
}
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"));
}
Aggregations