From c4fac4b0bdeefa5e4ce17b82cda65003ac854ead Mon Sep 17 00:00:00 2001 From: Tom Page Date: Thu, 9 Nov 2017 15:32:42 +0000 Subject: [PATCH] Refactor the delete items methods in REST API tests. --- .../org/alfresco/rest/core/v0/BaseAPI.java | 7 ++++--- .../alfresco/rest/v0/RMRolesAndActionsAPI.java | 6 +++--- .../alfresco/rest/v0/RecordCategoriesAPI.java | 18 +++++++++--------- .../java/org/alfresco/rest/v0/RecordsAPI.java | 13 +++++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java index 3f0f4c3920..3f5f0dbda8 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/v0/BaseAPI.java @@ -27,6 +27,7 @@ package org.alfresco.rest.core.v0; import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertNull; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -664,16 +665,16 @@ public abstract class BaseAPI * @param itemPath the path to the item eg. in case of a category it would be the "/" + category name, * in case of a folder or subCategory it would be /categoryName/folderName or /categoryName/subCategoryName/ * in case of a record /categoryName/folderName/recordName - * @return true if the deletion has been successful + * @throws AssertionError if the delete was not successful. */ - protected boolean deleteItem(String username, String password, String itemPath) + protected void deleteItem(String username, String password, String itemPath) { CmisObject container = getObjectByPath(username, password, FILE_PLAN_PATH + itemPath); if (container != null) { container.delete(); } - return getObjectByPath(username, password, itemPath) == null; + assertNull("Could not delete " + itemPath, getObjectByPath(username, password, itemPath)); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java index d5805a9a3b..c14888391e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RMRolesAndActionsAPI.java @@ -266,11 +266,11 @@ public class RMRolesAndActionsAPI extends BaseAPI * @param username user's username * @param password its password * @param holdName the hold name - * @return true if the delete is successful + * @throws AssertionError if the deletion was unsuccessful. */ - public boolean deleteHold(String username, String password, String holdName) + public void deleteHold(String username, String password, String holdName) { - return deleteItem(username, password, "/Holds/" + holdName); + deleteItem(username, password, "/Holds/" + holdName); } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index da327055e4..9b9e11398f 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -120,11 +120,11 @@ public class RecordCategoriesAPI extends BaseAPI * @param username user's username * @param password its password * @param categoryName the name of the category - * @return true if the delete is successful + * @throws AssertionError if the delete was unsuccessful. */ - public boolean deleteCategory(String username, String password, String categoryName) + public void deleteCategory(String username, String password, String categoryName) { - return deleteItem(username, password, "/" + categoryName); + deleteItem(username, password, "/" + categoryName); } /** @@ -133,11 +133,11 @@ public class RecordCategoriesAPI extends BaseAPI * @param username user's username * @param password its password * @param categoryName the name of the sub-category - * @return true if the delete is successful + * @throws AssertionError if the deletion was unsuccessful. */ - public boolean deleteSubCategory(String username, String password, String categoryName, String subCategoryName) + public void deleteSubCategory(String username, String password, String categoryName, String subCategoryName) { - return deleteItem(username, password, "/" + categoryName + "/" + subCategoryName); + deleteItem(username, password, "/" + categoryName + "/" + subCategoryName); } /** @@ -147,11 +147,11 @@ public class RecordCategoriesAPI extends BaseAPI * @param password its password * @param folderName folder name * @param containerName the name of the category or container sin which the folder is - * @return true if the delete is successful + * @throws AssertionError if the deletion was unsuccessful. */ - public boolean deleteFolderInContainer(String username, String password, String folderName, String containerName) + public void deleteFolderInContainer(String username, String password, String folderName, String containerName) { - return deleteItem(username, password, "/" + containerName + "/" + folderName); + deleteItem(username, password, "/" + containerName + "/" + folderName); } /** diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java index b212c414be..32ae42221e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java @@ -243,24 +243,25 @@ public class RecordsAPI extends BaseAPI /** * Delete a record from the given path - * + * * @param username user's username * @param password its password * @param recordName the record name * @param categoryName the name of the category in which the folder is, in case of unfiled record, this will have UNFILED_RECORDS_BREADCRUMB as container * @param folderName folder name, in case in which trying to delete a record in Unfiled records directly, this will be "" - * @return true if the delete is successful - * eg. of usage in the case in which the record is inside a folder in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "unfiled records folder"); - * eg. of usage in the case in which the record is created directly in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, ""); + * @throws AssertionError If the record could not be deleted. */ - public boolean deleteRecord(String username, String password, String recordName, String categoryName, String folderName) + public void deleteRecord(String username, String password, String recordName, String categoryName, String folderName) { String recordPath = "/" + categoryName; if (!folderName.equals("")) { recordPath = recordPath + "/" + folderName; } - return deleteItem(username, password, recordPath + "/" + recordName); + deleteItem(username, password, recordPath + "/" + recordName); } /**