Search in sources :

Example 51 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_Total.

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

Example 52 with JsonObject

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

the class InterpretationControllerTest method testPostComment.

@Test
void testPostComment() {
    assertWebMessage("Created", 201, "OK", "Commented created", POST("/interpretations/" + uid + "/comments", "text/plain:comment").content(HttpStatus.CREATED));
    JsonObject comments = GET("/interpretations/{uid}/comments", uid).content(HttpStatus.OK);
    assertEquals(1, comments.getArray("comments").size());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) DhisControllerConvenienceTest(org.hisp.dhis.webapi.DhisControllerConvenienceTest) Test(org.junit.jupiter.api.Test)

Example 53 with JsonObject

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

the class FollowupAnalysisControllerTest method assertFollowupValues.

private void assertFollowupValues(HttpResponse response, String... expectedComments) {
    JsonResponse body = response.content();
    JsonList<JsonFollowupValue> values = body.getList("followupValues", JsonFollowupValue.class);
    assertEquals(expectedComments.length, values.size());
    assertEquals(Arrays.stream(expectedComments).collect(toSet()), values.stream().map(JsonFollowupValue::getComment).collect(toSet()));
    JsonObject metadata = body.getObject("metadata");
    assertTrue(metadata.exists());
    assertEquals(asList("de", "coc", "ou", "startDate", "endDate", "maxResults"), metadata.names());
}
Also used : JsonFollowupValue(org.hisp.dhis.webapi.json.domain.JsonFollowupValue) JsonObject(org.hisp.dhis.jsontree.JsonObject) JsonResponse(org.hisp.dhis.jsontree.JsonResponse)

Example 54 with JsonObject

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

the class DimensionControllerTest method testGetDimensionsForDataSet.

@Test
void testGetDimensionsForDataSet() {
    String dsId = assertStatus(HttpStatus.CREATED, POST("/dataSets/", "{'name':'My data set', 'periodType':'Monthly', 'categoryCombo':{'id':'" + ccId + "'}}"));
    JsonObject response = GET("/dimensions/dataSet/{ds}", dsId).content();
    JsonArray dimensions = response.getArray("dimensions");
    assertEquals(1, dimensions.size());
    JsonObject gender = dimensions.getObject(0);
    assertEquals("Gender", gender.getString("name").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 55 with JsonObject

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

the class DomainJsonResponseTest method testErrorSummary_MessageOnly.

@Test
void testErrorSummary_MessageOnly() {
    JsonObject response = createJSON("{'message':'my message'}");
    assertEquals("my message", response.as(JsonError.class).summary());
}
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