mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Refactor assign user to RM role API test call.
This commit is contained in:
@@ -28,6 +28,7 @@ package org.alfresco.rest.v0;
|
|||||||
|
|
||||||
import static org.alfresco.dataprep.AlfrescoHttpClient.MIME_TYPE_JSON;
|
import static org.alfresco.dataprep.AlfrescoHttpClient.MIME_TYPE_JSON;
|
||||||
import static org.apache.http.HttpStatus.SC_OK;
|
import static org.apache.http.HttpStatus.SC_OK;
|
||||||
|
import static org.testng.AssertJUnit.assertEquals;
|
||||||
import static org.testng.AssertJUnit.assertNotNull;
|
import static org.testng.AssertJUnit.assertNotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -107,8 +108,10 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* assign user to records management role
|
* assign user to records management role
|
||||||
|
*
|
||||||
|
* @throws AssertionError if the assignation is unsuccessful.
|
||||||
*/
|
*/
|
||||||
public boolean assignUserToRole(String adminUser, String adminPassword, String userName, String role)
|
public void assignUserToRole(String adminUser, String adminPassword, String userName, String role)
|
||||||
{
|
{
|
||||||
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
|
||||||
String reqURL = MessageFormat.format(
|
String reqURL = MessageFormat.format(
|
||||||
@@ -119,20 +122,11 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
client.getAlfTicket(adminUser, adminPassword));
|
client.getAlfTicket(adminUser, adminPassword));
|
||||||
|
|
||||||
HttpPost request = null;
|
HttpPost request = null;
|
||||||
HttpResponse response = null;
|
HttpResponse response;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
request = new HttpPost(reqURL);
|
request = new HttpPost(reqURL);
|
||||||
response = client.execute(adminUser, adminPassword, request);
|
response = client.execute(adminUser, adminPassword, request);
|
||||||
switch (response.getStatusLine().getStatusCode())
|
|
||||||
{
|
|
||||||
case HttpStatus.SC_OK:
|
|
||||||
return true;
|
|
||||||
case HttpStatus.SC_CONFLICT:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -142,8 +136,8 @@ public class RMRolesAndActionsAPI extends BaseAPI
|
|||||||
}
|
}
|
||||||
client.close();
|
client.close();
|
||||||
}
|
}
|
||||||
|
assertEquals("Assigning user " + userName + " to role " + role + " failed.", SC_OK,
|
||||||
return false;
|
response.getStatusLine().getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user