Added somes tests for invalid paging parameters. REPO-1061, REPO-890

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@129753 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Martin Muller
2016-08-22 13:24:38 +00:00
parent ecec348d6c
commit 2c62e68f71

View File

@@ -29,10 +29,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
@@ -324,5 +321,96 @@ public class TestUserPreferences extends EnterpriseTestApi
{
assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, e.getHttpResponse().getStatusCode());
}
{
// REPO-1061, REPO-890
try
{
String skipCount = "a";
String maxItems = "hi";
HashMap<String, String> params = new HashMap<String, String>();
params.put("skipCount", skipCount);
params.put("maxItems", maxItems);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
try
{
String skipCount = "a";
String maxItems = "null";
HashMap<String, String> params = new HashMap<String, String>();
params.put("skipCount", skipCount);
params.put("maxItems", maxItems);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
try
{
String maxItems = "Red";
HashMap<String, String> params = new HashMap<String, String>();
params.put("maxItems", maxItems);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
try
{
String skipCount = "yuck";
HashMap<String, String> params = new HashMap<String, String>();
params.put("skipCount", skipCount);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
try
{
String skipCount = "-1";
HashMap<String, String> params = new HashMap<String, String>();
params.put("skipCount", skipCount);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
try
{
String maxItems = "0";
HashMap<String, String> params = new HashMap<String, String>();
params.put("maxItems", maxItems);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1.getId()));
peopleProxy.getPreferences(person1.getId(), params);
fail();
}
catch (PublicApiException e)
{
assertEquals(HttpStatus.SC_BAD_REQUEST, e.getHttpResponse().getStatusCode());
}
}
}
}