diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java index 907bbe53ab..fd8882e7ba 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java @@ -26,6 +26,8 @@ */ package org.alfresco.rest.core; +import org.alfresco.rest.requests.Node; +import org.alfresco.rest.requests.coreAPI.RestCoreAPI; import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; import org.alfresco.rest.rm.community.requests.igCoreAPI.FilesAPI; import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI; @@ -33,6 +35,7 @@ import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI; import org.alfresco.rest.rm.community.requests.igCoreAPI.RecordsAPI; import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.RepoTestModel; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; @@ -68,6 +71,22 @@ public class RestAPIFactory return getRmRestWrapper().withIGCoreAPI(); } + private RestCoreAPI getRestCoreAPI(UserModel userModel) + { + getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser()); + return getRmRestWrapper().withCoreAPI(); + } + + public Node getNodeAPI(RepoTestModel model) throws Exception + { + return getRestCoreAPI(null).usingNode(model); + } + + public Node getNodeAPI(UserModel userModel, RepoTestModel model) throws Exception + { + return getRestCoreAPI(userModel).usingNode(model); + } + public RMSiteAPI getRMSiteAPI() { return getRestIGCoreAPI(null).usingRMSite(); @@ -97,7 +116,7 @@ public class RestAPIFactory { return getRestIGCoreAPI(userModel).usingRecords(); } - + public FilesAPI getFilesAPI() { return getRestIGCoreAPI(null).usingFiles(); @@ -107,12 +126,12 @@ public class RestAPIFactory { return getRestIGCoreAPI(userModel).usingFiles(); } - + public RMUserAPI getRMUserAPI() { return getRestIGCoreAPI(null).usingRMUser(); } - + public RMUserAPI getRMUserAPI(UserModel userModel) { return getRestIGCoreAPI(userModel).usingRMUser(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java index 681a703f14..6e50c8ed17 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareDocumentAsRecordTests.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.stream.Collectors; import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentEntry; @@ -125,23 +126,23 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest assertEquals(matchingRecords.size(), 1, "More than one record matching document name"); // verify the original file in collaboration site has been renamed to reflect the record identifier - // FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details. - List filesAfterRename = filePlanComponentAPI.listChildComponents(testFolder.getNodeRefWithoutVersion()) - .getEntries() - .stream() - .filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion())) - .collect(Collectors.toList()); + List filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder) + .listChildren() + .getEntries() + .stream() + .filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion())) + .collect(Collectors.toList()); assertEquals(filesAfterRename.size(), 1, "There should be only one file in folder " + testFolder.getName()); // verify the new name has the form of " ()." - assertEquals(filesAfterRename.get(0).getFilePlanComponentModel().getName(), - document.getName().replace(".", String.format(" (%s).", record.getProperties().getRmIdentifier()))); + String recordName = filesAfterRename.get(0).onModel().getName(); + assertEquals(recordName, document.getName().replace(".", String.format(" (%s).", record.getProperties().getRmIdentifier()))); // verify the document in collaboration site is now a record, note the file is now renamed hence folder + doc. name concatenation // this also verifies the document is still in the initial folder Document documentPostFiling = dataContent.usingSite(testSite) .usingUser(testUser) - .getCMISDocument(testFolder.getCmisLocation() + "/" + filesAfterRename.get(0).getFilePlanComponentModel().getName()); + .getCMISDocument(testFolder.getCmisLocation() + "/" + recordName); // a document is a record if "Record" is one of its secondary types List documentSecondary = documentPostFiling.getSecondaryTypes() @@ -185,13 +186,12 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest assertStatusCode(FORBIDDEN); // verify the document is still in the original folder - // FIXME: this call uses the FilePlanComponentAPI due to no TAS support for Node API in TAS restapi v 5.2.0-0. See RM-4585 for details. - List filesAfterRename = getRestAPIFactory().getFilePlanComponentsAPI() - .listChildComponents(testFolder.getNodeRefWithoutVersion()) - .getEntries() - .stream() - .filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion())) - .collect(Collectors.toList()); + List filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder) + .listChildren() + .getEntries() + .stream() + .filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion())) + .collect(Collectors.toList()); assertEquals(filesAfterRename.size(), 1, "Declare as record failed but original document is missing"); }