mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merge branch 'feature/RM-4585_Amend_Test_Code_After_TAS_5202_Release' into 'master'
RM-4585 (DeclareDocumentAsRecordTests: use TAS Node API when available) See merge request !54
This commit is contained in:
@@ -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();
|
||||
|
@@ -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<FilePlanComponentEntry> filesAfterRename = filePlanComponentAPI.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
List<RestNodeModel> 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 "<original name> (<record Id>).<original extension>"
|
||||
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<SecondaryType> 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<FilePlanComponentEntry> filesAfterRename = getRestAPIFactory().getFilePlanComponentsAPI()
|
||||
.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
||||
.getEntries()
|
||||
.stream()
|
||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||
.collect(Collectors.toList());
|
||||
List<RestNodeModel> 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");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user