use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project records-management by Alfresco.
the class EmailMapKeysRestApiTest method testGetCapabilitiesAction.
/**
* Tests the REST API to get the list of email mapping keys
*
* @throws IOException
* @throws JSONException
*/
public void testGetCapabilitiesAction() throws IOException, JSONException {
// Send request
Response response = sendRequest(new GetRequest(GET_EMAIL_MAP_KEYS_URL), Status.STATUS_OK);
// Check the content from the response
String contentAsString = response.getContentAsString();
assertNotNull(contentAsString);
// Convert the response to json and check the data
JSONObject contentAsJson = new JSONObject(contentAsString);
JSONObject data = contentAsJson.getJSONObject("data");
assertNotNull(data);
// Get the email mapping keys and check them
JSONArray dataSets = data.getJSONArray("emailmapkeys");
assertNotNull(dataSets);
// Check the number of email mapping keys
assertTrue(dataSets.length() == 6);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project records-management by Alfresco.
the class EventRestApiTest method testGetEventTypes.
public void testGetEventTypes() throws Exception {
Response rsp = sendRequest(new GetRequest(GET_EVENTTYPES_URL), 200);
String rspContent = rsp.getContentAsString();
JSONObject obj = new JSONObject(rspContent);
JSONObject types = obj.getJSONObject("data");
assertNotNull(types);
JSONObject type = types.getJSONObject("rmEventType.simple");
assertNotNull(type);
assertEquals("rmEventType.simple", type.getString("eventTypeName"));
assertNotNull(type.getString("eventTypeDisplayLabel"));
System.out.println(rspContent);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project records-management by Alfresco.
the class EventRestApiTest method testGetRole.
public void testGetRole() throws Exception {
String eventName = GUID.generate();
eventService.addEvent(EVENT_TYPE, eventName, DISPLAY_LABEL);
try {
// Get the roles
Response rsp = sendRequest(new GetRequest(GET_EVENTS_URL + "/" + eventName), 200);
String rspContent = rsp.getContentAsString();
JSONObject obj = new JSONObject(rspContent);
JSONObject eventObj = obj.getJSONObject("data");
assertNotNull(eventObj);
assertEquals(eventName, eventObj.get(KEY_EVENT_NAME));
assertEquals(DISPLAY_LABEL, eventObj.get(KEY_EVENT_DISPLAY_LABEL));
assertEquals(EVENT_TYPE, eventObj.get(KEY_EVENT_TYPE));
// Bad requests
sendRequest(new GetRequest(GET_EVENTS_URL + "/cheese"), 404);
} finally {
// Clean up
eventService.removeEvent(eventName);
}
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class LoginTest method testMissingParameters.
/**
* Negative test - missing parameters
*/
public void testMissingParameters() throws Exception {
/**
* Login via get method missing pw
*/
String loginURL = "/api/login?u=" + USER_ONE;
sendRequest(new GetRequest(loginURL), Status.STATUS_BAD_REQUEST);
/**
* Login via get method missing u
*/
String login2URL = "/api/login?&pw=" + USER_ONE;
sendRequest(new GetRequest(login2URL), Status.STATUS_BAD_REQUEST);
}
use of org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest in project alfresco-remote-api by Alfresco.
the class ReadOnlyTransactionInGetRestApiTest method testGetSiteTags.
public void testGetSiteTags() throws Exception {
Response response = sendRequest(new GetRequest(URL_GET_SITE_TAGS), 200);
logResponse(response);
assertEquals(Status.STATUS_OK, response.getStatus());
}
Aggregations