Search in sources :

Example 16 with ExpectedPaging

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

the class GroupMember method parseGroupMembers.

public static ListResponse<GroupMember> parseGroupMembers(JSONObject jsonObject) {
    List<GroupMember> groupMembers = new ArrayList<>();
    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");
        groupMembers.add(parseGroupMember(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<GroupMember> resp = new ListResponse<>(paging, groupMembers);
    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 17 with ExpectedPaging

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

the class Favourite method parseFavourites.

public static ListResponse<Favourite> parseFavourites(JSONObject jsonObject) throws ParseException {
    List<Favourite> favourites = new ArrayList<Favourite>();
    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");
        favourites.add(Favourite.parseFavourite(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<Favourite>(paging, favourites);
}
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 18 with ExpectedPaging

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

the class SiteMembershipRequest method parseSiteMembershipRequests.

public static ListResponse<SiteMembershipRequest> parseSiteMembershipRequests(JSONObject jsonObject) throws ParseException {
    List<SiteMembershipRequest> siteMembershipRequests = new ArrayList<SiteMembershipRequest>();
    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");
        siteMembershipRequests.add(SiteMembershipRequest.parseSiteMembershipRequest(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<>(paging, siteMembershipRequests);
}
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 19 with ExpectedPaging

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

the class NodeRating method parseNodeRatings.

public static ListResponse<NodeRating> parseNodeRatings(String nodeId, JSONObject jsonObject) {
    List<NodeRating> nodeRatings = new ArrayList<NodeRating>();
    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");
        nodeRatings.add(NodeRating.parseNodeRating(nodeId, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<NodeRating> resp = new ListResponse<NodeRating>(paging, nodeRatings);
    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 20 with ExpectedPaging

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

the class Preference method parsePreferences.

public static ListResponse<Preference> parsePreferences(JSONObject jsonObject) {
    List<Preference> preferences = new ArrayList<Preference>();
    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");
        preferences.add(Preference.parsePreference(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<Preference> resp = new ListResponse<Preference>(paging, preferences);
    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)

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