mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merge remote-tracking branch 'origin/feature/APPS-1722' into feature/APPS-1722
This commit is contained in:
@@ -32,6 +32,7 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
|
||||||
import org.alfresco.rest.rm.community.smoke.CreateCategoriesTests;
|
import org.alfresco.rest.rm.community.smoke.CreateCategoriesTests;
|
||||||
@@ -102,6 +103,10 @@ public class CopyToRuleOnFoldersTest extends BaseRMRestTest {
|
|||||||
getRestAPIFactory().getNodeAPI(toContentModel( nonElectronicRecord)).move(createBodyForMoveCopy(folder2));
|
getRestAPIFactory().getNodeAPI(toContentModel( nonElectronicRecord)).move(createBodyForMoveCopy(folder2));
|
||||||
|
|
||||||
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||||
|
// Delete the record category
|
||||||
|
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
|
||||||
|
String recordCategoryId = category.getId();
|
||||||
|
recordCategoryAPI.deleteRecordCategory(recordCategoryId);
|
||||||
recordsAPI.deleteRecord(electronicRecord);
|
recordsAPI.deleteRecord(electronicRecord);
|
||||||
recordsAPI.deleteRecord(nonElectronicRecord);
|
recordsAPI.deleteRecord(nonElectronicRecord);
|
||||||
assertStatusCode(NO_CONTENT);
|
assertStatusCode(NO_CONTENT);
|
||||||
|
@@ -33,16 +33,15 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||||
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||||
|
|
||||||
import org.alfresco.utility.model.FileModel;
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
import org.alfresco.utility.model.*;
|
||||||
|
|
||||||
import org.alfresco.rest.v0.RulesAPI;
|
import org.alfresco.rest.v0.RulesAPI;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
@@ -50,15 +49,19 @@ import org.testng.annotations.BeforeClass;
|
|||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
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.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
|
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
|
||||||
@AlfrescoTest (jira = "APPS-36")
|
@AlfrescoTest (jira = "APPS-36")
|
||||||
public class FileAsRecordRuleTests extends BaseRMRestTest
|
public class FileAsRecordRuleTests extends BaseRMRestTest
|
||||||
@@ -100,7 +103,6 @@ public class FileAsRecordRuleTests extends BaseRMRestTest
|
|||||||
STEP("Create a collaboration site");
|
STEP("Create a collaboration site");
|
||||||
publicSite = dataSite.usingUser(nonRMUser).createPublicRandomSite();
|
publicSite = dataSite.usingUser(nonRMUser).createPublicRandomSite();
|
||||||
|
|
||||||
|
|
||||||
STEP("Create two categories with two folders");
|
STEP("Create two categories with two folders");
|
||||||
category_manager = createRootCategory(CATEGORY_MANAGER);
|
category_manager = createRootCategory(CATEGORY_MANAGER);
|
||||||
category_admin = createRootCategory(CATEGORY_ADMIN);
|
category_admin = createRootCategory(CATEGORY_ADMIN);
|
||||||
@@ -120,6 +122,8 @@ public class FileAsRecordRuleTests extends BaseRMRestTest
|
|||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||||
|
|
||||||
|
assertStatusCode(CREATED);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Given I am a user that can create a rule on a folder in a collaboration site
|
* Given I am a user that can create a rule on a folder in a collaboration site
|
||||||
@@ -150,6 +154,8 @@ public class FileAsRecordRuleTests extends BaseRMRestTest
|
|||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||||
|
|
||||||
|
assertStatusCode(CREATED);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Given I am configuring a "Declare and File as Record" action within a rule
|
* Given I am configuring a "Declare and File as Record" action within a rule
|
||||||
@@ -173,39 +179,14 @@ public class FileAsRecordRuleTests extends BaseRMRestTest
|
|||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Given a record folder location has been selected for a "Declare and File as Record" action within a rule
|
|
||||||
* And I have permissions and capabilities to file to that record folder
|
|
||||||
* When I trigger the rule
|
|
||||||
* Then the file is filed directly to the selected record folder from the file plan
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
assertStatusCode(CREATED);
|
||||||
public void triggerDeclareToRecordFolderRuleAsUserWithPermissions()
|
|
||||||
{
|
|
||||||
STEP("Create as rmManager a new file into the folderWithRule in order to trigger the rule");
|
|
||||||
FileModel testFile = dataContent.usingUser(rmManager).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given a record folder location has been selected for a "Declare and File as Record" action within a rule
|
|
||||||
* And I don't have permissions and capabilities to file to that record folder
|
|
||||||
* When I trigger the rule
|
|
||||||
* Then the file is not declared as record
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void triggerDeclareToRecordFolderRuleAsUserWithoutPermissions()
|
|
||||||
{
|
|
||||||
STEP("Create as nonRMuser a new file into the folderWithRule in order to trigger the rule");
|
|
||||||
FileModel testFile = dataContent.usingUser(nonRMUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Given I have not selected a record folder location
|
* Given I have not selected a record folder location
|
||||||
* When the rule is triggered
|
* When the rule is triggered
|
||||||
* Then the file is declared as record to the Unfiled Records folder
|
* Then the file is declared as record to the UnFiled Records folder
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void triggerDeclareToUnfiledRuleAsNonRMUser()
|
public void triggerDeclareToUnfiledRuleAsNonRMUser()
|
||||||
@@ -214,14 +195,25 @@ public class FileAsRecordRuleTests extends BaseRMRestTest
|
|||||||
|
|
||||||
RecordCategory recordCategory = new RecordCategory().builder()
|
RecordCategory recordCategory = new RecordCategory().builder()
|
||||||
.id(category_manager.getId()).build();
|
.id(category_manager.getId()).build();
|
||||||
|
|
||||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||||
|
|
||||||
STEP("Create as nonRMuser a new file into the previous folder in order to trigger the rule");
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
STEP("Create as nonRMUser a new file into the previous folder in order to trigger the rule");
|
||||||
inPlaceRecord = dataContent.usingUser(nonRMUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
inPlaceRecord = dataContent.usingUser(nonRMUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||||
|
|
||||||
|
// Verify that declared record is in Unfilled Records Folder
|
||||||
|
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||||
|
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||||
|
.getEntries()
|
||||||
|
.stream()
|
||||||
|
.filter(e -> e.getEntry().getId().equals(inPlaceRecord.getNodeRefWithoutVersion()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
|
@@ -32,32 +32,36 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
|||||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
|
||||||
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
import org.alfresco.rest.rm.community.model.rules.ActionsOnRule;
|
||||||
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
import org.alfresco.rest.rm.community.model.rules.RuleDefinition;
|
||||||
|
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildEntry;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||||
|
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
|
||||||
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
import org.alfresco.rest.rm.community.smoke.FileAsRecordTests;
|
||||||
import org.alfresco.rest.v0.RulesAPI;
|
import org.alfresco.rest.v0.RulesAPI;
|
||||||
import org.alfresco.rest.v0.service.RoleService;
|
import org.alfresco.rest.v0.service.RoleService;
|
||||||
import org.alfresco.utility.model.FileModel;
|
import org.alfresco.utility.model.*;
|
||||||
import org.alfresco.utility.model.FolderModel;
|
|
||||||
import org.alfresco.utility.model.SiteModel;
|
|
||||||
import org.alfresco.utility.model.UserModel;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.testng.Assert;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
||||||
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.util.CommonTestUtils.generateTestPrefix;
|
import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||||
import static org.alfresco.utility.report.log.Step.STEP;
|
import static org.alfresco.utility.report.log.Step.STEP;
|
||||||
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
||||||
|
|
||||||
private UserModel nonRMuser, rmManager;
|
private UserModel nonRMuser, rmManager;
|
||||||
private SiteModel publicSite;
|
|
||||||
private RecordCategory category_manager, category_admin;
|
private RecordCategory category_manager, category_admin;
|
||||||
private RecordCategoryChild folder_admin, folder_manager ;
|
private RecordCategoryChild folder_admin, folder_manager ;
|
||||||
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
private static final String CATEGORY_MANAGER = "catManager" + generateTestPrefix(FileAsRecordTests.class);
|
||||||
@@ -65,7 +69,7 @@ public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
|||||||
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
private static final String FOLDER_MANAGER = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||||
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
private static final String FOLDER_ADMIN = "recordFolder" + generateTestPrefix(FileAsRecordTests.class);
|
||||||
private FolderModel testFolder;
|
private FolderModel testFolder;
|
||||||
private FileModel document, documentDeclared,inPlaceRecord;
|
private FileModel document,inPlaceRecord;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -115,6 +119,7 @@ public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
|||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
||||||
|
|
||||||
|
assertStatusCode(CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -133,12 +138,9 @@ public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
|||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(rmManager.getUsername(), rmManager.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,48 +156,48 @@ public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
|||||||
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
STEP("Create a rule with Declare as Record action and check that user can select a record folder.");
|
||||||
RecordCategory recordCategory = new RecordCategory().builder()
|
RecordCategory recordCategory = new RecordCategory().builder()
|
||||||
.id(category_manager.getId()).build();
|
.id(category_manager.getId()).build();
|
||||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + testFolder.getNodeRef(), ruleDefinition);
|
||||||
|
|
||||||
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void triggerFileVersionToRecordFolderRuleAsUserWithPermissions()
|
public void triggerDeclareToUnfiledRuleAsNonRMUser() throws Exception {
|
||||||
{
|
|
||||||
|
|
||||||
STEP("Create as rmManager a new file into the folderWithRule in order to trigger the rule");
|
|
||||||
FileModel testFile = dataContent.usingUser(rmManager).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void triggerFileVersionToRecordFolderRuleAsUserWithoutPermissions()
|
|
||||||
{
|
|
||||||
|
|
||||||
STEP("Create as nonRMuser a new file into the folderWithRule in order to trigger the rule");
|
|
||||||
FileModel testFile = dataContent.usingUser(nonRMuser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void triggerDeclareToUnfiledRuleAsNonRMUser()
|
|
||||||
{
|
|
||||||
|
|
||||||
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
STEP("Create a collaboration folder with a rule set to declare and file as record without a record folder location");
|
||||||
|
|
||||||
|
|
||||||
|
FileModel inplaceRecord = dataContent.usingSite(testSite).usingUser(nonRMuser)
|
||||||
|
.createContent(new FileModel("declareAndFileToIntoUnfiledRecordFolder",
|
||||||
|
FileType.TEXT_PLAIN));
|
||||||
|
|
||||||
RecordCategory recordCategory = new RecordCategory().builder()
|
RecordCategory recordCategory = new RecordCategory().builder()
|
||||||
.id(category_manager.getId()).build();
|
.id(category_manager.getId()).build();
|
||||||
RecordCategoryChild folderWithRule = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
|
|
||||||
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description")
|
||||||
.applyToChildren(true)
|
.applyToChildren(true)
|
||||||
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
.actions(Collections.singletonList(ActionsOnRule.DECLARE_AS_RECORD.getActionValue()));
|
||||||
rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX + folderWithRule.getId(), ruleDefinition);
|
rulesAPI.createRule(nonRMuser.getUsername(), nonRMuser.getPassword(), NODE_PREFIX + inplaceRecord.getNodeRef(), ruleDefinition);
|
||||||
|
|
||||||
STEP("Create as nonRMuser a new file into the previous folder in order to trigger the rule");
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
|
STEP("Create as nonRMuser a new file into the previous folder in order to trigger the rule");
|
||||||
inPlaceRecord = dataContent.usingUser(nonRMuser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
inPlaceRecord = dataContent.usingUser(nonRMuser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||||
|
|
||||||
|
// verify the declared record is in Unfilled Records folder
|
||||||
|
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
|
||||||
|
List<UnfiledContainerChildEntry> matchingRecords = unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||||
|
.getEntries()
|
||||||
|
.stream()
|
||||||
|
.filter(e -> e.getEntry().getId().equals(inplaceRecord.getNodeRefWithoutVersion()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
@@ -209,10 +211,10 @@ public class FileVersionAsRecordRuleTest extends BaseRMRestTest {
|
|||||||
dataUser.deleteUser(nonRMuser);
|
dataUser.deleteUser(nonRMuser);
|
||||||
dataUser.deleteUser(rmManager);
|
dataUser.deleteUser(rmManager);
|
||||||
|
|
||||||
|
|
||||||
STEP("Delete categories");
|
STEP("Delete categories");
|
||||||
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
|
||||||
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
|
||||||
getRestAPIFactory().getRecordsAPI().deleteRecord(inPlaceRecord.getNodeRefWithoutVersion());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user