use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class DataApprovalControllerTest method testGetApprovalByCategoryOptionCombos.
@Test
void testGetApprovalByCategoryOptionCombos() {
JsonArray statuses = GET("/dataApprovals/categoryOptionCombos?ou={ou}&pe=202101&wf={wf}", ouId, wfId).content(HttpStatus.OK);
assertTrue(statuses.isArray());
assertEquals(1, statuses.size());
}
use of org.hisp.dhis.jsontree.JsonArray 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.JsonArray 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.JsonArray 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());
}
use of org.hisp.dhis.jsontree.JsonArray in project dhis2-core by dhis2.
the class GistFilterControllerTest method testFilter_GroupsOR.
@Test
void testFilter_GroupsOR() {
createDataSetsForOrganisationUnit(5, orgUnitId, "alpha");
createDataSetsForOrganisationUnit(5, orgUnitId, "beta");
createDataSetsForOrganisationUnit(5, orgUnitId, "gamma");
// both filters in group 2 are combined OR because root junction is
// implicitly AND
String url = "/dataSets/gist?filter=1:name:endsWith:3&filter=2:name:like:alpha&filter=2:name:like:beta&headless=true&order=name";
JsonArray matches = GET(url).content();
assertEquals(2, matches.size());
assertEquals("alpha3", matches.getObject(0).getString("name").string());
assertEquals("beta3", matches.getObject(1).getString("name").string());
}
Aggregations