diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java index 8164f3afbc..7bbde28e17 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java @@ -51,7 +51,6 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection; import org.alfresco.utility.model.UserModel; import org.springframework.context.annotation.Scope; -import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; /** @@ -173,8 +172,6 @@ public class FilePlanComponentAPI extends RestAPI .auth().basic(currentUser.getUsername(), currentUser.getPassword()) .multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name()) .multiPart("filedata", recordContent, ContentType.BINARY.name()) - .expect() - .statusCode(HttpStatus.CREATED.value()) .when() .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) .andReturn(); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java index 96362a07bd..4c95788f3e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java @@ -30,7 +30,6 @@ import static java.lang.Integer.parseInt; import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE; import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; @@ -222,7 +221,7 @@ public class BaseRestTest extends RestTest * @return record folder * @throws Exception on failed creation */ - public FilePlanComponent createFolderInFilePlan(UserModel user, String parentId) throws Exception + public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception { filePlanComponentAPI.usingRestWrapper().authenticateUser(user); 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 a6b111ee11..6054537aac 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 @@ -12,10 +12,13 @@ package org.alfresco.rest.rm.community.fileplancomponents; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRestTest; @@ -43,12 +46,28 @@ public class ElectronicRecordTests extends BaseRestTest /** image resource file to be used for records body */ private static final String IMAGE_FILE = "money.JPG"; + /** Valid root containers where non-electronic records can be created */ + @DataProvider(name = "invalidParentContainers") + public Object[][] invalidContainers() throws Exception { + return new Object[][] { + // record category + { getFilePlanComponentAsUser(dataUser.getAdminUser(), + createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) }, + // file plan root + { getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, + // transfers + { getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS.toString()) }, + // holds + { getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) }, + }; + } + /** Valid root containers where non-electronic records can be created */ @DataProvider(name = "validContainers") public Object[][] rootContainers() throws Exception { return new Object[][] { // an arbitrary record folder - { createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, + { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, // unfiled records root { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, // an arbitrary unfiled records folder @@ -57,6 +76,41 @@ public class ElectronicRecordTests extends BaseRestTest } /** + *
+     * Given a parent container that is NOT a record folder or an unfiled record folder
+     * When I try to create an electronic record within the parent container
+     * Then nothing happens
+     * And an error is reported
+     * 
+ * @param container + * @throws Exception + */ + @Test + ( + dataProvider = "invalidParentContainers", + description = "Electronic records can't be created in invalid parent containers" + ) + public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(), + new FilePlanComponentProperties()); + filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()); + + // verify the create request status code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + } + + /** + *
+     * Given a parent container that is a record folder
+     * And the record folder is open
+     * When I try to create an electronic record within the parent container
+     * Then the electronic record is created
+     * And the details of the new record are returned
+     * 
+ * and *
      * Given a parent container that is an unfiled record folder or the root unfiled record container
      * When I try to create an electronic record within the parent container
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 6990e1f319..9bf340632c 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
@@ -81,7 +81,7 @@ public class NonElectronicRecordTests extends BaseRestTest
     public Object[][] rootContainers() throws Exception {
         return new Object[][] {
             // an arbitrary record folder
-            { createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
+            { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
             // unfiled records root
             { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
             // an arbitrary unfiled records folder
@@ -225,7 +225,7 @@ public class NonElectronicRecordTests extends BaseRestTest
     public void cantCreateInClosedFolder() throws Exception
     {
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
-        FilePlanComponent recordFolder = createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
+        FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
         
         // the folder should be open
         assertFalse(recordFolder.getProperties().getIsClosed());