mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALFCOM-2687 Implementing the list invitations web script and unit tests.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13790 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
<BR />
|
<BR />
|
||||||
|
|
||||||
|
Returns a JSON element
|
||||||
|
|
||||||
<BR />
|
<BR />
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
<#-- list / search / invitations -->
|
<#-- list / search / invitations -->
|
||||||
|
|
||||||
<#import "../../invitation/invitation.lib.ftl" as invitationLib/>
|
<#import "../../invitation/invitation.lib.ftl" as invitationLib/>
|
||||||
"data": [
|
{
|
||||||
<#list invitations as invitation>
|
"data": [
|
||||||
<@invitationLib.invitationJSON invitation=invitation />
|
<#list invitations as invitation>
|
||||||
<#if invitation_has_next>,</#if>
|
<@invitationLib.invitationJSON invitation=invitation />
|
||||||
</#list>
|
<#if invitation_has_next>,</#if>
|
||||||
]
|
</#list>
|
||||||
|
]
|
||||||
|
}
|
||||||
|
@@ -683,6 +683,85 @@ public class SiteServiceTest extends BaseWebScriptTest
|
|||||||
String shortName = GUID.generate();
|
String shortName = GUID.generate();
|
||||||
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
|
createSite("myPreset", shortName, "myTitle", "myDescription", SiteVisibility.PUBLIC, 200);
|
||||||
|
|
||||||
|
String inviteeComments = "Please sir, let $* me in";
|
||||||
|
String userName = USER_TWO;
|
||||||
|
String roleName = SiteModel.SITE_CONSUMER;
|
||||||
|
String moderatedIdA = createModeratedInvitation(shortName, inviteeComments, userName, roleName);
|
||||||
|
|
||||||
|
String inviteeCommentsB = "Please sir, let $* me in";
|
||||||
|
String userNameB = USER_THREE;
|
||||||
|
String roleNameB = SiteModel.SITE_CONSUMER;
|
||||||
|
String moderatedIdB = createModeratedInvitation(shortName, inviteeCommentsB, userNameB, roleNameB);
|
||||||
|
|
||||||
|
String inviteeFirstName = "Buffy";
|
||||||
|
String inviteeLastName = "Summers";
|
||||||
|
String inviteeEmail = "buffy@sunnydale";
|
||||||
|
String inviteeUserName = userName;
|
||||||
|
String serverPath = "http://localhost:8081/share/";
|
||||||
|
String acceptURL = "page/accept-invite";
|
||||||
|
String rejectURL = "page/reject-invite";
|
||||||
|
|
||||||
|
// Create a nominated invitation
|
||||||
|
String nominatedId = createNominatedInvitation(shortName, inviteeFirstName, inviteeLastName, inviteeEmail, inviteeUserName, roleName, serverPath, acceptURL, rejectURL);
|
||||||
|
/**
|
||||||
|
* search by user - wombat does not have an invitation
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=wombat"), 200);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("user wombat", data.length(), 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* search by user - find USER_TWO's two invitations
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + USER_TWO), 200);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
//System.out.println(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("user two invitation not found", data.length(), 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search by type
|
||||||
|
*/
|
||||||
|
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?invitationType=MODERATED"), 200);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
//System.out.println(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?invitationType=NOMINATED"), 200);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
//System.out.println(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
}
|
||||||
|
// negative test - unknown invitationType
|
||||||
|
{
|
||||||
|
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?invitationType=Crap"), 500);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search by user and type
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
Response response = sendRequest(new GetRequest(URL_SITES + "/" + shortName + "/invitations?inviteeUserName=" + USER_TWO + "&invitationType=MODERATED"), 200);
|
||||||
|
JSONObject top = new JSONObject(response.getContentAsString());
|
||||||
|
//System.out.println(response.getContentAsString());
|
||||||
|
JSONArray data = top.getJSONArray("data");
|
||||||
|
assertEquals("user two invitation not found", data.length(), 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user