use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_DisplayName.
@Test
void testField_DisplayName() {
JsonObject gist = GET("/users/{uid}/userGroups/gist?fields=displayName,id", getSuperuserUid()).content();
JsonArray groups = gist.getArray("userGroups");
assertEquals(1, groups.size());
JsonObject group = groups.getObject(0);
assertEquals(asList("displayName", "id"), group.names());
assertEquals("groupX", group.getString("displayName").string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_Remove_MinusSyntax.
@Test
void testField_Remove_MinusSyntax() {
JsonObject user = GET("/users/{uid}/gist?fields=*,-surname", getSuperuserUid()).content();
assertFalse(user.has("surname"));
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_Href.
/*
* Synthetic Fields
*/
@Test
void testField_Href() {
JsonArray users = GET("/users/gist?fields=id,href&headless=true", getSuperuserUid()).content();
JsonObject user0 = users.getObject(0);
assertTrue(user0.has("id", "href"));
assertEquals("/users/" + user0.getString("id").string() + "/gist", user0.getString("href").string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_Remove_BangSyntax.
@Test
void testField_Remove_BangSyntax() {
JsonObject user = GET("/users/{uid}/gist?fields=*,!surname", getSuperuserUid()).content();
assertFalse(user.has("surname"));
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistPagerControllerTest method testPager_Total_CountQuery.
@Test
void testPager_Total_CountQuery() {
// create some members we can count a total for
createDataSetsForOrganisationUnit(10, orgUnitId, "extra");
String url = "/organisationUnits/{id}/dataSets/gist?total=true&pageSize=3&order=name&filter=name:startsWith:extra";
JsonObject gist = GET(url, orgUnitId).content();
assertHasPager(gist, 1, 3, 10);
// now page 2
gist = GET(url + "&page=2", orgUnitId).content();
assertHasPager(gist, 2, 3, 10);
assertEquals("/organisationUnits/{id}/dataSets/gist?total=true&pageSize=3&order=name&filter=name:startsWith:extra&page=1".replace("{id}", orgUnitId), gist.getObject("pager").getString("prevPage").string());
assertEquals("/organisationUnits/{id}/dataSets/gist?total=true&pageSize=3&order=name&filter=name:startsWith:extra&page=3".replace("{id}", orgUnitId), gist.getObject("pager").getString("nextPage").string());
JsonArray dataSets = gist.getArray("dataSets");
assertEquals("extra3", dataSets.getObject(0).getString("name").string());
assertEquals("extra4", dataSets.getObject(1).getString("name").string());
assertEquals("extra5", dataSets.getObject(2).getString("name").string());
}
Aggregations