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

130871 jvonka: REPO-1027: V1 REST API - fix error handling (add site member)
   - fix error code (should be 400 not 500) & add -ve api tests
   - ACE-5458


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132196 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:28:23 +00:00
parent 5e3d908af7
commit 6a5f88763f
5 changed files with 92 additions and 66 deletions

View File

@@ -61,6 +61,7 @@ import org.junit.Test;
public class TestSiteMembers extends EnterpriseTestApi
{
// TODO set create member for a user who is a member of the site (not the creator)
// TODO split into more manageable test methods
@Test
public void testSiteMembers() throws Exception
{
@@ -382,6 +383,30 @@ public class TestSiteMembers extends EnterpriseTestApi
{
assertEquals(e.getMessage(), HttpStatus.SC_NOT_FOUND, e.getHttpResponse().getStatusCode());
}
// missing person id
try
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2.getId()));
sitesProxy.createSiteMember(site.getSiteId(), new SiteMember(null, SiteRole.SiteContributor.toString()));
fail("");
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
// missing role
try
{
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2.getId()));
sitesProxy.createSiteMember(site.getSiteId(), new SiteMember(person1.getId(), null));
fail("");
}
catch(PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
// check site membership in GET
List<SiteMember> expectedSiteMembers = site.getMembers();