use of org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest in project records-management by Alfresco.
the class RoleRestApiTest method testPutRole.
public void testPutRole() throws Exception {
String role1 = GUID.generate();
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
try {
Set<Capability> caps = getListOfCapabilities(4, 8);
JSONArray arrCaps = new JSONArray();
for (Capability cap : caps) {
System.out.println(cap.getName());
arrCaps.put(cap.getName());
}
JSONObject obj = new JSONObject();
obj.put("name", role1);
obj.put("displayLabel", "Changed");
obj.put("capabilities", arrCaps);
// Get the roles
Response rsp = sendRequest(new PutRequest(getRolesUrlBySite() + "/" + role1, obj.toString(), APPLICATION_JSON), 200);
String rspContent = rsp.getContentAsString();
JSONObject result = new JSONObject(rspContent);
JSONObject roleObj = result.getJSONObject("data");
assertNotNull(roleObj);
assertNotNull(roleObj);
assertEquals(role1, roleObj.get("name"));
assertEquals("Changed", roleObj.get("displayLabel"));
checkCapabilities(roleObj, 4);
// Bad requests
sendRequest(new PutRequest(getRolesUrlBySite() + "/cheese", obj.toString(), APPLICATION_JSON), 404);
} finally {
// Clean up
filePlanRoleService.deleteRole(filePlan, role1);
}
}
Aggregations