From 2a9aca2ced6fb869cc1652a29e1c051b877e17cf Mon Sep 17 00:00:00 2001 From: cagache Date: Tue, 23 Apr 2019 12:15:38 +0300 Subject: [PATCH] transform UserPermissions in enum; add helper methods to create users with rm role, permissions or clearance (cherry picked from commit ebc860ea2abaf17124cb033225c5c3728dbe85e4) # Conflicts: # rm-automation/rm-automation-enterprise-rest-api/src/test/java/org/alfresco/rest/rm/enterprise/v0/classification/content/SetRMExemptionReasonTest.java --- .../community/requests/gscore/api/FilesAPI.java | 6 ++++-- .../rest/rm/community/base/BaseRMRestTest.java | 16 ++++++++++++++++ .../rm/community/base/DataProviderClass.java | 2 +- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java index 18b91bd2cc..10da1e0570 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/gscore/api/FilesAPI.java @@ -57,8 +57,9 @@ public class FilesAPI extends RMModelRequest * @param fileId The Id of a file to declare as record * @param parameters Request parameters, refer to API documentation for more details * @return The {@link Record} for created record + * @throws Exception for malformed JSON responses */ - public Record declareAsRecord(String fileId, String parameters) + public Record declareAsRecord(String fileId, String parameters) throws Exception { mandatoryString("fileId", fileId); @@ -75,8 +76,9 @@ public class FilesAPI extends RMModelRequest * * @param fileId The Id of a file to declare as record * @return The {@link Record} for created record + * @throws Exception for malformed JSON responses */ - public Record declareAsRecord(String fileId) + public Record declareAsRecord(String fileId) throws Exception { mandatoryString("fileId", fileId); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index 48ec3e4cb6..86fc641882 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -616,6 +616,22 @@ public class BaseRMRestTest extends RestTest recordCategoryAPI.deleteRecordCategory(recordCategoryId); } + /** + * Assign permission on a record category and give the user RM role + * + * @param user the user to assign rm role and permissions + * @param categoryId the id of the category to assign permissions for + * @param userPermission the permissions to be assigned to the user + * @param userRole the rm role to be assigned to the user + */ + public void assignUserPermissionsOnCategoryAndRMRole(UserModel user, String categoryId, UserPermissions userPermission, + String userRole) + { + getRestAPIFactory().getRMUserAPI().addUserPermission(categoryId, user, userPermission); + rmRolesAndActionsAPI.assignRoleToUser(getAdminUser().getUsername(), getAdminUser().getPassword(), + user.getUsername(), userRole); + } + /** * Helper method to create a test user with rm role * diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java index b4b39f70b8..d437da677a 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/DataProviderClass.java @@ -105,7 +105,7 @@ public class DataProviderClass * @return file plan component alias */ @DataProvider - public static String[][] categoryTypes() + public static Object[][] categoryTypes() { return new String[][] { { FOLDER_TYPE },