mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Implementation of addition of trailing * in search groups pattern
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13994 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
<webscript>
|
<webscript>
|
||||||
<shortname>List groups</shortname>
|
<shortname>List groups</shortname>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
Search for groups.
|
Search for groups.
|
||||||
<br />
|
<br />
|
||||||
Parameters
|
Parameters
|
||||||
<ul>
|
<ul>
|
||||||
<li>if the optional includeInternal parameter is true then will include internal groups, otherwise internalGroups are not returned.</li>
|
<li>if the optional includeInternal parameter is true then will include internal groups, otherwise internalGroups are not returned.</li>
|
||||||
<li>If the optional shortNameFilter parameter is set then returns those root groups with a partial match on shortName.</li>
|
<li>If the optional shortNameFilter parameter is set then returns those root groups with a partial match on shortName. You can use the pattern matching characters * to match zero or more characters or ? to match one character.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br />
|
<br />
|
||||||
Returns an Array of groups in JSON format.
|
Returns an Array of groups in JSON format.
|
||||||
|
@@ -102,7 +102,6 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
{
|
{
|
||||||
this.authenticationComponent.setSystemUserAsCurrentUser();
|
this.authenticationComponent.setSystemUserAsCurrentUser();
|
||||||
|
|
||||||
System.out.println("create test tree" + rootGroupName);
|
|
||||||
rootGroupName = authorityService.createAuthority(AuthorityType.GROUP, null, TEST_ROOTGROUP , TEST_ROOTGROUP_DISPLAY_NAME);
|
rootGroupName = authorityService.createAuthority(AuthorityType.GROUP, null, TEST_ROOTGROUP , TEST_ROOTGROUP_DISPLAY_NAME);
|
||||||
authorityService.createAuthority(AuthorityType.GROUP, rootGroupName, TEST_GROUPA);
|
authorityService.createAuthority(AuthorityType.GROUP, rootGroupName, TEST_GROUPA);
|
||||||
String groupB = authorityService.createAuthority(AuthorityType.GROUP, rootGroupName, TEST_GROUPB);
|
String groupB = authorityService.createAuthority(AuthorityType.GROUP, rootGroupName, TEST_GROUPB);
|
||||||
@@ -571,11 +570,44 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
// Search on partial short name
|
// Search on partial short name
|
||||||
{
|
{
|
||||||
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "*ADMIN*"), Status.STATUS_OK);
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "ALFRESCO_ADMIN*"), Status.STATUS_OK);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
JSONArray data = top.getJSONArray("data");
|
JSONArray data = top.getJSONArray("data");
|
||||||
assertTrue(data.length() > 0);
|
assertEquals("length not 1", 1, data.length());
|
||||||
|
JSONObject authority = data.getJSONObject(0);
|
||||||
|
assertEquals("", ADMIN_GROUP, authority.getString("shortName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search on partial short name with a ?
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "ALFRE?CO_ADMIN*"), Status.STATUS_OK);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
logger.debug(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("length not 1", 1, data.length());
|
||||||
|
JSONObject authority = data.getJSONObject(0);
|
||||||
|
assertEquals("", ADMIN_GROUP, authority.getString("shortName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Search on partial short name, Query should be extended by a *.
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "ALF"), Status.STATUS_OK);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
logger.debug(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("length not 1", 1, data.length());
|
||||||
|
JSONObject authority = data.getJSONObject(0);
|
||||||
|
assertEquals("", ADMIN_GROUP, authority.getString("shortName"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Negative test.
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "XX?X"), Status.STATUS_OK);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
logger.debug(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("length not 0", 0, data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search on full shortName
|
// Search on full shortName
|
||||||
@@ -584,14 +616,17 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
JSONArray data = top.getJSONArray("data");
|
JSONArray data = top.getJSONArray("data");
|
||||||
assertTrue(data.length() > 0);
|
assertEquals("length not 1", 1, data.length());
|
||||||
|
JSONObject authority = data.getJSONObject(0);
|
||||||
|
assertEquals("", ADMIN_GROUP, authority.getString("shortName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search on partial short name of a non root group
|
// Search on partial short name of a non root group
|
||||||
{
|
{
|
||||||
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + "*TD*"), Status.STATUS_OK);
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "?shortNameFilter=" + TEST_GROUPD ), Status.STATUS_OK);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
|
System.out.println(response.getContentAsString());
|
||||||
JSONArray data = top.getJSONArray("data");
|
JSONArray data = top.getJSONArray("data");
|
||||||
assertEquals("length not 1", 1, data.length());
|
assertEquals("length not 1", 1, data.length());
|
||||||
JSONObject authority = data.getJSONObject(0);
|
JSONObject authority = data.getJSONObject(0);
|
||||||
@@ -663,9 +698,7 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
public void testGetChildren() throws Exception
|
public void testGetChildren() throws Exception
|
||||||
{
|
{
|
||||||
createTestTree();
|
createTestTree();
|
||||||
|
|
||||||
//Thread.sleep(10,000);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get All Children of GROUP B
|
* Get All Children of GROUP B
|
||||||
*/
|
*/
|
||||||
@@ -675,7 +708,6 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
JSONArray data = top.getJSONArray("data");
|
JSONArray data = top.getJSONArray("data");
|
||||||
System.out.println(response.getContentAsString());
|
|
||||||
assertTrue(data.length() > 0);
|
assertTrue(data.length() > 0);
|
||||||
boolean gotGroupD = false;
|
boolean gotGroupD = false;
|
||||||
boolean gotUserTwo = false;
|
boolean gotUserTwo = false;
|
||||||
@@ -711,7 +743,6 @@ public class GroupsTest extends BaseWebScriptTest
|
|||||||
Response response = sendRequest(new GetRequest(URL_GROUPS + "/" + TEST_GROUPB + "/children?authorityType=GROUP"), Status.STATUS_OK);
|
Response response = sendRequest(new GetRequest(URL_GROUPS + "/" + TEST_GROUPB + "/children?authorityType=GROUP"), Status.STATUS_OK);
|
||||||
JSONObject top = new JSONObject(response.getContentAsString());
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
logger.debug(response.getContentAsString());
|
logger.debug(response.getContentAsString());
|
||||||
System.out.println(response.getContentAsString());
|
|
||||||
JSONArray data = top.getJSONArray("data");
|
JSONArray data = top.getJSONArray("data");
|
||||||
//assertTrue("no child groups of group B", data.length() == 1);
|
//assertTrue("no child groups of group B", data.length() == 1);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user