Merged HEAD (5.2) to 5.2.N (5.2.1)

127528 jkaabimofrad: Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)
      125406 jvonka: RA-779 / RA-780: Sites API - initial commit for create site [default/functional Share site ;-)] & delete site


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@127638 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-06-03 13:59:39 +00:00
parent 0fe50bd9f0
commit bfa0404bab
15 changed files with 705 additions and 446 deletions

View File

@@ -1,4 +1,4 @@
/*
/*
* #%L
* Alfresco Remote API
* %%
@@ -9,20 +9,20 @@
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.api.tests;
import static org.junit.Assert.assertEquals;
@@ -42,7 +42,10 @@ import org.alfresco.rest.api.tests.client.PublicApiClient.Paging;
import org.alfresco.rest.api.tests.client.PublicApiClient.Sites;
import org.alfresco.rest.api.tests.client.PublicApiException;
import org.alfresco.rest.api.tests.client.RequestContext;
import org.alfresco.rest.api.tests.client.data.Comment;
import org.alfresco.rest.api.tests.client.data.Site;
import org.alfresco.rest.api.tests.client.data.SiteImpl;
import org.alfresco.rest.api.tests.client.data.SiteRole;
import org.alfresco.service.cmr.site.SiteVisibility;
import org.alfresco.util.GUID;
import org.apache.commons.httpclient.HttpStatus;
@@ -95,20 +98,7 @@ public class TestSites extends EnterpriseTestApi
{
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
// Test Case cloud-1963
// invalid methods
try
{
sitesProxy.create("sites", null, null, null, null, "Unable to POST to sites");
fail();
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
}
try
{
sitesProxy.create("sites", "site", null, null, null, "Unable to POST to a site");
@@ -118,26 +108,6 @@ public class TestSites extends EnterpriseTestApi
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
}
// try
// {
// sitesProxy.remove("sites", null, null, null, "Unable to DELETE sites");
// fail();
// }
// catch(PublicApiException e)
// {
// assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
// }
//
// try
// {
// sitesProxy.remove("sites", "site", null, null, "Unable to DELETE sites");
// fail();
// }
// catch(PublicApiException e)
// {
// assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
// }
try
{
@@ -148,15 +118,16 @@ public class TestSites extends EnterpriseTestApi
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
}
// -ve - try to delete unknown site
try
{
sitesProxy.remove("sites", "site", null, null, "Unable to DELETE sites");
sitesProxy.remove("sites", "dummy", null, null, "Unable to DELETE site - not found");
fail();
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
// invalid site
@@ -216,10 +187,40 @@ public class TestSites extends EnterpriseTestApi
ListResponse<Site> resp = sitesProxy.getSites(createParams(paging, null));
checkList(expectedSites.subList(skipCount, skipCount + paging.getExpectedPaging().getCount()), paging.getExpectedPaging(), resp);
}
{
String siteTitle = "my site 123";
Site site = new SiteImpl("my site 123", SiteVisibility.PRIVATE.toString());
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
Site ret = sitesProxy.createSite(site);
String siteId = siteTitle.replace(' ', '-');
Site siteExp = new SiteImpl(null, siteId, ret.getGuid(), siteTitle, null, SiteVisibility.PRIVATE.toString(), null, SiteRole.SiteManager);
siteExp.expected(ret);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
ret = sitesProxy.getSite(siteId);
siteExp.expected(ret);
sitesProxy.removeSite(siteId);
try
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
sitesProxy.getSite(siteId);
fail("");
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
}
// Test Case cloud-1478
// Test Case cloud-1479
// user invited to network and user invited to site
// user invited to network and user not invited to site
}
}