use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class RequestInfoControllerTest method testGetCurrentInfo_NoHeader.
@Test
void testGetCurrentInfo_NoHeader() {
JsonObject info = GET("/request").content();
assertTrue(info.isObject());
assertTrue(info.isEmpty());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class SmsGatewayControllerTest method testUpdateGateway.
@Test
void testUpdateGateway() {
uid = assertStatus(HttpStatus.OK, POST("/gateways", "{'name':'test', 'username':'user', 'password':'pwd', 'type':'http'}"));
JsonObject gateway = GET("/gateways/{uid}", uid).content();
assertWebMessage("OK", 200, "OK", "Gateway with uid: " + uid + " has been updated", PUT("/gateways/" + uid, gateway.toString()).content(HttpStatus.OK));
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_PresetExpandsToReadableFields.
@Test
void testField_PresetExpandsToReadableFields() {
switchToGuestUser();
JsonArray users = GET("/users/gist?headless=true").content();
JsonObject user0 = users.getObject(0);
assertContainsOnly(user0.node().members().keySet(), "id", "code", "surname", "firstName", "username");
switchToSuperuser();
users = GET("/users/gist?headless=true").content();
user0 = users.getObject(0);
assertTrue(user0.node().members().keySet().size() > 4);
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_Attribute.
@Test
void testField_Attribute() {
// setup a DE with custom attribute value
String attrId = assertStatus(HttpStatus.CREATED, POST("/attributes", "{" + "'name':'extra', " + "'valueType':'TEXT', " + "'" + ObjectType.DATA_ELEMENT.getPropertyName() + "':true}"));
String ccId = GET("/categoryCombos/gist?fields=id,categoryOptionCombos::ids&pageSize=1&headless=true&filter=name:eq:default").content().getObject(0).getString("id").string();
String deId = assertStatus(HttpStatus.CREATED, POST("/dataElements/", "{'name':'My data element', 'shortName':'DE1', 'code':'DE1', 'valueType':'INTEGER', " + "'aggregationType':'SUM', 'zeroIsSignificant':false, 'domainType':'AGGREGATE', " + "'categoryCombo': {'id': '" + ccId + "'}," + "'attributeValues':[{'attribute': {'id':'" + attrId + "'}, 'value':'extra-value'}]" + "}"));
// test single field
assertEquals("extra-value", GET("/dataElements/{de}/gist?fields={attr}", deId, attrId).content().string());
// test multiple fields also with an alias 'extra'
JsonObject dataElement = GET("/dataElements/{de}/gist?fields=id,name,{attr}::rename(extra)", deId, attrId).content();
assertEquals(deId, dataElement.getString("id").string());
assertEquals("My data element", dataElement.getString("name").string());
assertEquals("extra-value", dataElement.getString("extra").string());
// test in listing
JsonArray dataElements = GET("/dataElements/gist?fields=id,name,{attr}::rename(extra)&headless=true", attrId).content();
assertEquals(1, dataElements.size());
assertEquals("extra-value", dataElements.getObject(0).getString("extra").string());
}
use of org.hisp.dhis.jsontree.JsonObject in project dhis2-core by dhis2.
the class GistFieldsControllerTest method testField_Sharing_EmbedsObject.
@Test
void testField_Sharing_EmbedsObject() {
JsonObject groups = GET("/users/{uid}/userGroups/gist?fields=id,sharing,users&headless=true", getSuperuserUid()).content().getObject(0);
assertTrue(groups.has("id", "sharing"));
assertTrue(groups.getObject("sharing").has("owner", "external", "users", "userGroups", "public"));
}
Aggregations