mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5416: REST API Tests for Folder Classification - removing the base class
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||||
@@ -34,6 +35,7 @@ import org.alfresco.rest.model.RestHtmlResponse;
|
|||||||
import org.alfresco.rest.model.RestSiteModel;
|
import org.alfresco.rest.model.RestSiteModel;
|
||||||
import org.alfresco.rest.model.RestSiteModelsCollection;
|
import org.alfresco.rest.model.RestSiteModelsCollection;
|
||||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
|
import org.alfresco.rest.requests.search.SearchAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||||
import org.alfresco.utility.model.StatusModel;
|
import org.alfresco.utility.model.StatusModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -145,16 +147,24 @@ public class RMRestWrapper
|
|||||||
return restWrapper.withCoreAPI();
|
return restWrapper.withCoreAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the Alfresco Search API. */
|
||||||
|
public SearchAPI withSearchAPI()
|
||||||
|
{
|
||||||
|
return restWrapper.withSearchAPI();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can handle the request sent to server by calling this method.
|
* You can handle the request sent to server by calling this method. If for example you want to sent multipart form
|
||||||
* If for example you want to sent multipart form data you can use: <pre>
|
* data you can use:
|
||||||
* restClient.configureRequestSpec()
|
*
|
||||||
* .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
* <pre>
|
||||||
* .addFormParam("renditions", "doclib")
|
* restClient.configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
|
||||||
* .addFormParam("autoRename", true);
|
* .addFormParam("renditions", "doclib").addFormParam("autoRename", true);
|
||||||
*
|
*
|
||||||
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
* restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
|
||||||
* </pre> This will create the node using the multipart data defined.
|
* </pre>
|
||||||
|
*
|
||||||
|
* This will create the node using the multipart data defined.
|
||||||
*/
|
*/
|
||||||
public RequestSpecBuilder configureRequestSpec()
|
public RequestSpecBuilder configureRequestSpec()
|
||||||
{
|
{
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.core;
|
package org.alfresco.rest.core;
|
||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
import static lombok.AccessLevel.PROTECTED;
|
||||||
@@ -32,6 +33,7 @@ import javax.annotation.Resource;
|
|||||||
|
|
||||||
import org.alfresco.rest.requests.Node;
|
import org.alfresco.rest.requests.Node;
|
||||||
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
import org.alfresco.rest.requests.coreAPI.RestCoreAPI;
|
||||||
|
import org.alfresco.rest.requests.search.SearchAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.GSCoreAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.FilesAPI;
|
||||||
@@ -85,6 +87,12 @@ public class RestAPIFactory
|
|||||||
return getRmRestWrapper().withCoreAPI();
|
return getRmRestWrapper().withCoreAPI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private SearchAPI getSearchAPI(UserModel userModel)
|
||||||
|
{
|
||||||
|
getRmRestWrapper().authenticateUser(userModel != null ? userModel : getDataUser().getAdminUser());
|
||||||
|
return getRmRestWrapper().withSearchAPI();
|
||||||
|
}
|
||||||
|
|
||||||
public Node getNodeAPI(RepoTestModel model) throws Exception
|
public Node getNodeAPI(RepoTestModel model) throws Exception
|
||||||
{
|
{
|
||||||
return getCoreAPI(null).usingNode(model);
|
return getCoreAPI(null).usingNode(model);
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.alfresco.rest.rm.community.base;
|
package org.alfresco.rest.rm.community.base;
|
||||||
|
|
||||||
import static lombok.AccessLevel.PROTECTED;
|
import static lombok.AccessLevel.PROTECTED;
|
||||||
@@ -40,15 +41,11 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_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.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.UserPermissions.PERMISSION_FILING;
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_ADMIN;
|
|
||||||
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
|
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel;
|
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.createRecordCategoryModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
|
||||||
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
|
|
||||||
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
@@ -136,15 +133,15 @@ public class BaseRMRestTest extends RestTest
|
|||||||
@DataProvider(name = "validRootContainers")
|
@DataProvider(name = "validRootContainers")
|
||||||
public String[][] getValidRootContainers() throws Exception
|
public String[][] getValidRootContainers() throws Exception
|
||||||
{
|
{
|
||||||
return new String[][]
|
return new String[][] {
|
||||||
{
|
|
||||||
// an arbitrary record folder
|
// an arbitrary record folder
|
||||||
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE },
|
{ createCategoryFolderInFilePlan().getId(), RECORD_FOLDER_TYPE },
|
||||||
// unfiled records root
|
// unfiled records root
|
||||||
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
|
{ UNFILED_RECORDS_CONTAINER_ALIAS, UNFILED_CONTAINER_TYPE },
|
||||||
// an arbitrary unfiled records folder
|
// an arbitrary unfiled records folder
|
||||||
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(), UNFILED_RECORD_FOLDER_TYPE }
|
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
|
||||||
};
|
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(),
|
||||||
|
UNFILED_RECORD_FOLDER_TYPE } };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -159,8 +156,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to create the RM Site via the POST request
|
* Helper method to create the RM Site via the POST request if the site doesn't exist
|
||||||
* if the site doesn't exist
|
|
||||||
*/
|
*/
|
||||||
public void createRMSiteIfNotExists() throws Exception
|
public void createRMSiteIfNotExists() throws Exception
|
||||||
{
|
{
|
||||||
@@ -224,10 +220,12 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created category
|
* @return The created category
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle) throws Exception
|
public RecordCategory createRootCategory(UserModel userModel, String categoryName, String categoryTitle)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
|
RecordCategory recordCategoryModel = createRecordCategoryModel(categoryName, categoryTitle);
|
||||||
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel, FILE_PLAN_ALIAS);
|
return getRestAPIFactory().getFilePlansAPI(userModel).createRootRecordCategory(recordCategoryModel,
|
||||||
|
FILE_PLAN_ALIAS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -240,10 +238,12 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created {@link RecordCategoryChild}
|
* @return The created {@link RecordCategoryChild}
|
||||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||||
*/
|
*/
|
||||||
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name, String type) throws Exception
|
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name,
|
||||||
|
String type) throws Exception
|
||||||
{
|
{
|
||||||
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
|
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
|
||||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel, recordCategoryId);
|
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel,
|
||||||
|
recordCategoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -255,7 +255,8 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created {@link RecordCategoryChild}
|
* @return The created {@link RecordCategoryChild}
|
||||||
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)}
|
||||||
*/
|
*/
|
||||||
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type) throws Exception
|
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type);
|
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type);
|
||||||
}
|
}
|
||||||
@@ -298,7 +299,8 @@ public class BaseRMRestTest extends RestTest
|
|||||||
public RecordCategoryChild createFolder(UserModel user, String recordCategoryId, String name) throws Exception
|
public RecordCategoryChild createFolder(UserModel user, String recordCategoryId, String name) throws Exception
|
||||||
{
|
{
|
||||||
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
|
RecordCategoryChild recordFolderModel = createRecordCategoryChildModel(name, RECORD_FOLDER_TYPE);
|
||||||
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel, recordCategoryId);
|
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordFolderModel,
|
||||||
|
recordCategoryId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -323,10 +325,12 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created folder
|
* @return The created folder
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName,
|
||||||
|
String nodeType) throws Exception
|
||||||
{
|
{
|
||||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||||
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(childModel, parentId);
|
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user)
|
||||||
|
.createUnfiledRecordFolderChild(childModel, parentId);
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
return child;
|
return child;
|
||||||
@@ -340,7 +344,8 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created folder
|
* @return The created folder
|
||||||
* @throws Exception on unsuccessful component creation
|
* @throws Exception on unsuccessful component creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType) throws Exception
|
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
|
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
|
||||||
}
|
}
|
||||||
@@ -355,14 +360,16 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created chid
|
* @return The created chid
|
||||||
* @throws Exception on unsuccessful child creation
|
* @throws Exception on unsuccessful child creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception
|
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName,
|
||||||
|
String nodeType) throws Exception
|
||||||
{
|
{
|
||||||
UnfiledContainerChild child = null;
|
UnfiledContainerChild child = null;
|
||||||
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
|
||||||
|
|
||||||
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
if (FilePlanComponentType.CONTENT_TYPE.equals(nodeType))
|
||||||
{
|
{
|
||||||
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
child = getRestAPIFactory().getUnfiledContainersAPI(user).uploadRecord(childModel, parentId,
|
||||||
|
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -382,7 +389,8 @@ public class BaseRMRestTest extends RestTest
|
|||||||
* @return The created chid
|
* @return The created chid
|
||||||
* @throws Exception on unsuccessful child creation
|
* @throws Exception on unsuccessful child creation
|
||||||
*/
|
*/
|
||||||
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType) throws Exception
|
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
|
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
|
||||||
}
|
}
|
||||||
@@ -397,11 +405,9 @@ public class BaseRMRestTest extends RestTest
|
|||||||
protected RecordFolder closeFolder(String folderId) throws Exception
|
protected RecordFolder closeFolder(String folderId) throws Exception
|
||||||
{
|
{
|
||||||
RecordFolder recordFolderModel = RecordFolder.builder()
|
RecordFolder recordFolderModel = RecordFolder.builder()
|
||||||
.properties(RecordFolderProperties.builder()
|
.properties(RecordFolderProperties.builder().isClosed(true).build()).build();
|
||||||
.isClosed(true)
|
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel,
|
||||||
.build())
|
folderId);
|
||||||
.build();
|
|
||||||
RecordFolder updateRecordFolder = getRestAPIFactory().getRecordFolderAPI().updateRecordFolder(recordFolderModel, folderId);
|
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
return updateRecordFolder;
|
return updateRecordFolder;
|
||||||
@@ -497,9 +503,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
*/
|
*/
|
||||||
public void deleteFolder(SiteModel siteModel, FolderModel folder)
|
public void deleteFolder(SiteModel siteModel, FolderModel folder)
|
||||||
{
|
{
|
||||||
contentService.deleteTree(getAdminUser().getUsername(),
|
contentService.deleteTree(getAdminUser().getUsername(), getAdminUser().getPassword(), siteModel.getId(),
|
||||||
getAdminUser().getPassword(),
|
|
||||||
siteModel.getId(),
|
|
||||||
folder.getName());
|
folder.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,10 +518,7 @@ public class BaseRMRestTest extends RestTest
|
|||||||
public Record createElectronicRecord(String parentId, String name) throws Exception
|
public Record createElectronicRecord(String parentId, String name) throws Exception
|
||||||
{
|
{
|
||||||
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
|
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI();
|
||||||
Record recordModel = Record.builder()
|
Record recordModel = Record.builder().name(name).nodeType(CONTENT_TYPE).build();
|
||||||
.name(name)
|
|
||||||
.nodeType(CONTENT_TYPE)
|
|
||||||
.build();
|
|
||||||
return recordFolderAPI.createRecord(recordModel, parentId);
|
return recordFolderAPI.createRecord(recordModel, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,4 +557,5 @@ public class BaseRMRestTest extends RestTest
|
|||||||
rmRolesAndActionsAPI.assignUserToRole(dataUser.getAdminUser().getUsername(),
|
rmRolesAndActionsAPI.assignUserToRole(dataUser.getAdminUser().getUsername(),
|
||||||
dataUser.getAdminUser().getPassword(), user.getUsername(), ROLE_RM_USER);
|
dataUser.getAdminUser().getPassword(), user.getUsername(), ROLE_RM_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user