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;
|
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.FilePlanComponentAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilesAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilesAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
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.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI;
|
||||||
import org.alfresco.utility.data.DataUser;
|
import org.alfresco.utility.data.DataUser;
|
||||||
|
import org.alfresco.utility.model.RepoTestModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
@@ -68,6 +71,22 @@ public class RestAPIFactory
|
|||||||
return getRmRestWrapper().withIGCoreAPI();
|
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()
|
public RMSiteAPI getRMSiteAPI()
|
||||||
{
|
{
|
||||||
return getRestIGCoreAPI(null).usingRMSite();
|
return getRestIGCoreAPI(null).usingRMSite();
|
||||||
|
@@ -39,6 +39,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.alfresco.dataprep.CMISUtil;
|
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.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentEntry;
|
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");
|
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
|
// 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<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||||
List<FilePlanComponentEntry> filesAfterRename = filePlanComponentAPI.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
.listChildren()
|
||||||
.getEntries()
|
.getEntries()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
assertEquals(filesAfterRename.size(), 1, "There should be only one file in folder " + testFolder.getName());
|
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>"
|
// verify the new name has the form of "<original name> (<record Id>).<original extension>"
|
||||||
assertEquals(filesAfterRename.get(0).getFilePlanComponentModel().getName(),
|
String recordName = filesAfterRename.get(0).onModel().getName();
|
||||||
document.getName().replace(".", String.format(" (%s).", record.getProperties().getRmIdentifier())));
|
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
|
// 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
|
// this also verifies the document is still in the initial folder
|
||||||
Document documentPostFiling = dataContent.usingSite(testSite)
|
Document documentPostFiling = dataContent.usingSite(testSite)
|
||||||
.usingUser(testUser)
|
.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
|
// a document is a record if "Record" is one of its secondary types
|
||||||
List<SecondaryType> documentSecondary = documentPostFiling.getSecondaryTypes()
|
List<SecondaryType> documentSecondary = documentPostFiling.getSecondaryTypes()
|
||||||
@@ -185,12 +186,11 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
|
|||||||
assertStatusCode(FORBIDDEN);
|
assertStatusCode(FORBIDDEN);
|
||||||
|
|
||||||
// verify the document is still in the original folder
|
// 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<RestNodeModel> filesAfterRename = getRestAPIFactory().getNodeAPI(testFolder)
|
||||||
List<FilePlanComponentEntry> filesAfterRename = getRestAPIFactory().getFilePlanComponentsAPI()
|
.listChildren()
|
||||||
.listChildComponents(testFolder.getNodeRefWithoutVersion())
|
|
||||||
.getEntries()
|
.getEntries()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(f -> f.getFilePlanComponentModel().getId().equals(document.getNodeRefWithoutVersion()))
|
.filter(f -> f.onModel().getId().equals(document.getNodeRefWithoutVersion()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
assertEquals(filesAfterRename.size(), 1, "Declare as record failed but original document is missing");
|
assertEquals(filesAfterRename.size(), 1, "Declare as record failed but original document is missing");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user