Search in sources :

Example 21 with ExpectedPaging

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

the class PersonNetwork method parseNetworkMembers.

public static ListResponse<PersonNetwork> parseNetworkMembers(JSONObject jsonObject) {
    List<PersonNetwork> networkMembers = new ArrayList<PersonNetwork>();
    JSONObject jsonList = (JSONObject) jsonObject.get("list");
    assertNotNull(jsonList);
    JSONArray jsonEntries = (JSONArray) jsonList.get("entries");
    assertNotNull(jsonEntries);
    for (int i = 0; i < jsonEntries.size(); i++) {
        JSONObject jsonEntry = (JSONObject) jsonEntries.get(i);
        JSONObject entry = (JSONObject) jsonEntry.get("entry");
        networkMembers.add(PersonNetwork.parseNetworkMember(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<PersonNetwork> resp = new ListResponse<PersonNetwork>(paging, networkMembers);
    return resp;
}
Also used : JSONObject(org.json.simple.JSONObject) ListResponse(org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)

Example 22 with ExpectedPaging

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

the class BasicSearchApiIntegrationTest method testQuery.

/**
 * Tests basic api for search
 */
@Test
public void testQuery() throws Exception {
    setRequestContext(user1);
    String f1Id = null;
    try {
        // As user 1 ...
        // Try to get nodes with search term 'king*' - assume clean repo (ie. none to start with)
        HttpResponse response = post(URL_SEARCH, json, null, null, SEARCH_API_NAME, 200);
        List<Node> nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(0, nodes.size());
        String myFolderNodeId = getMyNodeId();
        f1Id = createFolder(myFolderNodeId, "king").getId();
        response = post(URL_SEARCH, json, null, null, SEARCH_API_NAME, 200);
        ExpectedPaging paging = RestApiUtil.parsePaging(response.getJsonResponse());
        assertEquals(1, paging.getTotalItems().intValue());
        assertFalse(paging.getHasMoreItems());
        nodes = RestApiUtil.parseRestApiEntries(response.getJsonResponse(), Node.class);
        assertEquals(1, nodes.size());
        // Just happy if it doesn't error
        response = post(URL_SEARCH, SerializerTestHelper.JSON, null, null, SEARCH_API_NAME, 200);
    } finally {
        // some cleanup
        if (f1Id != null) {
            deleteNode(f1Id, true, 204);
        }
    }
}
Also used : Node(org.alfresco.rest.api.tests.client.data.Node) FolderNode(org.alfresco.rest.api.tests.client.data.FolderNode) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) ExpectedPaging(org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Aggregations

ExpectedPaging (org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)22 ListResponse (org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse)19 JSONArray (org.json.simple.JSONArray)19 JSONObject (org.json.simple.JSONObject)19 ArrayList (java.util.ArrayList)18 HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)3 Test (org.junit.Test)3 AbstractSingleNetworkSiteTest (org.alfresco.rest.AbstractSingleNetworkSiteTest)2 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)2 Node (org.alfresco.rest.api.tests.client.data.Node)2 File (java.io.File)1 HashMap (java.util.HashMap)1 ContentInfo (org.alfresco.rest.api.tests.client.data.ContentInfo)1 Document (org.alfresco.rest.api.tests.client.data.Document)1 FolderNode (org.alfresco.rest.api.tests.client.data.FolderNode)1 Rendition (org.alfresco.rest.api.tests.client.data.Rendition)1 MultiPartBuilder (org.alfresco.rest.api.tests.util.MultiPartBuilder)1 FileData (org.alfresco.rest.api.tests.util.MultiPartBuilder.FileData)1 MultiPartRequest (org.alfresco.rest.api.tests.util.MultiPartBuilder.MultiPartRequest)1 RestApiUtil.parsePaging (org.alfresco.rest.api.tests.util.RestApiUtil.parsePaging)1