From 737d1d15a005a0f712dd377d0300c118824b24ec Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 16 Nov 2016 17:14:39 +0200 Subject: [PATCH 1/3] New test for RM-4367 --- .../FilePlanComponentType.java | 5 ++- .../org/alfresco/rest/rm/base/TestData.java | 29 +++++++++++++++ .../RecordCategoryTest.java | 37 ++++++++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) 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
      *

From 102d9a6a75ac751a5158c22b8293cf8fd9f9c22f Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Thu, 17 Nov 2016 10:07:11 +0200
Subject: [PATCH 2/3] minor updates

---
 .../rm/fileplancomponents/RecordCategoryTest.java   | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

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 93f7137f2e..5e259d4603 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
@@ -336,18 +336,17 @@ 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"
+    (
+        description = "Create node types not allowed inside a category",
+        dataProviderClass = TestData.class,
+        dataProvider = "childrenNotAllowedForCategory"
 
-        )
+    )
     public void createTypesNotAllowedInCategory(String nodeType) throws Exception
     {
         String COMPONENT_NAME="Component"+getRandomAlphanumeric();
@@ -355,6 +354,7 @@ public class RecordCategoryTest extends BaseRestTest
         filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
         FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
 
+        //Build node  properties
         JsonObject componentProperties = buildObject()
             .add(NAME, COMPONENT_NAME)
             .add(NODE_TYPE, nodeType)
@@ -363,6 +363,7 @@ public class RecordCategoryTest extends BaseRestTest
             .end()
             .getJson();
 
+        //create the invalid node type
         FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, category.getId());
         filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
     }

From bf194339499d1778f51e83604f6f66debbe762bc Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Thu, 17 Nov 2016 11:29:47 +0200
Subject: [PATCH 3/3] add the bug id

---
 .../alfresco/rest/rm/fileplancomponents/RecordCategoryTest.java | 2 ++
 1 file changed, 2 insertions(+)

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 5e259d4603..78d527e30a 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
@@ -45,6 +45,7 @@ import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentType;
 import org.alfresco.rest.rm.model.fileplancomponents.FilePlanComponentsCollection;
 import org.alfresco.rest.rm.requests.FilePlanComponentAPI;
 import org.alfresco.utility.data.DataUser;
+import org.alfresco.utility.report.Bug;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.testng.annotations.Test;
 
@@ -347,6 +348,7 @@ public class RecordCategoryTest extends BaseRestTest
         dataProvider = "childrenNotAllowedForCategory"
 
     )
+    @Bug (id="RM-4367")
     public void createTypesNotAllowedInCategory(String nodeType) throws Exception
     {
         String COMPONENT_NAME="Component"+getRandomAlphanumeric();