diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java index aa4eda6563..e76c58c938 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/model/fileplancomponents/FilePlanComponentType.java @@ -27,8 +27,11 @@ public enum FilePlanComponentType HOLD_TYPE("rma:hold"), UNFILED_RECORD_FOLDER_TYPE("rma:unfiledRecordFolder"), HOLD_CONTAINER_TYPE("rma:holdContainer"), + TRANSFER_TYPE("rma:transfer"), TRANSFER_CONTAINER_TYPE("rma:transferContainer"), - UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"); + UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"), + FOLDER_TYPE("cm:folder"), + CONTENT_TYPE("cm:content"); private String type; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java index 9adde5de57..46b634a7c1 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/base/TestData.java @@ -15,10 +15,15 @@ import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAli import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; +import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE; +import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.FOLDER_TYPE; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE; +import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.TRANSFER_CONTAINER_TYPE; +import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.TRANSFER_TYPE; import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; +import static org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import org.testng.annotations.DataProvider; @@ -98,4 +103,28 @@ public interface TestData * The default FOLDER title used when creating categories */ public static String FOLDER_TITLE = "FOLDER TITLE" + getRandomAlphanumeric(); + + + /** + * Data Provider with: + * with the object types not allowed as children for a record category + * + * @return file plan component alias + */ + @DataProvider + public static Object[][] childrenNotAllowedForCategory() + { + return new Object[][] { + { FILE_PLAN_TYPE.toString() }, + { TRANSFER_CONTAINER_TYPE.toString() }, + { HOLD_CONTAINER_TYPE.toString() }, + { UNFILED_CONTAINER_TYPE.toString() }, + { UNFILED_RECORD_FOLDER_TYPE.toString()}, + { HOLD_TYPE.toString()}, + { TRANSFER_TYPE.toString()}, + { FOLDER_TYPE.toString()}, + { CONTENT_TYPE.toString()} + }; + } + } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java index d1f18bd2eb..93f7137f2e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java @@ -24,6 +24,7 @@ import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.OK; +import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; @@ -35,8 +36,9 @@ import java.util.NoSuchElementException; import com.google.gson.JsonObject; -import org.alfresco.rest.rm.base.BaseRestTest; import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.rm.base.BaseRestTest; +import org.alfresco.rest.rm.base.TestData; import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentProperties; import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType; @@ -333,6 +335,39 @@ public class RecordCategoryTest extends BaseRestTest }); } + /** + *
+ * Given that a record category exists + * When I ask to create a object type which is not a record category or a record folder as a child + * Then the children are not created and the 422 response code is returned + */ + @Test + ( + description = "Create object types not allowed inside a category", + dataProviderClass = TestData.class, + dataProvider = "childrenNotAllowedForCategory" + + ) + public void createTypesNotAllowedInCategory(String nodeType) throws Exception + { + String COMPONENT_NAME="Component"+getRandomAlphanumeric(); + // Authenticate with admin user + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME); + + JsonObject componentProperties = buildObject() + .add(NAME, COMPONENT_NAME) + .add(NODE_TYPE, nodeType) + .addObject(PROPERTIES) + .add(PROPERTIES_TITLE, "Title for " + COMPONENT_NAME) + .end() + .getJson(); + + FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, category.getId()); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + } + + /** * Helper method to create child category *