RM-2120: Add error handling (and test) as suggested by Neil during + review RM-46

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@104157 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Webster
2015-05-14 10:58:19 +00:00
parent edb4c206c5
commit a9f57ea03b
2 changed files with 33 additions and 1 deletions

View File

@@ -117,4 +117,25 @@ public class UserSecurityClearancePutUnitTest extends BaseWebScriptUnitTest
// Execute web script - this should throw the expected exception.
executeJSONWebScript(parameters);
}
/**
* Test the Security Clearance webscript can't be called by a user with insufficient clearance
*
* @throws Exception
*/
@Test(expected = WebScriptException.class)
public void testIncorrectClearanceId() throws Exception
{
String username = "user1";
String clearanceId = "ThisClearanceDoesNotExist";
// Setup web script parameters
Map<String, String> parameters = buildParameters(USERNAME, username, CLEARANCE_ID, clearanceId);
when(mockSecurityClearanceService.setUserSecurityClearance(username, clearanceId)).thenThrow(
new ClassificationServiceException.LevelIdNotFound(clearanceId));
// Execute web script - this should throw the expected exception.
executeJSONWebScript(parameters);
}
}