mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Various improvements to InviteServiceTest in setup(), tearDown(), and startInvite() helper method
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10213 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,18 +24,32 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.web.scripts.invite;
|
package org.alfresco.repo.web.scripts.invite;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
|
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
import org.alfresco.repo.site.SiteInfo;
|
import org.alfresco.repo.site.SiteInfo;
|
||||||
import org.alfresco.repo.site.SiteService;
|
import org.alfresco.repo.site.SiteService;
|
||||||
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
import org.alfresco.repo.web.scripts.BaseWebScriptTest;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
import org.alfresco.service.cmr.security.AuthorityService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.service.cmr.security.PersonService;
|
import org.alfresco.service.cmr.security.PersonService;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||||
|
import org.alfresco.service.cmr.workflow.WorkflowService;
|
||||||
import org.alfresco.util.PropertyMap;
|
import org.alfresco.util.PropertyMap;
|
||||||
import org.alfresco.util.URLEncoder;
|
import org.alfresco.util.URLEncoder;
|
||||||
import org.alfresco.web.scripts.Status;
|
import org.alfresco.web.scripts.Status;
|
||||||
|
import org.apache.commons.lang.RandomStringUtils;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.springframework.mock.web.MockHttpServletResponse;
|
import org.springframework.mock.web.MockHttpServletResponse;
|
||||||
@@ -47,17 +61,29 @@ import org.springframework.mock.web.MockHttpServletResponse;
|
|||||||
*/
|
*/
|
||||||
public class InviteServiceTest extends BaseWebScriptTest
|
public class InviteServiceTest extends BaseWebScriptTest
|
||||||
{
|
{
|
||||||
|
// member variables for service instances
|
||||||
private AuthorityService authorityService;
|
private AuthorityService authorityService;
|
||||||
private AuthenticationService authenticationService;
|
private AuthenticationService authenticationService;
|
||||||
private AuthenticationComponent authenticationComponent;
|
private AuthenticationComponent authenticationComponent;
|
||||||
private PersonService personService;
|
private PersonService personService;
|
||||||
private SiteService siteService;
|
private SiteService siteService;
|
||||||
|
private NodeService nodeService;
|
||||||
|
private WorkflowService workflowService;
|
||||||
|
private MutableAuthenticationDao mutableAuthenticationDao;
|
||||||
|
|
||||||
|
// stores invitee email addresses, one entry for each "start invite" operation
|
||||||
|
// invoked, so that resources created for each invitee for each test
|
||||||
|
// can be removed in the tearDown() method
|
||||||
|
private List<String> inviteeEmailAddrs;
|
||||||
|
|
||||||
|
private static final String WF_DEFINITION_INVITE = "jbpm$wf:invite";
|
||||||
|
|
||||||
private static final String USER_ADMIN = "admin";
|
private static final String USER_ADMIN = "admin";
|
||||||
private static final String USER_INVITER = "InviterUser";
|
private static final String USER_INVITER = "InviterUser";
|
||||||
private static final String INVITEE_FIRSTNAME = "InviteeFirstName";
|
private static final String INVITEE_FIRSTNAME = "InviteeFirstName";
|
||||||
private static final String INVITEE_LASTNAME = "InviteeLastName";
|
private static final String INVITEE_LASTNAME = "InviteeLastName";
|
||||||
private static final String INVITEE_EMAIL = "inviteeFN.inviteeLN@email123.com";
|
private static final String INVITEE_EMAIL_DOMAIN = "alfrescotesting.com";
|
||||||
|
private static final String INVITEE_EMAIL_PREFIX = "invitee";
|
||||||
private static final String SITE_SHORT_NAME_INVITE = "InviteSiteShortName";
|
private static final String SITE_SHORT_NAME_INVITE = "InviteSiteShortName";
|
||||||
|
|
||||||
private static final String URL_INVITE_SERVICE = "/api/invite";
|
private static final String URL_INVITE_SERVICE = "/api/invite";
|
||||||
@@ -77,31 +103,50 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
// get references to services
|
// get references to services
|
||||||
this.authorityService = (AuthorityService) getServer()
|
this.authorityService = (AuthorityService) getServer()
|
||||||
.getApplicationContext().getBean("authorityService");
|
.getApplicationContext().getBean("AuthorityService");
|
||||||
this.authenticationService = (AuthenticationService) getServer()
|
this.authenticationService = (AuthenticationService) getServer()
|
||||||
.getApplicationContext().getBean("AuthenticationService");
|
.getApplicationContext().getBean("AuthenticationService");
|
||||||
this.authenticationComponent = (AuthenticationComponent) getServer()
|
this.authenticationComponent = (AuthenticationComponent) getServer()
|
||||||
.getApplicationContext().getBean("authenticationComponent");
|
.getApplicationContext().getBean("AuthenticationComponent");
|
||||||
this.personService = (PersonService) getServer()
|
this.personService = (PersonService) getServer()
|
||||||
.getApplicationContext().getBean("PersonService");
|
.getApplicationContext().getBean("PersonService");
|
||||||
this.siteService = (SiteService) getServer().getApplicationContext()
|
this.siteService = (SiteService) getServer().getApplicationContext()
|
||||||
.getBean("siteService");
|
.getBean("siteService");
|
||||||
|
this.nodeService = (NodeService) getServer().getApplicationContext()
|
||||||
|
.getBean("NodeService");
|
||||||
|
this.workflowService = (WorkflowService) getServer()
|
||||||
|
.getApplicationContext().getBean("WorkflowService");
|
||||||
|
this.mutableAuthenticationDao = (MutableAuthenticationDao) getServer()
|
||||||
|
.getApplicationContext().getBean("authenticationDao");
|
||||||
|
|
||||||
// set current user as admin for various setup operations needing admin rights
|
// Create new invitee email address list
|
||||||
this.authenticationComponent.setCurrentUser(USER_ADMIN);
|
this.inviteeEmailAddrs = new ArrayList<String>();
|
||||||
|
|
||||||
// Create inviter
|
//
|
||||||
createPerson(USER_INVITER);
|
// various setup operations which need to be run as 'admin'
|
||||||
|
//
|
||||||
// Create site for Inviter to invite Invitee to
|
RunAsWork<Object> runAsWork = new RunAsWork<Object>()
|
||||||
// - only create the site if it doesn't already exist
|
|
||||||
SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_INVITE);
|
|
||||||
if (siteInfo == null)
|
|
||||||
{
|
{
|
||||||
this.siteService.createSite("InviteSitePreset",
|
public Object doWork() throws Exception
|
||||||
SITE_SHORT_NAME_INVITE, "InviteSiteTitle",
|
{
|
||||||
"InviteSiteDescription", true);
|
// Create inviter
|
||||||
}
|
createPerson(USER_INVITER);
|
||||||
|
|
||||||
|
// Create site for Inviter to invite Invitee to
|
||||||
|
// - only create the site if it doesn't already exist
|
||||||
|
SiteInfo siteInfo = InviteServiceTest.this.siteService
|
||||||
|
.getSite(SITE_SHORT_NAME_INVITE);
|
||||||
|
if (siteInfo == null)
|
||||||
|
{
|
||||||
|
InviteServiceTest.this.siteService.createSite(
|
||||||
|
"InviteSitePreset", SITE_SHORT_NAME_INVITE,
|
||||||
|
"InviteSiteTitle", "InviteSiteDescription", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AuthenticationUtil.runAs(runAsWork, USER_ADMIN);
|
||||||
|
|
||||||
// Do tests as inviter user
|
// Do tests as inviter user
|
||||||
this.authenticationComponent.setCurrentUser(USER_INVITER);
|
this.authenticationComponent.setCurrentUser(USER_INVITER);
|
||||||
@@ -112,25 +157,67 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
{
|
{
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
|
|
||||||
// admin authority required for various cleanup operations needing admin rights
|
//
|
||||||
this.authenticationComponent.setCurrentUser(USER_ADMIN);
|
// run various teardown operations which need to be run as 'admin'
|
||||||
|
//
|
||||||
|
RunAsWork<Object> runAsWork = new RunAsWork<Object>()
|
||||||
|
{
|
||||||
|
public Object doWork() throws Exception
|
||||||
|
{
|
||||||
|
// delete the inviter
|
||||||
|
deletePersonByUserName(USER_INVITER);
|
||||||
|
|
||||||
// delete the inviter
|
// delete all invitee people
|
||||||
deletePerson(USER_INVITER);
|
for (String inviteeEmail : InviteServiceTest.this.inviteeEmailAddrs)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// delete all people with given email address
|
||||||
|
//
|
||||||
|
|
||||||
// delete invite site
|
Set<NodeRef> people = InviteServiceTest.this.personService
|
||||||
siteService.deleteSite(SITE_SHORT_NAME_INVITE);
|
.getPeopleFilteredByProperty(
|
||||||
|
ContentModel.PROP_EMAIL, inviteeEmail);
|
||||||
|
for (NodeRef person : people)
|
||||||
|
{
|
||||||
|
String userName = DefaultTypeConverter.INSTANCE
|
||||||
|
.convert(String.class, nodeService.getProperty(
|
||||||
|
person, ContentModel.PROP_USERNAME));
|
||||||
|
|
||||||
|
// delete person
|
||||||
|
deletePersonByUserName(userName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete invite site
|
||||||
|
siteService.deleteSite(SITE_SHORT_NAME_INVITE);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AuthenticationUtil.runAs(runAsWork, USER_ADMIN);
|
||||||
|
|
||||||
|
// cancel all active invite workflows
|
||||||
|
WorkflowDefinition wfDef = InviteServiceTest.this.workflowService
|
||||||
|
.getDefinitionByName(WF_DEFINITION_INVITE);
|
||||||
|
List<WorkflowInstance> workflowList = InviteServiceTest.this.workflowService
|
||||||
|
.getActiveWorkflows(wfDef.id);
|
||||||
|
for (WorkflowInstance workflow : workflowList)
|
||||||
|
{
|
||||||
|
InviteServiceTest.this.workflowService.cancelWorkflow(workflow.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addUserToGroup(String groupName, String userName)
|
private void addUserToGroup(String groupName, String userName)
|
||||||
{
|
{
|
||||||
// get the full name for the group
|
// get the full name for the group
|
||||||
String fullGroupName = this.authorityService.getName(AuthorityType.GROUP, groupName);
|
String fullGroupName = this.authorityService.getName(
|
||||||
|
AuthorityType.GROUP, groupName);
|
||||||
|
|
||||||
// create group if it does not exist
|
// create group if it does not exist
|
||||||
if (this.authorityService.authorityExists(fullGroupName) == false)
|
if (this.authorityService.authorityExists(fullGroupName) == false)
|
||||||
{
|
{
|
||||||
this.authorityService.createAuthority(AuthorityType.GROUP, null, fullGroupName);
|
this.authorityService.createAuthority(AuthorityType.GROUP, null,
|
||||||
|
fullGroupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the user to the group
|
// add the user to the group
|
||||||
@@ -140,7 +227,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
private void removeUserFromGroup(String groupName, String userName)
|
private void removeUserFromGroup(String groupName, String userName)
|
||||||
{
|
{
|
||||||
// get the full name for the group
|
// get the full name for the group
|
||||||
String fullGroupName = this.authorityService.getName(AuthorityType.GROUP, groupName);
|
String fullGroupName = this.authorityService.getName(
|
||||||
|
AuthorityType.GROUP, groupName);
|
||||||
|
|
||||||
// remove user from the group
|
// remove user from the group
|
||||||
this.authorityService.removeAuthority(fullGroupName, userName);
|
this.authorityService.removeAuthority(fullGroupName, userName);
|
||||||
@@ -178,24 +266,46 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deletePerson(String userName)
|
private void deletePersonByUserName(String userName)
|
||||||
{
|
{
|
||||||
// delete person node associated with user
|
// delete authentication if authentication exists for given user name
|
||||||
this.personService.deletePerson(userName);
|
if (this.authenticationService.authenticationExists(userName))
|
||||||
|
{
|
||||||
|
this.authenticationService.deleteAuthentication(userName);
|
||||||
|
}
|
||||||
|
|
||||||
// delete user
|
// delete user account
|
||||||
this.authenticationService.deleteAuthentication(userName);
|
if (this.mutableAuthenticationDao.userExists(userName))
|
||||||
|
{
|
||||||
|
this.mutableAuthenticationDao.deleteUser(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete person node associated with given user name
|
||||||
|
// if one exists
|
||||||
|
if (this.personService.personExists(userName))
|
||||||
|
{
|
||||||
|
this.personService.deletePerson(userName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject startInvite(String inviteeFirstName, String inviteeLastName, String inviteeEmail,
|
private JSONObject startInvite(String inviteeFirstName,
|
||||||
String siteShortName, int expectedStatus) throws Exception
|
String inviteeLastName, String siteShortName, int expectedStatus)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
|
String inviteeEmail = INVITEE_EMAIL_PREFIX +
|
||||||
|
RandomStringUtils.randomAlphanumeric(6)
|
||||||
|
+ "@" + INVITEE_EMAIL_DOMAIN;
|
||||||
|
this.inviteeEmailAddrs.add(inviteeEmail);
|
||||||
|
|
||||||
// Inviter sends invitation to Invitee to join a Site
|
// Inviter sends invitation to Invitee to join a Site
|
||||||
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START
|
String startInviteUrl = URL_INVITE_SERVICE + "/" + INVITE_ACTION_START
|
||||||
+ "?inviteeFirstName=" + inviteeFirstName + "&inviteeLastName=" + inviteeLastName
|
+ "?inviteeFirstName=" + inviteeFirstName + "&inviteeLastName="
|
||||||
+ "&inviteeEmail=" + URLEncoder.encode(inviteeEmail) + "&siteShortName=" + siteShortName;
|
+ inviteeLastName + "&inviteeEmail="
|
||||||
|
+ URLEncoder.encode(inviteeEmail) + "&siteShortName="
|
||||||
|
+ siteShortName;
|
||||||
|
|
||||||
MockHttpServletResponse response = getRequest(startInviteUrl, expectedStatus);
|
MockHttpServletResponse response = getRequest(startInviteUrl,
|
||||||
|
expectedStatus);
|
||||||
|
|
||||||
JSONObject result = new JSONObject(response.getContentAsString());
|
JSONObject result = new JSONObject(response.getContentAsString());
|
||||||
|
|
||||||
@@ -217,11 +327,12 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONArray getInvitesByInviterUserName(String inviterUserName, int expectedStatus)
|
private JSONArray getInvitesByInviterUserName(String inviterUserName,
|
||||||
throws Exception
|
int expectedStatus) throws Exception
|
||||||
{
|
{
|
||||||
// construct get invites URL
|
// construct get invites URL
|
||||||
String getInvitesUrl = URL_INVITES_SERVICE + "?inviterUserName=" + inviterUserName;
|
String getInvitesUrl = URL_INVITES_SERVICE + "?inviterUserName="
|
||||||
|
+ inviterUserName;
|
||||||
|
|
||||||
// invoke get invites web script
|
// invoke get invites web script
|
||||||
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
||||||
@@ -232,11 +343,12 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONArray getInvitesByInviteeUserName(String inviteeUserName, int expectedStatus)
|
private JSONArray getInvitesByInviteeUserName(String inviteeUserName,
|
||||||
throws Exception
|
int expectedStatus) throws Exception
|
||||||
{
|
{
|
||||||
// construct get invites URL
|
// construct get invites URL
|
||||||
String getInvitesUrl = URL_INVITES_SERVICE + "?inviteeUserName=" + inviteeUserName;
|
String getInvitesUrl = URL_INVITES_SERVICE + "?inviteeUserName="
|
||||||
|
+ inviteeUserName;
|
||||||
|
|
||||||
// invoke get invites web script
|
// invoke get invites web script
|
||||||
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
||||||
@@ -247,11 +359,12 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSONArray getInvitesBySiteShortName(String siteShortName, int expectedStatus)
|
private JSONArray getInvitesBySiteShortName(String siteShortName,
|
||||||
throws Exception
|
int expectedStatus) throws Exception
|
||||||
{
|
{
|
||||||
// construct get invites URL
|
// construct get invites URL
|
||||||
String getInvitesUrl = URL_INVITES_SERVICE + "?siteShortName=" + siteShortName;
|
String getInvitesUrl = URL_INVITES_SERVICE + "?siteShortName="
|
||||||
|
+ siteShortName;
|
||||||
|
|
||||||
// invoke get invites web script
|
// invoke get invites web script
|
||||||
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
MockHttpServletResponse response = getRequest(getInvitesUrl,
|
||||||
@@ -264,20 +377,22 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
|
|
||||||
public void testStartInvite() throws Exception
|
public void testStartInvite() throws Exception
|
||||||
{
|
{
|
||||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(INVITE_ACTION_START, result.get("action"));
|
assertEquals(INVITE_ACTION_START, result.get("action"));
|
||||||
assertEquals(INVITEE_FIRSTNAME, result.get("inviteeFirstName"));
|
assertEquals(INVITEE_FIRSTNAME, result.get("inviteeFirstName"));
|
||||||
assertEquals(INVITEE_LASTNAME, result.get("inviteeLastName"));
|
assertEquals(INVITEE_LASTNAME, result.get("inviteeLastName"));
|
||||||
assertEquals(INVITEE_EMAIL, result.get("inviteeEmail"));
|
assertEquals(this.inviteeEmailAddrs
|
||||||
|
.get(this.inviteeEmailAddrs.size() - 1), result
|
||||||
|
.get("inviteeEmail"));
|
||||||
assertEquals(SITE_SHORT_NAME_INVITE, result.get("siteShortName"));
|
assertEquals(SITE_SHORT_NAME_INVITE, result.get("siteShortName"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCancelInvite() throws Exception
|
public void testCancelInvite() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite workflow
|
// inviter starts invite workflow
|
||||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of invite ID of started invite
|
// get hold of invite ID of started invite
|
||||||
@@ -293,7 +408,7 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testAcceptInvite() throws Exception
|
public void testAcceptInvite() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite (sends out invitation)
|
// inviter starts invite (sends out invitation)
|
||||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of invite ID of started invite
|
// get hold of invite ID of started invite
|
||||||
@@ -312,12 +427,15 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
Status.STATUS_OK);
|
Status.STATUS_OK);
|
||||||
|
|
||||||
//
|
//
|
||||||
// test that invitation represented by invite ID (of invitation started above)
|
// test that invitation represented by invite ID (of invitation started
|
||||||
// is no longer pending (as a result of the invitation having being accepted)
|
// above)
|
||||||
|
// is no longer pending (as a result of the invitation having being
|
||||||
|
// accepted)
|
||||||
//
|
//
|
||||||
|
|
||||||
// get pending invite matching inviteId from invite started above
|
// get pending invite matching inviteId from invite started above
|
||||||
JSONArray getInvitesResult = getInvitesByInviteId(inviteId, Status.STATUS_OK);
|
JSONArray getInvitesResult = getInvitesByInviteId(inviteId,
|
||||||
|
Status.STATUS_OK);
|
||||||
|
|
||||||
// there should no longer be any invites identified by invite ID pending
|
// there should no longer be any invites identified by invite ID pending
|
||||||
assertEquals(getInvitesResult.length(), 0);
|
assertEquals(getInvitesResult.length(), 0);
|
||||||
@@ -326,7 +444,7 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testRejectInvite() throws Exception
|
public void testRejectInvite() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite (sends out invitation)
|
// inviter starts invite (sends out invitation)
|
||||||
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of invite ID of started invite
|
// get hold of invite ID of started invite
|
||||||
@@ -345,12 +463,15 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
Status.STATUS_OK);
|
Status.STATUS_OK);
|
||||||
|
|
||||||
//
|
//
|
||||||
// test that invite represented by invite ID (of invitation started above)
|
// test that invite represented by invite ID (of invitation started
|
||||||
// is no longer pending (as a result of the invitation having being rejected)
|
// above)
|
||||||
|
// is no longer pending (as a result of the invitation having being
|
||||||
|
// rejected)
|
||||||
//
|
//
|
||||||
|
|
||||||
// get pending invite matching inviteId from invite started above
|
// get pending invite matching inviteId from invite started above
|
||||||
JSONArray getInvitesResult = getInvitesByInviteId(inviteId, Status.STATUS_OK);
|
JSONArray getInvitesResult = getInvitesByInviteId(inviteId,
|
||||||
|
Status.STATUS_OK);
|
||||||
|
|
||||||
// there should no longer be any invites identified by invite ID pending
|
// there should no longer be any invites identified by invite ID pending
|
||||||
assertEquals(getInvitesResult.length(), 0);
|
assertEquals(getInvitesResult.length(), 0);
|
||||||
@@ -359,8 +480,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testGetInvitesByInviteId() throws Exception
|
public void testGetInvitesByInviteId() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite workflow
|
// inviter starts invite workflow
|
||||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
INVITEE_LASTNAME, SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of workflow ID of started invite workflow instance
|
// get hold of workflow ID of started invite workflow instance
|
||||||
|
|
||||||
@@ -369,7 +490,8 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
assertEquals(true, ((inviteId != null) && (inviteId.length() != 0)));
|
assertEquals(true, ((inviteId != null) && (inviteId.length() != 0)));
|
||||||
|
|
||||||
// get pending invite matching inviteId from invite started above
|
// get pending invite matching inviteId from invite started above
|
||||||
JSONArray getInvitesResult = getInvitesByInviteId(inviteId, Status.STATUS_OK);
|
JSONArray getInvitesResult = getInvitesByInviteId(inviteId,
|
||||||
|
Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(getInvitesResult.length(), 1);
|
assertEquals(getInvitesResult.length(), 1);
|
||||||
|
|
||||||
@@ -381,11 +503,13 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testGetInvitesByInviterUserName() throws Exception
|
public void testGetInvitesByInviterUserName() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite workflow
|
// inviter starts invite workflow
|
||||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
INVITEE_LASTNAME, SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get pending invites matching inviter user name used in invite started above
|
// get pending invites matching inviter user name used in invite started
|
||||||
JSONArray getInvitesResult = getInvitesByInviterUserName(USER_INVITER, Status.STATUS_OK);
|
// above
|
||||||
|
JSONArray getInvitesResult = getInvitesByInviterUserName(USER_INVITER,
|
||||||
|
Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(true, getInvitesResult.length() > 0);
|
assertEquals(true, getInvitesResult.length() > 0);
|
||||||
|
|
||||||
@@ -397,16 +521,20 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testGetInvitesByInviteeUserName() throws Exception
|
public void testGetInvitesByInviteeUserName() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite workflow
|
// inviter starts invite workflow
|
||||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
INVITEE_LASTNAME, SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of invitee user name property of started invite workflow instance
|
// get hold of invitee user name property of started invite workflow
|
||||||
|
// instance
|
||||||
String inviteeUserName = startInviteResult.getString("inviteeUserName");
|
String inviteeUserName = startInviteResult.getString("inviteeUserName");
|
||||||
|
|
||||||
assertEquals(true, ((inviteeUserName != null) && (inviteeUserName.length() != 0)));
|
assertEquals(true, ((inviteeUserName != null) && (inviteeUserName
|
||||||
|
.length() != 0)));
|
||||||
|
|
||||||
// get pending invites matching invitee user name from invite started above
|
// get pending invites matching invitee user name from invite started
|
||||||
JSONArray getInvitesResult = getInvitesByInviteeUserName(inviteeUserName, Status.STATUS_OK);
|
// above
|
||||||
|
JSONArray getInvitesResult = getInvitesByInviteeUserName(
|
||||||
|
inviteeUserName, Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(true, getInvitesResult.length() > 0);
|
assertEquals(true, getInvitesResult.length() > 0);
|
||||||
|
|
||||||
@@ -418,16 +546,20 @@ public class InviteServiceTest extends BaseWebScriptTest
|
|||||||
public void testGetInvitesBySiteShortName() throws Exception
|
public void testGetInvitesBySiteShortName() throws Exception
|
||||||
{
|
{
|
||||||
// inviter starts invite workflow
|
// inviter starts invite workflow
|
||||||
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_EMAIL,
|
JSONObject startInviteResult = startInvite(INVITEE_FIRSTNAME,
|
||||||
SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
INVITEE_LASTNAME, SITE_SHORT_NAME_INVITE, Status.STATUS_OK);
|
||||||
|
|
||||||
// get hold of site short name property of started invite workflow instance
|
// get hold of site short name property of started invite workflow
|
||||||
|
// instance
|
||||||
String siteShortName = startInviteResult.getString("siteShortName");
|
String siteShortName = startInviteResult.getString("siteShortName");
|
||||||
|
|
||||||
assertEquals(true, ((siteShortName != null) && (siteShortName.length() != 0)));
|
assertEquals(true,
|
||||||
|
((siteShortName != null) && (siteShortName.length() != 0)));
|
||||||
|
|
||||||
// get pending invites matching site short name from invite started above
|
// get pending invites matching site short name from invite started
|
||||||
JSONArray getInvitesResult = getInvitesBySiteShortName(siteShortName, Status.STATUS_OK);
|
// above
|
||||||
|
JSONArray getInvitesResult = getInvitesBySiteShortName(siteShortName,
|
||||||
|
Status.STATUS_OK);
|
||||||
|
|
||||||
assertEquals(true, getInvitesResult.length() > 0);
|
assertEquals(true, getInvitesResult.length() > 0);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user