Search in sources :

Example 96 with HttpResponse

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

the class AbstractBaseApiTest method getAll.

protected HttpResponse getAll(String url, PublicApiClient.Paging paging, Map<String, String> otherParams, int expectedStatus) throws Exception {
    Map<String, String> params = createParams(paging, otherParams);
    HttpResponse response = publicApiClient.get(getScope(), url, null, null, null, params);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) RestApiUtil.toJsonAsString(org.alfresco.rest.api.tests.util.RestApiUtil.toJsonAsString)

Example 97 with HttpResponse

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

the class AbstractBaseApiTest method createAndGetRendition.

protected Rendition createAndGetRendition(String sourceNodeId, String renditionId) throws Exception {
    Rendition renditionRequest = new Rendition();
    renditionRequest.setId(renditionId);
    int retryCount = 0;
    while (retryCount < MAX_RETRY) {
        try {
            HttpResponse res = post(getNodeRenditionsUrl(sourceNodeId), toJsonAsString(renditionRequest), 202);
            assertNull(res.getJsonResponse());
            break;
        } catch (AssertionError ex) {
            // If no transformer is currently available,
            // wait for 'PAUSE_TIME' and try again.
            retryCount++;
            System.out.println("waitAndGetRendition: " + retryCount);
            Thread.sleep(PAUSE_TIME);
        }
    }
    return waitAndGetRendition(sourceNodeId, renditionId);
}
Also used : Rendition(org.alfresco.rest.api.tests.client.data.Rendition) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 98 with HttpResponse

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

the class AbstractBaseApiTest method putBinary.

protected HttpResponse putBinary(String url, int version, BinaryPayload payload, String queryString, Map<String, String> params, int expectedStatus) throws Exception {
    if (queryString != null) {
        url += queryString;
    }
    HttpResponse response = publicApiClient.putBinary(getScope(), version, url, null, null, null, payload, params);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 99 with HttpResponse

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

the class AbstractBaseApiTest method getSharedNodeId.

// -shared- (eg. "Shared" folder for on-prem)
protected String getSharedNodeId() throws Exception {
    HttpResponse response = getSingle(NodesEntityResource.class, Nodes.PATH_SHARED, null, 200);
    Node node = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Node.class);
    return node.getId();
}
Also used : Node(org.alfresco.rest.api.tests.client.data.Node) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 100 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, Map<String, String> params, Map<String, String> headers, String apiName, String contentType, int expectedStatus) throws Exception {
    RequestBuilder requestBuilder = httpClient.new PostRequestBuilder().setBodyAsByteArray(body).setContentType(contentType).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)

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