use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class TrackerRelationshipsExportControllerTest method assertNthRelationship.
private JsonObject assertNthRelationship(JsonObject body, Relationship r, int n) {
assertFalse(body.isEmpty());
JsonArray rels = body.getArray("instances");
assertFalse(rels.isEmpty());
assertTrue(rels.size() >= n);
JsonObject jsonRelationship = rels.get(n).as(JsonObject.class);
assertRelationship(jsonRelationship, r);
return jsonRelationship;
}
use of org.hisp.dhis.jsontree.JsonArray 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.JsonArray 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());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class SmsGatewayControllerTest method tearDown.
@AfterEach
void tearDown() {
JsonArray gateways = GET("/gateways").content().getArray("gateways");
for (JsonObject gateway : gateways.asList(JsonObject.class)) {
assertStatus(HttpStatus.OK, DELETE("/gateways/" + gateway.getString("uid").string()));
}
assertTrue(GET("/gateways").content().getArray("gateways").isEmpty());
}
Aggregations