Search in sources :

Example 11 with ListResponse

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

the class AuditApp method parseAuditApps.

public static ListResponse<AuditApp> parseAuditApps(JSONObject jsonObject) {
    List<AuditApp> groups = 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");
        groups.add(parseAuditApp(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<AuditApp> resp = new ListResponse<AuditApp>(paging, groups);
    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 12 with ListResponse

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

the class Comment method parseComments.

public static ListResponse<Comment> parseComments(String nodeId, JSONObject jsonObject) {
    List<Comment> comments = new ArrayList<Comment>();
    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");
        comments.add(Comment.parseComment(nodeId, entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<Comment>(paging, comments);
}
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 13 with ListResponse

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

the class Activities method parseActivities.

public static ListResponse<Activity> parseActivities(JSONObject jsonObject) {
    List<Activity> activities = new ArrayList<Activity>();
    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");
        activities.add(Activity.parseActivity(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    return new ListResponse<Activity>(paging, activities);
}
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 14 with ListResponse

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

the class AuditEntry method parseAuditEntries.

public static ListResponse<AuditEntry> parseAuditEntries(JSONObject jsonObject) {
    List<AuditEntry> entries = 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");
        entries.add(parseAuditEntry(entry));
    }
    ExpectedPaging paging = ExpectedPaging.parsePagination(jsonList);
    ListResponse<AuditEntry> resp = new ListResponse<AuditEntry>(paging, entries);
    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 15 with ListResponse

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

the class SiteImpl method parseSites.

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

ListResponse (org.alfresco.rest.api.tests.client.PublicApiClient.ListResponse)41 ArrayList (java.util.ArrayList)30 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)22 JSONObject (org.json.simple.JSONObject)21 Test (org.junit.Test)21 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)20 ExpectedPaging (org.alfresco.rest.api.tests.client.PublicApiClient.ExpectedPaging)19 JSONArray (org.json.simple.JSONArray)19 Paging (org.alfresco.rest.api.tests.client.PublicApiClient.Paging)18 List (java.util.List)13 TestSite (org.alfresco.rest.api.tests.RepoService.TestSite)10 TenantRunAsWork (org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork)8 TestNetwork (org.alfresco.rest.api.tests.RepoService.TestNetwork)8 TestPerson (org.alfresco.rest.api.tests.RepoService.TestPerson)8 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Sites (org.alfresco.rest.api.tests.client.PublicApiClient.Sites)6 People (org.alfresco.rest.api.tests.client.PublicApiClient.People)5 NodeRef (org.alfresco.service.cmr.repository.NodeRef)5 ParseException (java.text.ParseException)4