Refactor the delete items methods in REST API tests.

This commit is contained in:
Tom Page
2017-11-09 15:32:42 +00:00
parent 80ed8c4e63
commit c4fac4b0bd
4 changed files with 23 additions and 21 deletions

View File

@@ -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));
}
/**

View File

@@ -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);
}

View File

@@ -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);
}
/**

View File

@@ -243,24 +243,25 @@ public class RecordsAPI extends BaseAPI
/**
* Delete a record from the given path
*
* <ul>
* <li>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");
* <li>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, "");
* </ul>
* @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);
}
/**