+ * @author Kristijan Conkas + * @since 2.6 + */ +public class DeleteRecordTests extends BaseRestTest +{ + @Autowired + private FilePlanComponentAPI filePlanComponentAPI; + + @Autowired + private RMUserAPI rmUserAPI; + + @Autowired + private DataUser dataUser; + + @Autowired + private RMSiteAPI rmSiteAPI; + + /** image resource file to be used for records body */ + private static final String IMAGE_FILE = "money.JPG"; + + /** + *
+ * Given a record + * And that I have the "Delete Record" capability + * And write permissions + * When I delete the record + * Then it is deleted from the file plan + *+ * + * @param container + * @throws Exception + */ + @Test + ( + dataProvider = "validRootContainers", + description = "Admin user can delete an electronic record" + ) + @AlfrescoTest(jira="RM-4363") + public void adminCanDeleteElectronicRecord(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // create an electronic record + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(CONTENT_TYPE.toString()) + .build(); + FilePlanComponent newRecord = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + deleteAndVerify(newRecord); + } + + /** + *
+ * Given a record + * And that I have the "Delete Record" capability + * And write permissions + * When I delete the record + * Then it is deleted from the file plan + *+ * + * @param container + * @throws Exception + */ + @Test + ( + dataProvider = "validRootContainers", + description = "Admin user can delete a non-electronic record" + ) + @AlfrescoTest(jira="RM-4363") + public void adminCanDeleteNonElectronicRecord(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // create a non-electronic record + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); + FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( + record, + container.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + deleteAndVerify(newRecord); + } + + /** + *
+ * Given a record + * And that I don't have write permissions + * When I try to delete the record + * Then nothing happens + * And error gets reported + *+ * + * @param container + * @throws Exception + */ + @Test + ( + description = "User without write permissions can't delete a record" + ) + @AlfrescoTest(jira="RM-4363") + public void userWithoutWritePermissionsCantDeleteRecord() throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // create a non-electronic record in unfiled records + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); + FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( + record, + UNFILED_RECORDS_CONTAINER_ALIAS.toString()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // create test user and add it with collab. privileges + UserModel deleteUser = dataUser.createRandomTestUser("delnoperm"); + deleteUser.setUserRole(UserRole.SiteCollaborator); + logger.info("test user: " + deleteUser.getUsername()); + dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator); + + // add RM role to user + rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER); + rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // log in as deleteUser + filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser); + + // try to delete newRecord + filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + } + + /** + *
+ * Given a record + * And that I don't have the "Delete Record" capability + * When I try to delete the record + * Then nothing happens + * And error gets reported + *+ * + * @param container + * @throws Exception + */ + @Test + ( + description = "User without delete records capability can't delete a record" + ) + @AlfrescoTest(jira="RM-4363") + public void userWithoutDeleteRecordsCapabilityCantDeleteRecord() throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // create test user and add it with collab. privileges + UserModel deleteUser = dataUser.createRandomTestUser("delnoperm"); + deleteUser.setUserRole(UserRole.SiteCollaborator); + dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator); + logger.info("test user: " + deleteUser.getUsername()); + + // add RM role to user, RM Power User doesn't have the Delete Record capabilities + rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER); + rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // create random folder + FilePlanComponent randomFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()); + logger.info("random folder:" + randomFolder.getName()); + + // grant deleteUser Filing privileges on randomFolder category, this will be + // inherited to randomFolder + addUserPermission(filePlanComponentAPI.getFilePlanComponent(randomFolder.getParentId()), + deleteUser, UserPermissions.PERMISSION_FILING); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // create a non-electronic record in randomFolder + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); + FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( + record, + randomFolder.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // log in as deleteUser + filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser); + + // verify the user can see the newRecord + filePlanComponentAPI.getFilePlanComponent(newRecord.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // try to delete newRecord + filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + } + + /** + * Utility method to delete a record and verify successful deletion + * @param record + * @throws Exception + */ + private void deleteAndVerify(FilePlanComponent record) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // delete it and verify status + filePlanComponentAPI.deleteFilePlanComponent(record.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NO_CONTENT); + + // try to get deleted file plan component + filePlanComponentAPI.getFilePlanComponent(record.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND); + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java index 2b30770dc8..34312c3c3c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java @@ -41,7 +41,6 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; import org.alfresco.utility.data.DataUser; import org.springframework.beans.factory.annotation.Autowired; @@ -64,16 +63,16 @@ public class ElectronicRecordTests extends BaseRestTest @Autowired private DataUser dataUser; - + /** image resource file to be used for records body */ private static final String IMAGE_FILE = "money.JPG"; - + /** Valid root containers where electronic records can be created */ @DataProvider(name = "invalidParentContainers") public Object[][] invalidContainers() throws Exception { return new Object[][] { // record category - { getFilePlanComponentAsUser(dataUser.getAdminUser(), + { getFilePlanComponentAsUser(dataUser.getAdminUser(), createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) }, // file plan root { getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, @@ -83,7 +82,7 @@ public class ElectronicRecordTests extends BaseRestTest { getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) }, }; } - + /** *
* Given a parent container that is NOT a record folder or an unfiled record folder @@ -103,10 +102,13 @@ public class ElectronicRecordTests extends BaseRestTest { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), - new FilePlanComponentProperties()); + // Build object the filePlan + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(CONTENT_TYPE.toString()) + .build(); filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()); - + // verify the create request status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } @@ -114,7 +116,7 @@ public class ElectronicRecordTests extends BaseRestTest /** ** Given a parent container that is a record folder - * And the record folder is closed + * And the record folder is closed * When I try to create an electronic record within the parent container * Then nothing happens * And an error is reported @@ -126,22 +128,24 @@ public class ElectronicRecordTests extends BaseRestTest { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()); - + // the folder should be open assertFalse(recordFolder.getProperties().getIsClosed()); - + // close the folder closeFolder(recordFolder.getId()); - + // try to create it, this should fail - FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), - new FilePlanComponentProperties()); + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(CONTENT_TYPE.toString()) + .build(); filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, recordFolder.getId()); - + // verify the status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } - + /** ** Given a parent container that is a record folder @@ -164,13 +168,13 @@ public class ElectronicRecordTests extends BaseRestTest */ @Test ( - dataProvider = "validRootContainers", + dataProvider = "validRootContainers", description = "Electronic record can only be created if all mandatory properties are given" ) public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponent container) throws Exception { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - + logger.info("Root container:\n" + toJson(container)); if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString())) { @@ -179,17 +183,17 @@ public class ElectronicRecordTests extends BaseRestTest } // component without name - FilePlanComponent record = new FilePlanComponent(); - record.setNodeType(CONTENT_TYPE.toString()); - record.setProperties(new FilePlanComponentProperties()); - + FilePlanComponent record = FilePlanComponent.builder() + .nodeType(CONTENT_TYPE.toString()) + .build(); + // try to create it filePlanComponentAPI.createFilePlanComponent(record, container.getId()); // verify the status code is BAD_REQUEST - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST); } - + /** ** Given a parent container that is a record folder @@ -216,13 +220,47 @@ public class ElectronicRecordTests extends BaseRestTest { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), - new FilePlanComponentProperties()); + FilePlanComponent record = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(CONTENT_TYPE.toString()) + .build(); String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); - + // verify the create request status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); - + + // get newly created electonic record and verify its properties + FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); + // created record will have record identifier inserted in its name but will be prefixed with + // the name it was created as + assertTrue(electronicRecord.getName().startsWith(record.getName())); + } + + /** + * This test verified that in the test client implementation if record name isn't specified it + * defaults to filed file name. + * @param container valid record container + * @throws Exception if record creation failed + */ + @Test + ( + dataProvider = "validRootContainers", + description = "Electronic records can be created in unfiled record folder or unfiled record root" + ) + public void recordNameDerivedFromFileName(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // record object without name set + FilePlanComponent record = FilePlanComponent.builder() + .nodeType(CONTENT_TYPE.toString()) + .build(); + + String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); + + // verify the create request status code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // get newly created electonic record and verify its properties FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); // record will have record identifier inserted in its name but will for sure start with file name diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java index d0b6be85b2..9280b306db 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java @@ -199,9 +199,12 @@ public class FilePlanTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); // Build object for updating the filePlan - FilePlanComponent filePlanComponent = new FilePlanComponent(); - FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION); - filePlanComponent.setProperties(filePlanComponentProperties); + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .properties(FilePlanComponentProperties.builder() + .title(FILE_PLAN_TITLE) + .description(FILE_PLAN_DESCRIPTION) + .build()) + .build(); // Update the record category FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString()); @@ -301,7 +304,12 @@ public class FilePlanTests extends BaseRestTest String name = filePlanAlias + getRandomAlphanumeric(); // Build the file plan root properties - FilePlanComponent filePlanComponent = new FilePlanComponent(name,rmType.toString(),new FilePlanComponentProperties()); + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .name(name) + .nodeType(rmType.toString()) + .properties(FilePlanComponentProperties.builder() + .build()) + .build(); // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java index c8cc153545..968edbe9dd 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java @@ -70,10 +70,10 @@ public class NonElectronicRecordTests extends BaseRestTest @Autowired private DataUser dataUser; - + @Autowired private RMSiteAPI rmSiteAPI; - + /** ** Given a parent container that is NOT a record folder or an unfiled record folder @@ -87,24 +87,25 @@ public class NonElectronicRecordTests extends BaseRestTest public void cantCreateForInvalidParentIds() throws Exception { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - + // non-electronic record object to be used for create tests - FilePlanComponent nonElectronicRecord = new FilePlanComponent( - "Record " + getRandomAlphanumeric(), - NON_ELECTRONIC_RECORD_TYPE.toString(), - new FilePlanComponentProperties()); - + FilePlanComponent nonElectronicRecord = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); + // create record category, non-electronic records can't be its children - FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent( - new FilePlanComponent("Category " + getRandomAlphanumeric(), - RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties()), - FILE_PLAN_ALIAS.toString()); - + FilePlanComponent recordCategoryModel = FilePlanComponent.builder() + .name("Category " + getRandomAlphanumeric()) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .build(); + + FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS.toString()); + // iterate through all invalid parent containers and try to create/file an electronic record asList(FILE_PLAN_ALIAS.toString(), TRANSFERS_ALIAS.toString(), HOLDS_ALIAS.toString(), recordCategory.getId()) .stream() - .forEach(id -> + .forEach(id -> { try { @@ -118,7 +119,7 @@ public class NonElectronicRecordTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); }); } - + /** ** Given a parent container that is a record folder @@ -144,14 +145,14 @@ public class NonElectronicRecordTests extends BaseRestTest public void canCreateInValidContainers(FilePlanComponent container) throws Exception { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - + logger.info("Root container:\n" + toJson(container)); if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString())) { // only record folders can be open or closed assertFalse(container.getProperties().getIsClosed()); } - + // use these properties for non-electronic record to be created String title = "Title " + getRandomAlphanumeric(); String description = "Description " + getRandomAlphanumeric(); @@ -159,33 +160,38 @@ public class NonElectronicRecordTests extends BaseRestTest String file = "File " + getRandomAlphanumeric(); String shelf = "Shelf " + getRandomAlphanumeric(); String location = "Location " + getRandomAlphanumeric(); - + Random random = new Random(); Integer copies = random.nextInt(Integer.MAX_VALUE); Integer size = random.nextInt(Integer.MAX_VALUE); - - // set values of all available properties - FilePlanComponentProperties properties = new FilePlanComponentProperties(title, description); - properties.setBox(box); - properties.setFile(file); - properties.setShelf(shelf); - properties.setLocation(location); - properties.setNumberOfCopies(copies); - properties.setPhysicalSize(size); - + + // set values of all available properties for the non electronic records + FilePlanComponent filePlanComponent = FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(title) + .description(description) + .box(box) + .file(file) + .shelf(shelf) + .location(location) + .numberOfCopies(copies) + .physicalSize(size) + .build()) + .build(); + // create non-electronic record String nonElectronicId = filePlanComponentAPI.createFilePlanComponent( - new FilePlanComponent("Record " + getRandomAlphanumeric(), - NON_ELECTRONIC_RECORD_TYPE.toString(), - properties), + filePlanComponent, container.getId()).getId(); - + // verify the create request status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); - + // get newly created non-electonic record and verify its properties FilePlanComponent nonElectronicRecord = filePlanComponentAPI.getFilePlanComponent(nonElectronicId); - + assertEquals(title, nonElectronicRecord.getProperties().getTitle()); assertEquals(description, nonElectronicRecord.getProperties().getDescription()); assertEquals(box, nonElectronicRecord.getProperties().getBox()); @@ -195,11 +201,11 @@ public class NonElectronicRecordTests extends BaseRestTest assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies()); assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize()); } - + /** ** Given a parent container that is a record folder - * And the record folder is closed + * And the record folder is closed * When I try to create a non-electronic record within the parent container * Then nothing happens * And an error is reported @@ -211,21 +217,22 @@ public class NonElectronicRecordTests extends BaseRestTest { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()); - + // the folder should be open assertFalse(recordFolder.getProperties().getIsClosed()); - + // close the folder closeFolder(recordFolder.getId()); - + // try to create it, this should fail and throw an exception - filePlanComponentAPI.createFilePlanComponent( - new FilePlanComponent("Record " + getRandomAlphanumeric(), - NON_ELECTRONIC_RECORD_TYPE.toString(), - new FilePlanComponentProperties()), - recordFolder.getId()).getId(); - + filePlanComponentAPI.createFilePlanComponent(FilePlanComponent.builder() + .name("Record " + getRandomAlphanumeric()) + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(), + recordFolder.getId()) + .getId(); + // verify the status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } @@ -251,31 +258,32 @@ public class NonElectronicRecordTests extends BaseRestTest */ @Test ( - dataProvider = "validRootContainers", + dataProvider = "validRootContainers", description = "Non-electronic record can only be created if all mandatory properties are given" ) public void allMandatoryPropertiesRequired(FilePlanComponent container) throws Exception { filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - + logger.info("Root container:\n" + toJson(container)); if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString())) { // only record folders can be open or closed assertFalse(container.getProperties().getIsClosed()); } - + // component without name and title - FilePlanComponent noNameOrTitle = getDummyNonElectronicRecord(); - + FilePlanComponent noNameOrTitle = getDummyNonElectronicRecord(); + // component with title only FilePlanComponent titleOnly = getDummyNonElectronicRecord(); - FilePlanComponentProperties properties = new FilePlanComponentProperties(); - properties.setTitle("Title " + getRandomAlphanumeric()); + FilePlanComponentProperties properties = FilePlanComponentProperties.builder() + .title("Title " + getRandomAlphanumeric()) + .build(); titleOnly.setProperties(properties); - // try to create invalid components - asList(noNameOrTitle, titleOnly).stream().forEach(c -> + // try to create invalid components + asList(noNameOrTitle, titleOnly).stream().forEach(c -> { try { @@ -284,21 +292,21 @@ public class NonElectronicRecordTests extends BaseRestTest catch (Exception error) { } - + // this should fail and throw an exception try - { + { filePlanComponentAPI.createFilePlanComponent(c, container.getId()); - } + } catch (Exception e) { } // verify the status code is BAD_REQUEST filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST); - }); + }); } - + /** ** Given that I am a user without RM privileges @@ -310,7 +318,7 @@ public class NonElectronicRecordTests extends BaseRestTest */ @Test ( - dataProvider = "validRootContainers", + dataProvider = "validRootContainers", description = "Non-electronic record can't be created if user doesn't have RM privileges" ) public void cantCreateIfNoRmPrivileges(FilePlanComponent container) throws Exception @@ -319,16 +327,23 @@ public class NonElectronicRecordTests extends BaseRestTest UserModel user = createUserWithRole(username, UserRole.SiteManager); filePlanComponentAPI.usingRestWrapper().authenticateUser(user); - + // try to create a fileplan component - FilePlanComponent record = new FilePlanComponent("Record Name", NON_ELECTRONIC_RECORD_TYPE.toString(), - new FilePlanComponentProperties("Name", "Title")); - + FilePlanComponent record=FilePlanComponent.builder() + .properties(FilePlanComponentProperties.builder() + .description("Description") + .title("Title") + .build()) + .name("Record Name") + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); + + // this should fail and throw an exception try - { + { filePlanComponentAPI.createFilePlanComponent(record, container.getId()); - } + } catch (Exception e) { } @@ -336,18 +351,19 @@ public class NonElectronicRecordTests extends BaseRestTest // user who isn't an RM site member can't access the container path filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); } - + /** * Helper function to return an empty FilePlanComponent for non-electronic record * @return */ private FilePlanComponent getDummyNonElectronicRecord() { - FilePlanComponent component = new FilePlanComponent(); - component.setNodeType(NON_ELECTRONIC_RECORD_TYPE.toString()); + FilePlanComponent component=FilePlanComponent.builder() + .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) + .build(); return component; } - + /** * Create user with given role and add it to RM site *
@@ -369,13 +385,13 @@ public class NonElectronicRecordTests extends BaseRestTest UserModel user = new UserModel(); user.setUsername(userName); user.setPassword(userName); - + if (!dataUser.isUserInRepo(userName)) { // user doesn't exist, create it user = dataUser.createUser(userName, userName); user.setUserRole(userRole); - + dataUser.addUserToSite(user, new SiteModel(siteId), userRole); } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java index c812282573..12e8c9ed28 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java @@ -94,8 +94,15 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory = new FilePlanComponent(categoryName,RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -103,9 +110,9 @@ public class RecordCategoryTest extends BaseRestTest restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertTrue(filePlanComponent.isCategory()); - assertFalse(filePlanComponent.isFile()); - assertFalse(filePlanComponent.isRecordFolder()); + assertTrue(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsFile()); + assertFalse(filePlanComponent.getIsRecordFolder()); assertEquals(filePlanComponent.getName(), categoryName); assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString()); @@ -139,8 +146,14 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -148,7 +161,7 @@ public class RecordCategoryTest extends BaseRestTest String newCategoryName = "Rename " + categoryName; // Build the properties which will be updated - FilePlanComponent recordCategoryUpdated = new FilePlanComponent(newCategoryName); + FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build(); // Update the record category FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId()); @@ -186,8 +199,15 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), - new FilePlanComponentProperties(categoryTitle)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(categoryName) + .nodeType(RECORD_CATEGORY_TYPE.toString()) + .properties( + FilePlanComponentProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the record category FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); @@ -226,9 +246,9 @@ public class RecordCategoryTest extends BaseRestTest // Verify child category assertEquals(childCategory.getParentId(), rootCategory.getId()); - assertTrue(childCategory.isCategory()); - assertFalse(childCategory.isFile()); - assertFalse(childCategory.isRecordFolder()); + assertTrue(childCategory.getIsCategory()); + assertFalse(childCategory.getIsFile()); + assertFalse(childCategory.getIsRecordFolder()); assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString()); } @@ -295,19 +315,19 @@ public class RecordCategoryTest extends BaseRestTest assertEquals(filePlanComponent.getParentId(), rootCategory.getId()); // Only categories or folders have been created - assertFalse(filePlanComponent.isFile()); + assertFalse(filePlanComponent.getIsFile()); // Boolean properties related to node type // Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE.toString())) { - assertTrue(filePlanComponent.isCategory()); - assertFalse(filePlanComponent.isRecordFolder()); + assertTrue(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsRecordFolder()); } else { - assertTrue(filePlanComponent.isRecordFolder()); - assertFalse(filePlanComponent.isCategory()); + assertTrue(filePlanComponent.getIsRecordFolder()); + assertFalse(filePlanComponent.getIsCategory()); } // Does returned object have the same contents as the created one? @@ -348,8 +368,14 @@ public class RecordCategoryTest extends BaseRestTest FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME); //Build node properties - FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType, - new FilePlanComponentProperties("Title for " + COMPONENT_NAME)); + FilePlanComponent recordCategory = FilePlanComponent.builder() + .name(COMPONENT_NAME) + .nodeType(nodeType) + .properties( + FilePlanComponentProperties.builder() + .title("Title for " + COMPONENT_NAME) + .build()) + .build(); //create the invalid node type filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId()); @@ -383,8 +409,14 @@ public class RecordCategoryTest extends BaseRestTest { RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); //Build node properties - FilePlanComponent component = new FilePlanComponent(componentName, componentType.toString(), - new FilePlanComponentProperties("Title for " + componentName)); + FilePlanComponent component = FilePlanComponent.builder() + .name(componentName) + .nodeType(componentType.toString()) + .properties(FilePlanComponentProperties.builder() + .title("Title for " + componentName) + .build()) + .build(); + FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId); restWrapper.assertStatusCodeIs(CREATED); return fpc; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java index 705e79258b..bab76aec0c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java @@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME; import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.CREATED; @@ -44,6 +45,7 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.fail; import static org.testng.AssertJUnit.assertTrue; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.NoSuchElementException; @@ -93,8 +95,13 @@ public class RecordFolderTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); FilePlanComponent filePlanComponent = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY); - FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(FOLDER_TITLE); - FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), filePlanComponentProperties); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(FOLDER_TITLE) + .build()) + .build(); // Create the record folder FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId()); @@ -105,9 +112,9 @@ public class RecordFolderTests extends BaseRestTest // Check folder has been created within the category created assertEquals(filePlanComponent.getId(),folder.getParentId()); // Verify the returned properties for the file plan component - record folder - assertFalse(folder.isCategory()); - assertFalse(folder.isFile()); - assertTrue(folder.isRecordFolder()); + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); assertEquals(folder.getName(), FOLDER_NAME); assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString()); @@ -138,8 +145,14 @@ public class RecordFolderTests extends BaseRestTest String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId(); // Build the record category properties - FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(FOLDER_TITLE)); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(FOLDER_TITLE) + .build()) + .build(); + // Create a record folder filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID); @@ -168,10 +181,10 @@ public class RecordFolderTests extends BaseRestTest // Verify the returned properties for the file plan component - record folder assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType()); - assertTrue(folderDetails.isRecordFolder()); - assertFalse(folderDetails.isCategory()); - assertFalse(folderDetails.isFile()); - assertFalse(folderDetails.isClosed()); + assertTrue(folderDetails.getIsRecordFolder()); + assertFalse(folderDetails.getIsCategory()); + assertFalse(folderDetails.getIsFile()); + assertFalse(folderDetails.getIsClosed()); assertEquals(FOLDER_NAME,folderDetails.getName()); assertEquals(dataUser.getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId()); @@ -210,11 +223,16 @@ public class RecordFolderTests extends BaseRestTest String location = "Location"+getRandomAlphanumeric(); //Create the file plan component properties to update - FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(folderTitle, folderDescription); - filePlanComponentProperties.setVitalRecord(true); - filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1")); - filePlanComponentProperties.setLocation(location); - FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties); + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(folderName) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .vitalRecord(true) + .reviewPeriod(new ReviewPeriod("month","1")) + .location(location) + .build()) + .build(); // Update the record category FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId()); @@ -226,7 +244,7 @@ public class RecordFolderTests extends BaseRestTest assertEquals(folderName, folderUpdated.getName()); assertEquals(folderDescription, folderUpdated.getProperties().getDescription()); assertEquals(folderTitle, folderUpdated.getProperties().getTitle()); - assertTrue(folderUpdated.getProperties().isVitalRecord()); + assertTrue(folderUpdated.getProperties().getVitalRecord()); assertEquals(location, folderUpdated.getProperties().getLocation()); assertNotNull(folderUpdated.getProperties().getReviewPeriod().getPeriodType()); assertNotNull(folderUpdated.getProperties().getReviewPeriod().getExpression()); @@ -324,11 +342,11 @@ public class RecordFolderTests extends BaseRestTest // Is parent Id set correctly assertEquals(filePlanComponent.getParentId(), category.getId()); - assertFalse(filePlanComponent.isFile()); + assertFalse(filePlanComponent.getIsFile()); // Boolean properties related to node type - assertTrue(filePlanComponent.isRecordFolder()); - assertFalse(filePlanComponent.isCategory()); + assertTrue(filePlanComponent.getIsRecordFolder()); + assertFalse(filePlanComponent.getIsCategory()); assertEquals(createdComponent.getName(), filePlanComponent.getName()); assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType()); @@ -342,6 +360,97 @@ public class RecordFolderTests extends BaseRestTest ); } + + /** + * Given that I want to create a record folder + * When I use the API with the relativePath + * Then the categories specified in the relativePath that don't exist are created within the record folder + * + * Containers in the relativePath that do not exist are created before the node is created + */ + @Test + ( + description = "Create a folder based on the relativePath. " + + "Containers in the relativePath that do not exist are created before the node is created" + ) + public void createFolderWithRelativePath() throws Exception + { + //RelativePath specify the container structure to create relative to the record folder to be created + String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth(); + + // Authenticate with admin user + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + //The record folder to be created + FilePlanComponent recordFolder = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .relativePath(RELATIVE_PATH) + .build(); + + // Create the record folder + FilePlanComponent folder = filePlanComponentAPI.withParams("include="+ PATH).createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); + + //Check the path return contains the RELATIVE_PATH + assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); + //check the parent is a category + assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); + + //check the created folder from the server + folder=filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder.getId()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + // Verify the returned properties for the file plan component - record folder + assertFalse(folder.getIsCategory()); + assertFalse(folder.getIsFile()); + assertTrue(folder.getIsRecordFolder()); + + //Check the path return contains the RELATIVE_PATH + assertTrue(folder.getPath().getName().contains(RELATIVE_PATH)); + + //New Relative Path only a part of containers need to be created before the record folder + String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1); + //The record folder to be created + FilePlanComponent recordFolder2 = FilePlanComponent.builder() + .name(FOLDER_NAME) + .nodeType(RECORD_FOLDER_TYPE.toString()) + .relativePath(NEW_RELATIVE_PATH) + .build(); + + // Create the record folder + FilePlanComponent folder2 = filePlanComponentAPI.withParams("include=" + PATH).createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS.toString()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder2.getIsCategory()); + assertFalse(folder2.getIsFile()); + assertTrue(folder2.getIsRecordFolder()); + //Check the path return contains the NEW_RELATIVE_PATH + assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH)); + + //check the parent is a category + assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory()); + + // Check the folder created on the server + folder2 = filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder2.getId()); + //Check the API response code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // Verify the returned properties for the file plan component - record folder + assertFalse(folder2.getIsCategory()); + assertFalse(folder2.getIsFile()); + assertTrue(folder2.getIsRecordFolder()); + //Check the path return contains the NEW_RELATIVE_PATH + assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH)); + } + @AfterClass (alwaysRun = true) public void tearDown() throws Exception { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java index 74e669d8ce..d008d5fbae 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java @@ -107,8 +107,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest String folderDescription = folderName + " Description"; // Build unfiled records folder properties - FilePlanComponent unfiledFolder=new FilePlanComponent(folderName,UNFILED_RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(folderTitle,folderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(folderName) + .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .build()) + .build(); FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS.toString()); @@ -117,9 +123,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(filePlanComponent.isCategory()); - assertFalse(filePlanComponent.isFile()); - assertFalse(filePlanComponent.isRecordFolder()); // it is not a _normal_ record folder! + assertFalse(filePlanComponent.getIsCategory()); + assertFalse(filePlanComponent.getIsFile()); + assertFalse(filePlanComponent.getIsRecordFolder()); // it is not a _normal_ record folder! assertEquals(filePlanComponent.getName(), folderName); assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); @@ -151,8 +157,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest logger.info("creating " + componentType.toString()); // Build unfiled records folder properties - FilePlanComponent unfiledFolder = new FilePlanComponent(folderName, componentType.toString(), - new FilePlanComponentProperties(folderTitle, folderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(folderName) + .nodeType(componentType.toString()) + .properties(FilePlanComponentProperties.builder() + .title(folderTitle) + .description(folderDescription) + .build()) + .build(); try { @@ -189,8 +201,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(parentFolderName, parentFolder.getName()); // Build the unfiled records folder properties - FilePlanComponent unfiledFolder = new FilePlanComponent(childFolderName, UNFILED_RECORD_FOLDER_TYPE.toString(), - new FilePlanComponentProperties(childFolderTitle, childFolderDescription)); + FilePlanComponent unfiledFolder = FilePlanComponent.builder() + .name(childFolderName) + .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString()) + .properties(FilePlanComponentProperties.builder() + .title(childFolderTitle) + .description(childFolderDescription) + .build()) + .build(); // Create it as a child of parentFolder FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, @@ -200,9 +218,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(childFolder.isCategory()); - assertFalse(childFolder.isFile()); - assertFalse(childFolder.isRecordFolder()); // it is not a _normal_ record folder! + assertFalse(childFolder.getIsCategory()); + assertFalse(childFolder.getIsFile()); + assertFalse(childFolder.getIsRecordFolder()); // it is not a _normal_ record folder! assertEquals(childFolder.getName(), childFolderName); assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); @@ -251,9 +269,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(folderName, folderToModify.getName()); // Build the properties which will be updated - FilePlanComponent folderToUpdate = new FilePlanComponent(modified + folderToModify.getName(), - new FilePlanComponentProperties(modified + folderToModify.getProperties().getTitle(), - modified + folderToModify.getProperties().getDescription())); + FilePlanComponent folderToUpdate = FilePlanComponent.builder() + .name(modified + folderToModify.getName()) + .properties(FilePlanComponentProperties.builder(). + title(modified + folderToModify.getProperties().getTitle()). + description(modified + folderToModify.getProperties().getDescription()) + .build()) + .build(); + // Update the unfiled records folder filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId()); // Verify the status code diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java index 417895d64f..cb562d6525 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java @@ -95,7 +95,10 @@ public class RMSiteTests extends BaseRestTest } // Create the RM site - RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD); + RMSite rmSite =RMSite.builder().compliance(STANDARD).build(); + rmSite.setTitle(RM_TITLE); + rmSite.setDescription(RM_DESCRIPTION); + RMSite rmSiteResponse = rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -132,7 +135,10 @@ public class RMSiteTests extends BaseRestTest String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists"; // Create the RM site - RMSite rmSite = new RMSite(newTitle, newDescription, STANDARD); + RMSite rmSite = RMSite.builder().compliance(STANDARD).build(); + rmSite.setTitle(newTitle); + rmSite.setDescription(newDescription); + rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -236,7 +242,9 @@ public class RMSiteTests extends BaseRestTest rmSiteAPI.usingRestWrapper().authenticateUser(userModel); // Create the RM site - RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, DOD5015); + RMSite rmSite = RMSite.builder().compliance(DOD5015).build(); + rmSite.setTitle(RM_TITLE); + rmSite.setDescription(RM_DESCRIPTION); rmSite=rmSiteAPI.createRMSite(rmSite); // Verify the status code @@ -325,7 +333,7 @@ public class RMSiteTests extends BaseRestTest createRMSiteIfNotExists(); // Build the RM site properties - RMSite rmSiteToUpdate = new RMSite(DOD5015); + RMSite rmSiteToUpdate = RMSite.builder().compliance(DOD5015).build(); // Update the RM site rmSiteAPI.updateRMSite(rmSiteToUpdate); diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties index 37b4cd6ede..a42ee061f7 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/messages/records-management-service.properties @@ -20,4 +20,5 @@ rm.service.node-has-aspect=The record type {1} is already showing for record {0} rm.service.final-version=Final rm.service.final-version-description=The final archived record version rm.service.enable-autoversion-on-record-creation=Auto Version on Record Creation -rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder \ No newline at end of file +rm.service.add-children-to-closed-record-folder=You can't add new items to a closed record folder +rm.service.update-record-content=Could not update content property as it's immutable for records. \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml index f4e068dc03..71db247827 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-public-rest-context.xml @@ -45,18 +45,23 @@ -+ - + - + + + + ++ + + @@ -84,6 +89,30 @@ + + ++ + + + + + + ++ +org.alfresco.rm.rest.api.Records ++ + ++ ++
++ diff --git a/rm-community/rm-community-repo/pom.xml b/rm-community/rm-community-repo/pom.xml index 51cd214259..3097d04a65 100644 --- a/rm-community/rm-community-repo/pom.xml +++ b/rm-community/rm-community-repo/pom.xml @@ -25,6 +25,7 @@ alfresco-rm-community-repo true ${project.build.directory}/solr/home +1.4