Search in sources :

Example 76 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(Class<?> entityResource, PublicApiClient.Paging paging, Map<String, String> otherParams, int expectedStatus) throws Exception {
    HttpResponse response = publicApiClient.get(entityResource, null, null, otherParams);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 77 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(String url, String entityId, Map<String, String> params, int expectedStatus) throws Exception {
    HttpResponse response = publicApiClient.get(getScope(), url, entityId, null, null, params);
    checkStatus(expectedStatus, response.getStatusCode());
    return response;
}
Also used : HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 78 with HttpResponse

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

the class AbstractBaseApiTest method waitAndGetRendition.

protected Rendition waitAndGetRendition(String sourceNodeId, String renditionId, int maxRetry, long pauseTime) throws Exception {
    int retryCount = 0;
    while (retryCount < maxRetry) {
        try {
            HttpResponse response = getSingle(getNodeRenditionsUrl(sourceNodeId), renditionId, 200);
            Rendition rendition = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Rendition.class);
            assertNotNull(rendition);
            assertEquals(Rendition.RenditionStatus.CREATED, rendition.getStatus());
            return rendition;
        } catch (AssertionError ex) {
            // If the asynchronous create rendition action is not finished yet,
            // wait for 'PAUSE_TIME' and try again.
            retryCount++;
            System.out.println("waitAndGetRendition: " + retryCount);
            Thread.sleep(pauseTime);
        }
    }
    return null;
}
Also used : Rendition(org.alfresco.rest.api.tests.client.data.Rendition) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse)

Example 79 with HttpResponse

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

the class AbstractBaseApiTest method getRootNodeId.

// -root- (eg. Company Home for on-prem)
protected String getRootNodeId() throws Exception {
    HttpResponse response = getSingle(NodesEntityResource.class, Nodes.PATH_ROOT, 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 80 with HttpResponse

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

the class AbstractBaseApiTest method get.

public HttpResponse get(String url, Map<String, String> params, int expectedStatus) throws IOException {
    HttpResponse response = publicApiClient.get(url, 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