use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project records-management by Alfresco.
the class DispositionRestApiTest method testDeleteDispositionAction.
public void testDeleteDispositionAction() throws Exception {
NodeRef newRecordCategory = filePlanService.createRecordCategory(recordSeries, GUID.generate());
dispositionService.createDispositionSchedule(newRecordCategory, null);
// create an action definition to then delete
String categoryNodeUrl = newRecordCategory.toString().replace("://", "/");
String postRequestUrl = MessageFormat.format(POST_ACTIONDEF_URL_FORMAT, categoryNodeUrl);
JSONObject jsonPostData = new JSONObject();
jsonPostData.put("name", "cutoff");
String jsonPostString = jsonPostData.toString();
sendRequest(new PostRequest(postRequestUrl, jsonPostString, APPLICATION_JSON), 200);
// verify the action definition is present and retrieve it's id
String getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
Response rsp = sendRequest(new GetRequest(getRequestUrl), 200);
JSONObject json = new JSONObject(new JSONTokener(rsp.getContentAsString()));
String actionDefId = json.getJSONObject("data").getJSONArray("actions").getJSONObject(0).getString("id");
// try and delete a non existent action definition to check for 404
String deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, "xyz");
rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 404);
// now delete the action defintion created above
deleteRequestUrl = MessageFormat.format(DELETE_ACTIONDEF_URL_FORMAT, categoryNodeUrl, actionDefId);
rsp = sendRequest(new DeleteRequest(deleteRequestUrl), 200);
// verify it got deleted
getRequestUrl = MessageFormat.format(GET_SCHEDULE_URL_FORMAT, categoryNodeUrl);
rsp = sendRequest(new GetRequest(getRequestUrl), 200);
json = new JSONObject(new JSONTokener(rsp.getContentAsString()));
JSONArray actions = json.getJSONObject("data").getJSONArray("actions");
assertEquals(0, actions.length());
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project records-management by Alfresco.
the class EmailMapScriptTest method testEmailMap.
/**
* Tests the REST APIs for a custom mapping
*
* @throws IOException
* @throws JSONException
*/
public void testEmailMap() throws IOException, JSONException {
/**
* Test GET
*/
Response getResponse = sendRequest(new GetRequest(URL_RM_EMAILMAP), Status.STATUS_OK);
JSONObject getResponseContent = new JSONObject(getResponse.getContentAsString());
JSONObject getData = getResponseContent.getJSONObject("data");
JSONArray getMappings = getData.getJSONArray("mappings");
assertTrue(getMappings.length() == 20);
/**
* Test POST
*/
JSONObject newMapping = new JSONObject();
newMapping.put("from", "messageTo");
newMapping.put("to", "rmc:Wibble");
Response postResponse = sendRequest(new PostRequest(URL_RM_EMAILMAP, newMapping.toString(), APPLICATION_JSON), Status.STATUS_OK);
JSONObject postResponseContent = new JSONObject(postResponse.getContentAsString());
JSONObject postData = postResponseContent.getJSONObject("data");
JSONArray postMappings = postData.getJSONArray("mappings");
assertTrue(postMappings.length() == 21);
assertTrue(existsMapping(postMappings));
/**
* Test DELETE
*/
Response deleteResponse = sendRequest(new DeleteRequest(String.format(URL_RM_EMAILMAP_DELETE, "messageTo", "rmc:Wibble")), Status.STATUS_OK);
JSONObject deleteResponseContent = new JSONObject(deleteResponse.getContentAsString());
JSONObject deleteData = deleteResponseContent.getJSONObject("data");
JSONArray deleteMappings = deleteData.getJSONArray("mappings");
assertTrue(deleteMappings.length() == 20);
assertFalse(existsMapping(deleteMappings));
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest in project records-management by Alfresco.
the class RoleRestApiTest method testDeleteRole.
public void testDeleteRole() throws Exception {
String role1 = GUID.generate();
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
filePlanRoleService.createRole(filePlan, role1, "My Test Role", getListOfCapabilities(5));
assertTrue(filePlanRoleService.existsRole(filePlan, role1));
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/" + role1), 200);
assertFalse(filePlanRoleService.existsRole(filePlan, role1));
// Bad request
sendRequest(new DeleteRequest(getRolesUrlBySite() + "/cheese"), 404);
}
Aggregations