From 9c76930fead6a6300fa6063abd7921cae1a8a650 Mon Sep 17 00:00:00 2001 From: jcule Date: Fri, 6 Oct 2017 09:22:13 +0100 Subject: [PATCH 1/2] RM-5645: Automate AC Prevent Classification Beyond Parents Classification: added checks for response code and message --- .../rm/community/base/BaseRMRestTest.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) 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 124df6907a..5f1fa8ec22 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 @@ -39,8 +39,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; -import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; -import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; @@ -80,6 +78,7 @@ import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.testng.annotations.BeforeClass; @@ -615,4 +614,26 @@ public class BaseRMRestTest extends RestTest } return names; } + + /** + * Helper method to check the response code and message returned + * + * @param setClassificationResponse + * @param nodeId + */ + public List getResponseCodeAndMessage(JSONObject setClassificationResponse, String nodeId) + { + List response = new ArrayList(); + if (setClassificationResponse != null) + { + String message = setClassificationResponse.getString("message"); + response.add(message); + if (setClassificationResponse.getJSONObject("status") != null) + { + String code = setClassificationResponse.getJSONObject("status").get("code").toString(); + response.add(code); + } + } + return response; + } } From 8ff0a2495225babe7eab0f6cf308c558183c5b9b Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Mon, 9 Oct 2017 16:53:10 +0300 Subject: [PATCH 2/2] RM-5645 - review changes --- .../rm/community/base/BaseRMRestTest.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) 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 5f1fa8ec22..a7fdd272d1 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 @@ -53,6 +53,7 @@ import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.List; +import javafx.util.Pair; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestAPIFactory; @@ -70,6 +71,7 @@ import org.alfresco.rest.rm.community.requests.gscore.api.RMSiteAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI; +import org.alfresco.rest.rm.community.util.ParameterCheck; import org.alfresco.rest.search.RestRequestQueryModel; import org.alfresco.rest.search.SearchNodeModel; import org.alfresco.rest.search.SearchRequest; @@ -616,24 +618,18 @@ public class BaseRMRestTest extends RestTest } /** - * Helper method to check the response code and message returned - * + * Helper method to get the error response code and message from the provided setClassificationResponse + * * @param setClassificationResponse - * @param nodeId + * @return a pair of representing the code and message from the response */ - public List getResponseCodeAndMessage(JSONObject setClassificationResponse, String nodeId) + public Pair parseErrorResponse(JSONObject setClassificationResponse) { - List response = new ArrayList(); - if (setClassificationResponse != null) - { - String message = setClassificationResponse.getString("message"); - response.add(message); - if (setClassificationResponse.getJSONObject("status") != null) - { - String code = setClassificationResponse.getJSONObject("status").get("code").toString(); - response.add(code); - } - } - return response; + ParameterCheck.mandatoryObject("setClassificationResponse", setClassificationResponse); + + String message = setClassificationResponse.getString("message"); + String code = setClassificationResponse.getJSONObject("status").get("code").toString(); + + return new Pair<>(Integer.valueOf(code), message); } }