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