Search in sources :

Example 91 with HttpResponse

use of org.alfresco.rest.api.tests.client.HttpResponse in project alfresco-remote-api by Alfresco.

the class AbstractBaseApiTest method updateTextFile.

protected Document updateTextFile(String contentId, String textContent, Map<String, String> params, int expectedStatus) throws Exception {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(textContent.getBytes());
    File txtFile = TempFileProvider.createTempFile(inputStream, getClass().getSimpleName(), ".txt");
    BinaryPayload payload = new BinaryPayload(txtFile);
    HttpResponse response = putBinary(getNodeContentUrl(contentId), payload, null, params, expectedStatus);
    if (expectedStatus != 200) {
        return null;
    }
    return RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
}
Also used : BinaryPayload(org.alfresco.rest.api.tests.client.PublicApiHttpClient.BinaryPayload) ByteArrayInputStream(java.io.ByteArrayInputStream) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) File(java.io.File)

Example 92 with HttpResponse

use of org.alfresco.rest.api.tests.client.HttpResponse in project alfresco-remote-api by Alfresco.

the class AbstractBaseApiTest method post.

protected HttpResponse post(String url, String body, Map<String, String> params, Map<String, String> headers, String apiName, int expectedStatus) throws Exception {
    RequestBuilder requestBuilder = httpClient.new PostRequestBuilder().setBodyAsString(body).setRequestContext(publicApiClient.getRequestContext()).setScope(getScope()).setApiName(apiName).setEntityCollectionName(url).setHeaders(headers).setParams(params);
    HttpResponse response = publicApiClient.execute(requestBuilder);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : RequestBuilder(org.alfresco.rest.api.tests.client.PublicApiHttpClient.RequestBuilder) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 93 with HttpResponse

use of org.alfresco.rest.api.tests.client.HttpResponse in project alfresco-remote-api by Alfresco.

the class AbstractBaseApiTest method post.

protected HttpResponse post(String url, String body, String queryString, int expectedStatus) throws Exception {
    if (queryString != null) {
        url += queryString;
    }
    HttpResponse response = publicApiClient.post(getScope(), url, null, null, null, body);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 94 with HttpResponse

use of org.alfresco.rest.api.tests.client.HttpResponse in project alfresco-remote-api by Alfresco.

the class AbstractBaseApiTest method post.

protected HttpResponse post(String url, byte[] body, String queryString, String contentType, int expectedStatus) throws Exception {
    if (queryString != null) {
        url += queryString;
    }
    HttpResponse response = publicApiClient.post(getScope(), url, null, null, null, body, contentType);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 95 with HttpResponse

use of org.alfresco.rest.api.tests.client.HttpResponse in project alfresco-remote-api by Alfresco.

the class AbstractBaseApiTest method getSingle.

protected HttpResponse getSingle(Class<?> entityResource, String entityId, Map<String, String> params, int expectedStatus) throws Exception {
    HttpResponse response = publicApiClient.get(entityResource, entityId, null, params);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Aggregations

HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)162 Test (org.junit.Test)114 HashMap (java.util.HashMap)59 AbstractSingleNetworkSiteTest (org.alfresco.rest.AbstractSingleNetworkSiteTest)50 Document (org.alfresco.rest.api.tests.client.data.Document)49 Node (org.alfresco.rest.api.tests.client.data.Node)49 LinkedHashMap (java.util.LinkedHashMap)31 ArrayList (java.util.ArrayList)29 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)27 Folder (org.alfresco.rest.api.tests.client.data.Folder)26 File (java.io.File)25 NodesEntityResource (org.alfresco.rest.api.nodes.NodesEntityResource)25 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)22 CustomModel (org.alfresco.rest.api.model.CustomModel)16 ContentInfo (org.alfresco.rest.api.tests.client.data.ContentInfo)15 MultiPartBuilder (org.alfresco.rest.api.tests.util.MultiPartBuilder)15 JSONObject (org.json.simple.JSONObject)15 NodeRef (org.alfresco.service.cmr.repository.NodeRef)14 Map (java.util.Map)13 CustomAspect (org.alfresco.rest.api.model.CustomAspect)13