use of org.alfresco.rest.api.tests.client.PublicApiClient.Sites in project alfresco-remote-api by Alfresco.
the class TestPersonSites method getSiteMembershipsForPersonAndNetwork.
/**
* Retrieves the site memberships associated to a user.
*
* @param paging
* The paging object
* @param params
* Public api parameters map.
* @param person
* The test person.
* @param network
* The test network.
* @return The site memberships associated to the give user.
* @throws Exception
*/
private ListResponse<MemberOfSite> getSiteMembershipsForPersonAndNetwork(final Paging paging, Map<String, String> params, TestPerson person, TestNetwork network, boolean runAsUserTenant) throws Exception {
final Sites sitesProxy = publicApiClient.sites();
publicApiClient.setRequestContext(new RequestContext(network.getId(), person.getId()));
ListResponse<MemberOfSite> resp;
if (runAsUserTenant) {
// get memberships
resp = TenantUtil.runAsUserTenant(new TenantRunAsWork<ListResponse<MemberOfSite>>() {
@Override
public ListResponse<MemberOfSite> doWork() throws Exception {
ListResponse<MemberOfSite> resp = sitesProxy.getPersonSites(person.getId(), createParams(paging, params));
return resp;
}
}, person.getId(), network.getId());
} else {
resp = sitesProxy.getPersonSites(person.getId(), createParams(paging, params));
}
return resp;
}
use of org.alfresco.rest.api.tests.client.PublicApiClient.Sites in project alfresco-remote-api by Alfresco.
the class TestSites method testGetSiteAndListSites.
@Test
public void testGetSiteAndListSites() throws Exception {
Sites sitesProxy = publicApiClient.sites();
// create & get sites (as person 2)
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2Id));
String siteTitle = "site 1 " + System.currentTimeMillis();
Site site = new SiteImpl(siteTitle, SiteVisibility.PRIVATE.toString());
site1 = sitesProxy.createSite(site);
Site ret = sitesProxy.getSite(site1.getSiteId());
site1.expected(ret);
siteTitle = "site 2 " + System.currentTimeMillis();
site = new SiteImpl(siteTitle, SiteVisibility.PUBLIC.toString());
site2 = sitesProxy.createSite(site);
ret = sitesProxy.getSite(site2.getSiteId());
site2.expected(ret);
siteTitle = "site 3 " + System.currentTimeMillis();
site = new SiteImpl(siteTitle, SiteVisibility.MODERATED.toString());
site3 = sitesProxy.createSite(site);
ret = sitesProxy.getSite(site3.getSiteId());
site3.expected(ret);
}
List<TestSite> expectedSites = TenantUtil.runAsUserTenant(new TenantRunAsWork<List<TestSite>>() {
@Override
public List<TestSite> doWork() throws Exception {
List<TestSite> sites = network1.getSites(person1Id);
return sites;
}
}, person1Id, network1.getId());
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
int skipCount = 0;
int maxItems = 2;
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
ListResponse<Site> resp = sitesProxy.getSites(createParams(paging, null));
checkList(expectedSites.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
int skipCount = 2;
int maxItems = Integer.MAX_VALUE;
Paging paging = getPaging(skipCount, maxItems, expectedSites.size(), expectedSites.size());
ListResponse<Site> resp = sitesProxy.getSites(createParams(paging, null));
checkList(expectedSites.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
}
Aggregations