use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class UserControllerTest method testPutJsonObject_Pre38.
@Test
void testPutJsonObject_Pre38() {
JsonObject user = GET("/users/{uid}", peter.getUid()).content();
JsonImportSummary summary = PUT("/37/users/" + peter.getUid(), user.toString()).content(HttpStatus.OK).as(JsonImportSummary.class);
assertEquals("ImportReport", summary.getResponseType());
assertEquals("OK", summary.getStatus());
assertEquals(1, summary.getStats().getUpdated());
assertEquals(peter.getUid(), summary.getTypeReports().get(0).getObjectReports().get(0).getUid());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class SharingControllerTest method testGetSharing.
@Test
void testGetSharing() {
String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups", "{'name':'test'}"));
JsonObject sharing = GET("/sharing?type=userGroup&id=" + groupId).content(HttpStatus.OK);
JsonObject meta = sharing.getObject("meta");
assertTrue(meta.getBoolean("allowPublicAccess").booleanValue());
assertFalse(meta.getBoolean("allowExternalAccess").booleanValue());
JsonObject object = sharing.getObject("object");
assertEquals(groupId, object.getString("id").string());
assertEquals("test", object.getString("name").string());
assertEquals("test", object.getString("displayName").string());
assertEquals("rw------", object.getString("publicAccess").string());
assertFalse(object.getBoolean("externalAccess").booleanValue());
assertEquals("admin admin", object.getObject("user").getString("name").string());
assertEquals(0, object.getArray("userGroupAccesses").size());
assertEquals(0, object.getArray("userAccesses").size());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class SharingControllerTest method testSearchUserGroups.
@Test
void testSearchUserGroups() {
String groupId = assertStatus(HttpStatus.CREATED, POST("/userGroups", "{'name':'test'}"));
JsonObject matches = GET("/sharing/search?key=" + groupId).content(HttpStatus.OK);
assertTrue(matches.has("userGroups", "users"));
assertEquals(0, matches.getArray("userGroups").size());
assertEquals(0, matches.getArray("users").size());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class ProgramMessageControllerTest method testSaveMessages.
@Test
void testSaveMessages() {
JsonObject status = POST("/messages", "{'programMessages': []}").content(HttpStatus.OK);
assertTrue(status.isObject());
assertEquals(1, status.size());
JsonArray summaries = status.getArray("summaries");
assertTrue(summaries.isArray());
assertTrue(summaries.isEmpty());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class SchemaBasedControllerTest method testGistAPI.
private void testGistAPI(JsonSchema schema, String uid) {
if (IGNORED_GIST_ENDPOINTS.contains(schema.getName())) {
return;
}
String endpoint = schema.getRelativeApiEndpoint();
// test gist list of object for the schema
JsonObject gist = GET(endpoint + "/gist").content();
assertTrue(gist.getObject("pager").exists());
JsonArray list = gist.getArray(schema.getPlural());
assertFalse(list.isEmpty());
// only if there is only one we are sure its the one we created
if (list.size() == 1) {
assertEquals(uid, list.getObject(0).getString("id").string());
}
// test the single object gist as well
JsonObject object = GET(endpoint + "/" + uid + "/gist").content();
assertTrue(object.exists());
assertEquals(uid, object.getString("id").string());
}
Aggregations