Search in sources :

Example 41 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_Error_ValidationFailed.

@Test
void testDescribe_Error_ValidationFailed() {
    JsonObject description = GET("/users/gist?describe=true&fields=password", getSuperuserUid()).content();
    assertTrue(description.has("error", "unplanned", "planned", "status"));
    assertTrue(description.getObject("error").has("type", "message"));
    assertTrue(description.getObject("unplanned").has("fields", "filters", "orders"));
    assertEquals("validation-failed", description.getString("status").string());
    assertEquals("Property `password` is not readable.", description.getObject("error").getString("message").string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 42 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_ObjectCollectionList.

@Test
void testDescribe_ObjectCollectionList() {
    JsonObject description = GET("/users/{uid}/userGroups/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 43 with JsonObject

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

the class GistDescribeControllerTest method testDescribe_FetchParameters.

@Test
void testDescribe_FetchParameters() {
    JsonObject description = GET("/users/gist?describe=true&filter=surname:startsWith:Jo", getSuperuserUid()).content();
    assertBaseDescription(description);
    JsonObject hql = description.getObject("hql");
    assertTrue(hql.has("parameters"));
    JsonObject parameters = hql.getObject("parameters");
    assertTrue(parameters.isObject());
    assertEquals(1, parameters.size());
    // starts with is case-insensitive so both term and DB field are lowered
    assertEquals("jo%", parameters.getString("f_0").string());
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 44 with JsonObject

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

the class GistFilterControllerTest method testFilter_Gt_1toMany.

@Test
void testFilter_Gt_1toMany() {
    String fields = "id,username,twoFA";
    String filter = "created:gt:2021-01-01,userGroups:gt:0";
    JsonObject users = GET("/userGroups/{uid}/users/gist?fields={fields}&filter={filter}&headless=true", userGroupId, fields, filter).content().getObject(0);
    assertTrue(users.has("id"));
    assertTrue(users.has("username"));
    assertTrue(users.has("twoFA"));
}
Also used : JsonObject(org.hisp.dhis.jsontree.JsonObject) Test(org.junit.jupiter.api.Test)

Example 45 with JsonObject

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

the class GistFilterControllerTest method testFilter_In_Id.

@Test
void testFilter_In_Id() {
    createDataSetsForOrganisationUnit(10, orgUnitId, "plus");
    List<String> dsUids = GET("/dataSets/gist?fields=id&filter=name:in:[plus2,plus6]&headless=true").content().stringValues();
    assertEquals(2, dsUids.size());
    String url = "/organisationUnits/{id}/dataSets/gist?filter=id:in:[{ds}]&fields=name&order=name";
    JsonObject gist = GET(url, orgUnitId, String.join(",", dsUids)).content();
    assertEquals(asList("plus2", "plus6"), gist.getArray("dataSets").stringValues());
}
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