Search in sources :

Example 81 with GetRequest

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);
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest) JSONArray(org.json.JSONArray)

Example 82 with GetRequest

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);
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 83 with GetRequest

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);
    }
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) JSONObject(org.json.JSONObject) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 84 with GetRequest

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);
}
Also used : GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Example 85 with GetRequest

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());
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) GetRequest(org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)

Aggregations

GetRequest (org.springframework.extensions.webscripts.TestWebScriptServer.GetRequest)182 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)171 JSONObject (org.json.JSONObject)141 JSONArray (org.json.JSONArray)89 PostRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PostRequest)25 HashMap (java.util.HashMap)23 JSONTokener (org.json.JSONTokener)23 DeleteRequest (org.springframework.extensions.webscripts.TestWebScriptServer.DeleteRequest)21 PutRequest (org.springframework.extensions.webscripts.TestWebScriptServer.PutRequest)17 NodeRef (org.alfresco.service.cmr.repository.NodeRef)14 Serializable (java.io.Serializable)13 WorkflowDefinition (org.alfresco.service.cmr.workflow.WorkflowDefinition)13 QName (org.alfresco.service.namespace.QName)13 ArrayList (java.util.ArrayList)12 WorkflowPath (org.alfresco.service.cmr.workflow.WorkflowPath)12 Date (java.util.Date)11 WorkflowTask (org.alfresco.service.cmr.workflow.WorkflowTask)11 JSONStringer (org.json.JSONStringer)7 Calendar (java.util.Calendar)6 UserTransaction (javax.transaction.UserTransaction)6