Merged SHA-SIMP-1 (5.1.0) to HEAD (5.1)

109013: trying to fix compilation error after merge so build can run


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@110797 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ray Gauss
2015-08-25 14:03:22 +00:00
parent ec20cc7e9b
commit e440f28a19

View File

@@ -73,7 +73,7 @@ import org.springframework.extensions.webscripts.TestWebScriptServer.Response;
/** /**
* Unit Test to test Invite Web Script API * Unit Test to test Invite Web Script API
* *
* @author Glen Johnson at Alfresco dot com * @author Glen Johnson at Alfresco dot com
*/ */
public class InviteServiceTest extends BaseWebScriptTest public class InviteServiceTest extends BaseWebScriptTest
@@ -97,7 +97,7 @@ public class InviteServiceTest extends BaseWebScriptTest
// can be removed in the tearDown() method // can be removed in the tearDown() method
private List<String> inviteeEmailAddrs; private List<String> inviteeEmailAddrs;
private static final String WF_DEFINITION_INVITE = WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI; private static final String WF_DEFINITION_INVITE = WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE;
private static final String USER_INVITER = "InviterUser"; private static final String USER_INVITER = "InviterUser";
private static final String USER_INVITER_2 = "InviterUser2"; private static final String USER_INVITER_2 = "InviterUser2";
@@ -122,7 +122,7 @@ public class InviteServiceTest extends BaseWebScriptTest
protected void setUp() throws Exception protected void setUp() throws Exception
{ {
super.setUp(); super.setUp();
/** /**
* We don't want to be authenticated as 'system' but run as 'InviterUser', because then * We don't want to be authenticated as 'system' but run as 'InviterUser', because then
* 'system' will be the creator for the sites and 'inviterUser' will be a nobody. * 'system' will be the creator for the sites and 'inviterUser' will be a nobody.
@@ -150,9 +150,9 @@ public class InviteServiceTest extends BaseWebScriptTest
scriptInvitationService.setSiteService(this.siteService); scriptInvitationService.setSiteService(this.siteService);
Invite invite = (Invite) getServer().getApplicationContext().getBean("webscript.org.alfresco.repository.invite.invite.get"); Invite invite = (Invite) getServer().getApplicationContext().getBean("webscript.org.alfresco.repository.invite.invite.get");
invite.setSiteService(this.siteService); invite.setSiteService(this.siteService);
configureMailExecutorForTestMode(this.getServer()); configureMailExecutorForTestMode(this.getServer());
// We're using a MailActionExecuter defined in outboundSMTP-test-context.xml which // We're using a MailActionExecuter defined in outboundSMTP-test-context.xml which
// sets the testMode property to true via spring injection. This will prevent emails // sets the testMode property to true via spring injection. This will prevent emails
// from being sent from within this test case. // from being sent from within this test case.
@@ -179,20 +179,20 @@ public class InviteServiceTest extends BaseWebScriptTest
// "alfresco/workflow/invitation-nominated_processdefinition.xml"); // "alfresco/workflow/invitation-nominated_processdefinition.xml");
// workflowService.deployDefinition( // workflowService.deployDefinition(
// JBPMEngine.ENGINE_ID, inviteWfResource.getInputStream(), MimetypeMap.MIMETYPE_XML); // JBPMEngine.ENGINE_ID, inviteWfResource.getInputStream(), MimetypeMap.MIMETYPE_XML);
// Create new invitee email address list // Create new invitee email address list
inviteeEmailAddrs = new ArrayList<String>(); inviteeEmailAddrs = new ArrayList<String>();
// Create inviter person // Create inviter person
createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, USER_INVITER, INVITER_EMAIL); createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, USER_INVITER, INVITER_EMAIL);
// Create inviter2 person // Create inviter2 person
createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, USER_INVITER_2, INVITER_EMAIL_2); createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, USER_INVITER_2, INVITER_EMAIL_2);
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
// The creation of sites is heavily dependent on the authenticated user. We must ensure that, // The creation of sites is heavily dependent on the authenticated user. We must ensure that,
// when doing the runAs below, the user both 'runAs' and 'fullyAuthenticated'. In order for // when doing the runAs below, the user both 'runAs' and 'fullyAuthenticated'. In order for
// this to be the case, the security context MUST BE EMPTY now. We could do the old // this to be the case, the security context MUST BE EMPTY now. We could do the old
@@ -217,7 +217,7 @@ public class InviteServiceTest extends BaseWebScriptTest
siteService.createSite("InviteSitePreset", SITE_SHORT_NAME_INVITE_1, siteService.createSite("InviteSitePreset", SITE_SHORT_NAME_INVITE_1,
"InviteSiteTitle", "InviteSiteDescription", SiteVisibility.PUBLIC); "InviteSiteTitle", "InviteSiteDescription", SiteVisibility.PUBLIC);
} }
// Create second site for inviter to invite invitee to // Create second site for inviter to invite invitee to
siteInfo = siteService.getSite(SITE_SHORT_NAME_INVITE_2); siteInfo = siteService.getSite(SITE_SHORT_NAME_INVITE_2);
if (siteInfo == null) if (siteInfo == null)
@@ -234,7 +234,7 @@ public class InviteServiceTest extends BaseWebScriptTest
"InviteSitePreset", SITE_SHORT_NAME_INVITE_3, "InviteSitePreset", SITE_SHORT_NAME_INVITE_3,
"InviteSiteTitle", "InviteSiteDescription", SiteVisibility.PUBLIC); "InviteSiteTitle", "InviteSiteDescription", SiteVisibility.PUBLIC);
} }
// set inviter2's role on third site to collaborator // set inviter2's role on third site to collaborator
String inviterSiteRole = siteService.getMembersRole(SITE_SHORT_NAME_INVITE_3, USER_INVITER_2); String inviterSiteRole = siteService.getMembersRole(SITE_SHORT_NAME_INVITE_3, USER_INVITER_2);
if ((inviterSiteRole == null) || (inviterSiteRole.equals(SiteModel.SITE_COLLABORATOR) == false)) if ((inviterSiteRole == null) || (inviterSiteRole.equals(SiteModel.SITE_COLLABORATOR) == false))
@@ -282,14 +282,14 @@ public class InviteServiceTest extends BaseWebScriptTest
// and isolates all the hacking into this test class. // and isolates all the hacking into this test class.
// //
// Therefore we've decided to do [3]. // Therefore we've decided to do [3].
ChildApplicationContextFactory outboundSmptSubsystem ChildApplicationContextFactory outboundSmptSubsystem
= (ChildApplicationContextFactory)server.getApplicationContext().getBean("OutboundSMTP"); = (ChildApplicationContextFactory)server.getApplicationContext().getBean("OutboundSMTP");
ApplicationContext childAppCtxt = outboundSmptSubsystem.getApplicationContext(); ApplicationContext childAppCtxt = outboundSmptSubsystem.getApplicationContext();
MailActionExecuter mailActionExecutor = (MailActionExecuter)childAppCtxt.getBean("mail"); MailActionExecuter mailActionExecutor = (MailActionExecuter)childAppCtxt.getBean("mail");
mailActionExecutor.setTestMode(true); mailActionExecutor.setTestMode(true);
} }
@Override @Override
protected void tearDown() throws Exception protected void tearDown() throws Exception
{ {
@@ -307,7 +307,7 @@ public class InviteServiceTest extends BaseWebScriptTest
} }
}; };
final SiteInfo[] siteInfos = AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getSystemUserName()); final SiteInfo[] siteInfos = AuthenticationUtil.runAs(runAsWork, AuthenticationUtil.getSystemUserName());
// //
// run various teardown operations which need to be run as 'admin' // run various teardown operations which need to be run as 'admin'
// //
@@ -330,7 +330,7 @@ public class InviteServiceTest extends BaseWebScriptTest
// delete all people with given email address // delete all people with given email address
// //
Set<NodeRef> people = Set<NodeRef> people =
personService.getPeopleFilteredByProperty(ContentModel.PROP_EMAIL, inviteeEmail, 1000); personService.getPeopleFilteredByProperty(ContentModel.PROP_EMAIL, inviteeEmail, 1000);
for (NodeRef person : people) for (NodeRef person : people)
{ {
@@ -340,7 +340,7 @@ public class InviteServiceTest extends BaseWebScriptTest
deletePersonByUserName(userName); deletePersonByUserName(userName);
} }
} }
// delete invite sites // delete invite sites
siteService.deleteSite(SITE_SHORT_NAME_INVITE_1); siteService.deleteSite(SITE_SHORT_NAME_INVITE_1);
siteService.deleteSite(SITE_SHORT_NAME_INVITE_2); siteService.deleteSite(SITE_SHORT_NAME_INVITE_2);
@@ -381,8 +381,8 @@ public class InviteServiceTest extends BaseWebScriptTest
public static String PERSON_LASTNAME = "LastName123"; public static String PERSON_LASTNAME = "LastName123";
public static String PERSON_JOBTITLE = "JobTitle123"; public static String PERSON_JOBTITLE = "JobTitle123";
public static String PERSON_ORG = "Organisation123"; public static String PERSON_ORG = "Organisation123";
private void createPerson(String firstName, String lastName, String userName, String emailAddress) private void createPerson(String firstName, String lastName, String userName, String emailAddress)
{ {
// if user with given user name doesn't already exist then create user // if user with given user name doesn't already exist then create user
@@ -450,11 +450,11 @@ public class InviteServiceTest extends BaseWebScriptTest
{ {
String inviteeEmail = INVITEE_EMAIL_PREFIX + RandomStringUtils.randomAlphanumeric(6) String inviteeEmail = INVITEE_EMAIL_PREFIX + RandomStringUtils.randomAlphanumeric(6)
+ "@" + INVITEE_EMAIL_DOMAIN; + "@" + INVITEE_EMAIL_DOMAIN;
return startInvite(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeSiteRole, siteShortName, return startInvite(inviteeFirstName, inviteeLastName, inviteeEmail, inviteeSiteRole, siteShortName,
expectedStatus); expectedStatus);
} }
private JSONObject cancelInvite(String inviteId, String siteShortName, int expectedStatus) throws Exception private JSONObject cancelInvite(String inviteId, String siteShortName, int expectedStatus) throws Exception
{ {
String cancelInviteUrl = URL_INVITE + "/" + INVITE_ACTION_CANCEL + "?inviteId=" + inviteId; String cancelInviteUrl = URL_INVITE + "/" + INVITE_ACTION_CANCEL + "?inviteId=" + inviteId;
@@ -465,10 +465,10 @@ public class InviteServiceTest extends BaseWebScriptTest
Response response = sendRequest(new GetRequest(cancelInviteUrl), expectedStatus); Response response = sendRequest(new GetRequest(cancelInviteUrl), expectedStatus);
; ;
JSONObject result = new JSONObject(response.getContentAsString()); JSONObject result = new JSONObject(response.getContentAsString());
return result; return result;
} }
private JSONObject rejectInvite(String inviteId, String inviteTicket, int expectedStatus) throws Exception private JSONObject rejectInvite(String inviteId, String inviteTicket, int expectedStatus) throws Exception
{ {
// Invitee rejects invitation to a Site from Inviter // Invitee rejects invitation to a Site from Inviter
@@ -553,16 +553,16 @@ public class InviteServiceTest extends BaseWebScriptTest
private JSONObject getInviteInfo(String inviteId, String inviteTicket, String inviteeUid) throws Exception private JSONObject getInviteInfo(String inviteId, String inviteTicket, String inviteeUid) throws Exception
{ {
String url = "/api/invite/" + inviteId + "/" + inviteTicket + "?inviteeUserName=" + inviteeUid; String url = "/api/invite/" + inviteId + "/" + inviteTicket + "?inviteeUserName=" + inviteeUid;
String runAsUser = AuthenticationUtil.getRunAsUser(); String runAsUser = AuthenticationUtil.getRunAsUser();
Response response = sendRequest(new GetRequest(url), Status.STATUS_OK); Response response = sendRequest(new GetRequest(url), Status.STATUS_OK);
if (!runAsUser.equals(AuthenticationUtil.getRunAsUser())) if (!runAsUser.equals(AuthenticationUtil.getRunAsUser()))
{ {
AuthenticationUtil.setRunAsUser(runAsUser); AuthenticationUtil.setRunAsUser(runAsUser);
} }
JSONObject result = new JSONObject(response.getContentAsString()); JSONObject result = new JSONObject(response.getContentAsString());
return result; return result;
@@ -581,20 +581,20 @@ public class InviteServiceTest extends BaseWebScriptTest
.get("inviteeEmail")); .get("inviteeEmail"));
assertEquals(SITE_SHORT_NAME_INVITE_1, result.get("siteShortName")); assertEquals(SITE_SHORT_NAME_INVITE_1, result.get("siteShortName"));
} }
public void testStartInviteWhenInviteeIsAlreadyMemberOfSite() public void testStartInviteWhenInviteeIsAlreadyMemberOfSite()
throws Exception throws Exception
{ {
// //
// add invitee as member of site: SITE_SHORT_NAME_INVITE // add invitee as member of site: SITE_SHORT_NAME_INVITE
// //
String randomStr = RandomStringUtils.randomNumeric(6); String randomStr = RandomStringUtils.randomNumeric(6);
final String inviteeUserName = "inviteeUserName" + randomStr; final String inviteeUserName = "inviteeUserName" + randomStr;
final String inviteeEmailAddr = INVITEE_EMAIL_PREFIX + randomStr final String inviteeEmailAddr = INVITEE_EMAIL_PREFIX + randomStr
+ "@" + INVITEE_EMAIL_DOMAIN; + "@" + INVITEE_EMAIL_DOMAIN;
// create person with invitee user name and invitee email address // create person with invitee user name and invitee email address
AuthenticationUtil.runAs(new RunAsWork<Object>() AuthenticationUtil.runAs(new RunAsWork<Object>()
{ {
public Object doWork() throws Exception public Object doWork() throws Exception
@@ -602,46 +602,46 @@ public class InviteServiceTest extends BaseWebScriptTest
createPerson(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeUserName, inviteeEmailAddr); createPerson(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeUserName, inviteeEmailAddr);
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
// add invitee person to site: SITE_SHORT_NAME_INVITE // add invitee person to site: SITE_SHORT_NAME_INVITE
AuthenticationUtil.runAs(new RunAsWork<Object>() AuthenticationUtil.runAs(new RunAsWork<Object>()
{ {
public Object doWork() throws Exception public Object doWork() throws Exception
{ {
InviteServiceTest.this.siteService.setMembership( InviteServiceTest.this.siteService.setMembership(
SITE_SHORT_NAME_INVITE_1, inviteeUserName, SITE_SHORT_NAME_INVITE_1, inviteeUserName,
INVITEE_SITE_ROLE); INVITEE_SITE_ROLE);
return null; return null;
} }
}, USER_INVITER); }, USER_INVITER);
/** /**
* Should conflict * Should conflict
*/ */
startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE, startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE,
SITE_SHORT_NAME_INVITE_1, Status.STATUS_CONFLICT); SITE_SHORT_NAME_INVITE_1, Status.STATUS_CONFLICT);
// Should go through // Should go through
startInvite(INVITEE_FIRSTNAME, "Belzebub", inviteeEmailAddr, INVITEE_SITE_ROLE, startInvite(INVITEE_FIRSTNAME, "Belzebub", inviteeEmailAddr, INVITEE_SITE_ROLE,
SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
// Should go through // Should go through
startInvite("Lucifer", INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE, startInvite("Lucifer", INVITEE_LASTNAME, inviteeEmailAddr, INVITEE_SITE_ROLE,
SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
} }
// public void testStartInviteWhenAlreadyInProgress() // public void testStartInviteWhenAlreadyInProgress()
// throws Exception // throws Exception
// { // {
// JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_SITE_ROLE, // JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_SITE_ROLE,
// SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); // SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
// //
// String inviteeEmail = (String) result.get("inviteeEmail"); // String inviteeEmail = (String) result.get("inviteeEmail");
// //
// startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE, // startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE,
// SITE_SHORT_NAME_INVITE_1, Status.STATUS_CONFLICT); // SITE_SHORT_NAME_INVITE_1, Status.STATUS_CONFLICT);
// } // }
@@ -694,10 +694,10 @@ public class InviteServiceTest extends BaseWebScriptTest
// Invitee accepts invitation to a Site from Inviter // Invitee accepts invitation to a Site from Inviter
String acceptInviteUrl = URL_INVITE + "/" + inviteId + "/" + inviteTicket + "/accept"; String acceptInviteUrl = URL_INVITE + "/" + inviteId + "/" + inviteTicket + "/accept";
sendRequest(new PutRequest(acceptInviteUrl, (byte[])null, null), Status.STATUS_OK); sendRequest(new PutRequest(acceptInviteUrl, (byte[])null, null), Status.STATUS_OK);
// Invitee attempts to accept the invitation again // Invitee attempts to accept the invitation again
sendRequest(new PutRequest(acceptInviteUrl, (byte[])null, null), Status.STATUS_CONFLICT); sendRequest(new PutRequest(acceptInviteUrl, (byte[])null, null), Status.STATUS_CONFLICT);
// Invitee attempts to reject an invitation that has already been accepted. // Invitee attempts to reject an invitation that has already been accepted.
rejectInvite(inviteId, inviteTicket, Status.STATUS_CONFLICT); rejectInvite(inviteId, inviteTicket, Status.STATUS_CONFLICT);
@@ -727,8 +727,8 @@ public class InviteServiceTest extends BaseWebScriptTest
String inviteTicket = result.getString("inviteTicket"); String inviteTicket = result.getString("inviteTicket");
rejectInvite(inviteId, inviteTicket, Status.STATUS_OK); rejectInvite(inviteId, inviteTicket, Status.STATUS_OK);
// Negative test // Negative test
rejectInvite(inviteId, inviteTicket, Status.STATUS_CONFLICT); rejectInvite(inviteId, inviteTicket, Status.STATUS_CONFLICT);
// //
@@ -742,21 +742,21 @@ public class InviteServiceTest extends BaseWebScriptTest
// 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(0, getInvitesResult.getJSONArray("invites").length()); // assertEquals(0, getInvitesResult.getJSONArray("invites").length());
} }
public void testGetInvitationStatus() throws Exception public void testGetInvitationStatus() throws Exception
{ {
for (String invitationStatus : new String[]{ for (String invitationStatus : new String[]{
InviteInfo.INVITATION_STATUS_REJECTED, InviteInfo.INVITATION_STATUS_REJECTED,
InviteInfo.INVITATION_STATUS_ACCEPTED InviteInfo.INVITATION_STATUS_ACCEPTED
}) })
{ {
// inviter starts invite (sends out invitation) // inviter starts invite (sends out invitation)
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_SITE_ROLE, JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, INVITEE_SITE_ROLE,
SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
String inviteId = result.getString("inviteId"); String inviteId = result.getString("inviteId");
String inviteTicket = result.getString("inviteTicket"); String inviteTicket = result.getString("inviteTicket");
String inviteeUserName = result.getString("inviteeUserName"); String inviteeUserName = result.getString("inviteeUserName");
@@ -783,7 +783,7 @@ public class InviteServiceTest extends BaseWebScriptTest
} }
// get inviteInfo about invitation // get inviteInfo about invitation
result = getInviteInfo(inviteId, inviteTicket, inviteeUserName); result = getInviteInfo(inviteId, inviteTicket, inviteeUserName);
status = result.getJSONObject("invite").getString("invitationStatus"); status = result.getJSONObject("invite").getString("invitationStatus");
// invitation status should be accepted/rejected // invitation status should be accepted/rejected
assertEquals(status, invitationStatus); assertEquals(status, invitationStatus);
@@ -805,7 +805,7 @@ public class InviteServiceTest extends BaseWebScriptTest
// get pending invite matching inviteId from invite started above // get pending invite matching inviteId from invite started above
JSONObject getInvitesResult = getInvitesByInviteId(inviteId, JSONObject getInvitesResult = getInvitesByInviteId(inviteId,
Status.STATUS_OK); Status.STATUS_OK);
assertEquals(getInvitesResult.getJSONArray("invites").length(), 1); assertEquals(getInvitesResult.getJSONArray("invites").length(), 1);
JSONObject inviteJSONObj = getInvitesResult.getJSONArray("invites").getJSONObject(0); JSONObject inviteJSONObj = getInvitesResult.getJSONArray("invites").getJSONObject(0);
@@ -879,7 +879,7 @@ public class InviteServiceTest extends BaseWebScriptTest
assertEquals(siteShortName, inviteJSONObj.getJSONObject("site").get("shortName")); assertEquals(siteShortName, inviteJSONObj.getJSONObject("site").get("shortName"));
} }
public void testStartInviteForbiddenWhenInviterNotSiteManager() throws Exception public void testStartInviteForbiddenWhenInviterNotSiteManager() throws Exception
{ {
// inviter2 starts invite workflow, but he/she is not the site manager of the given site // inviter2 starts invite workflow, but he/she is not the site manager of the given site
@@ -887,35 +887,35 @@ public class InviteServiceTest extends BaseWebScriptTest
startInvite(INVITEE_FIRSTNAME, startInvite(INVITEE_FIRSTNAME,
INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_3, Status.STATUS_FORBIDDEN); INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_3, Status.STATUS_FORBIDDEN);
} }
public void testCancelInviteForbiddenWhenInviterNotSiteManager() throws Exception public void testCancelInviteForbiddenWhenInviterNotSiteManager() throws Exception
{ {
// inviter (who is Site Manager of the given site) starts invite workflow // inviter (who is Site Manager of the given site) starts invite workflow
JSONObject result = startInvite(INVITEE_FIRSTNAME, JSONObject result = startInvite(INVITEE_FIRSTNAME,
INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_3, Status.STATUS_OK); INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_3, Status.STATUS_OK);
// get hold of invite ID of started invite // get hold of invite ID of started invite
String inviteId = result.getString("inviteId"); String inviteId = result.getString("inviteId");
// when inviter 2 (who is not Site Manager of the given site) tries to cancel invite // when inviter 2 (who is not Site Manager of the given site) tries to cancel invite
// http status FORBIDDEN must be returned // http status FORBIDDEN must be returned
AuthenticationUtil.setFullyAuthenticatedUser(USER_INVITER_2); AuthenticationUtil.setFullyAuthenticatedUser(USER_INVITER_2);
cancelInvite(inviteId, null, Status.STATUS_FORBIDDEN); cancelInvite(inviteId, null, Status.STATUS_FORBIDDEN);
} }
public void testInviteeResourcesDeletedUponRejectWhenNoInvitePending() throws Exception public void testInviteeResourcesDeletedUponRejectWhenNoInvitePending() throws Exception
{ {
// inviter starts invite workflow // inviter starts invite workflow
JSONObject result = startInvite(INVITEE_FIRSTNAME, JSONObject result = startInvite(INVITEE_FIRSTNAME,
INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); INVITEE_LASTNAME, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
// get hold of properties of started invite // get hold of properties of started invite
String inviteId = result.getString("inviteId"); String inviteId = result.getString("inviteId");
String inviteTicket = result.getString("inviteTicket"); String inviteTicket = result.getString("inviteTicket");
final String inviteeUserName = result.getString("inviteeUserName"); final String inviteeUserName = result.getString("inviteeUserName");
rejectInvite(inviteId, inviteTicket, Status.STATUS_OK); rejectInvite(inviteId, inviteTicket, Status.STATUS_OK);
AuthenticationUtil.runAs(new RunAsWork<Void>() AuthenticationUtil.runAs(new RunAsWork<Void>()
{ {
public Void doWork() throws Exception public Void doWork() throws Exception
@@ -932,16 +932,16 @@ public class InviteServiceTest extends BaseWebScriptTest
}); });
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
} }
public void testInviteeResourcesNotDeletedUponRejectWhenInvitesPending() throws Exception public void testInviteeResourcesNotDeletedUponRejectWhenInvitesPending() throws Exception
{ {
// Test only applies to legacy invite workflow // Test only applies to legacy invite workflow
this.invitationServiceImpl.setNominatedInvitationWorkflowId( this.invitationServiceImpl.setNominatedInvitationWorkflowId(
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE); WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_INVITE);
// Create invitee person // Create invitee person
final String inviteeEmail = INVITEE_EMAIL_PREFIX + RandomStringUtils.randomAlphanumeric(6) + "@" + INVITEE_EMAIL_DOMAIN; final String inviteeEmail = INVITEE_EMAIL_PREFIX + RandomStringUtils.randomAlphanumeric(6) + "@" + INVITEE_EMAIL_DOMAIN;
AuthenticationUtil.runAs(new RunAsWork<Object>() AuthenticationUtil.runAs(new RunAsWork<Object>()
@@ -952,20 +952,20 @@ public class InviteServiceTest extends BaseWebScriptTest
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
// inviter invites invitee to site 1 // inviter invites invitee to site 1
JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK); JSONObject result = startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, Status.STATUS_OK);
// get hold of properties of started invite // get hold of properties of started invite
String invite1Id = result.getString("inviteId"); String invite1Id = result.getString("inviteId");
String invite1Ticket = result.getString("inviteTicket"); String invite1Ticket = result.getString("inviteTicket");
final String inviteeUserName = result.getString("inviteeUserName"); final String inviteeUserName = result.getString("inviteeUserName");
// inviter invites invitee to site 2 // inviter invites invitee to site 2
startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_2, Status.STATUS_OK); startInvite(INVITEE_FIRSTNAME, INVITEE_LASTNAME, inviteeEmail, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_2, Status.STATUS_OK);
rejectInvite(invite1Id, invite1Ticket, Status.STATUS_OK); rejectInvite(invite1Id, invite1Ticket, Status.STATUS_OK);
boolean inviteeUserExists = AuthenticationUtil.runAs(new RunAsWork<Boolean>() boolean inviteeUserExists = AuthenticationUtil.runAs(new RunAsWork<Boolean>()
{ {
public Boolean doWork() throws Exception public Boolean doWork() throws Exception
@@ -978,32 +978,32 @@ public class InviteServiceTest extends BaseWebScriptTest
Boolean result = mutableAuthenticationDao.userExists(inviteeUserName); Boolean result = mutableAuthenticationDao.userExists(inviteeUserName);
return result; return result;
} }
}); });
return result; return result;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
// test that the invitee's user account still exists (has not been deleted // test that the invitee's user account still exists (has not been deleted
assertEquals(true, inviteeUserExists); assertEquals(true, inviteeUserExists);
boolean inviteePersonExists = AuthenticationUtil.runAs(new RunAsWork<Boolean>() boolean inviteePersonExists = AuthenticationUtil.runAs(new RunAsWork<Boolean>()
{ {
public Boolean doWork() throws Exception public Boolean doWork() throws Exception
{ {
Boolean result = personService.personExists(inviteeUserName); Boolean result = personService.personExists(inviteeUserName);
return result; return result;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
assertEquals(true, inviteePersonExists); assertEquals(true, inviteePersonExists);
// Reset back to default // Reset back to default
this.invitationServiceImpl.setNominatedInvitationWorkflowId( this.invitationServiceImpl.setNominatedInvitationWorkflowId(
WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT); WorkflowModelNominatedInvitation.WORKFLOW_DEFINITION_NAME_ACTIVITI_ADD_DIRECT);
} }
/** /**
* https://issues.alfresco.com/jira/browse/ETHREEOH-520 * https://issues.alfresco.com/jira/browse/ETHREEOH-520
*/ */
@@ -1012,8 +1012,8 @@ public class InviteServiceTest extends BaseWebScriptTest
{ {
final String userName = "userInviteServiceTest" + GUID.generate(); final String userName = "userInviteServiceTest" + GUID.generate();
final String emailAddress = " "; final String emailAddress = " ";
// Create a person with a blank email address and // Create a person with a blank email address and
AuthenticationUtil.runAs(new RunAsWork<Object>() AuthenticationUtil.runAs(new RunAsWork<Object>()
{ {
public Object doWork() throws Exception public Object doWork() throws Exception
@@ -1021,9 +1021,9 @@ public class InviteServiceTest extends BaseWebScriptTest
createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, userName, " "); createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, userName, " ");
return null; return null;
} }
}, AuthenticationUtil.getSystemUserName()); }, AuthenticationUtil.getSystemUserName());
// Try and add an existing person to the site with no email address // Try and add an existing person to the site with no email address
// Should return bad request since the email address has not been provided // Should return bad request since the email address has not been provided
startInvite(PERSON_FIRSTNAME, PERSON_LASTNAME, emailAddress, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, 400); startInvite(PERSON_FIRSTNAME, PERSON_LASTNAME, emailAddress, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, 400);
@@ -1091,7 +1091,7 @@ public class InviteServiceTest extends BaseWebScriptTest
} }
// MNT-14113: User admin console: sorting users causes some to disappear // MNT-14113: User admin console: sorting users causes some to disappear
// //
// It was decided to make the search results of AFTS (indexed) search to be the // It was decided to make the search results of AFTS (indexed) search to be the
// same as the CQ search results. Therefore, 'People.getPeople(String filter)' // same as the CQ search results. Therefore, 'People.getPeople(String filter)'
// transforms 'filter' to '*<filter>*' (adds leading wildcard). // transforms 'filter' to '*<filter>*' (adds leading wildcard).