From df90b1e1b574d358dab595f8cb843a21ad9353d5 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Fri, 12 May 2017 12:21:39 +0300 Subject: [PATCH 1/2] add tests to create rm types with autoRename parameter (to cover RM-5116) --- .../rest/rm/community/base/TestData.java | 16 ++++++ .../rm/community/fileplans/FilePlanTests.java | 52 +++++++++++++++++++ .../recordcategories/RecordCategoryTests.java | 39 ++++++++++++++ .../UnfiledContainerTests.java | 41 ++++++++++++++- 4 files changed, 146 insertions(+), 2 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java index 3c799ebb61..d5a24f5789 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java @@ -159,6 +159,22 @@ public interface TestData }; } + /** + * Data Provider with: + * with the object types for creating a Record Category Child + * + * @return record category child type + */ + @DataProvider + public static Object[][] categoryChild() + { + return new String[][] { + { RECORD_FOLDER_TYPE }, + { FOLDER_TYPE }, + { RECORD_CATEGORY_TYPE } + }; + } + /** * Invalid root level types, at unfiled record folder/unfiled containers container level that shouldn't be possible to create */ diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java index 73b1780b84..2feea62f20 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplans/FilePlanTests.java @@ -45,12 +45,14 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -322,6 +324,56 @@ public class FilePlanTests extends BaseRMRestTest assertNotNull(rootRecordCategoryProperties.getIdentifier()); } + /** + *
+     * Given a root category
+     * When I ask the API to create a root category having the same name
+     * Then  the response code received is 409 - name clashes with an existing node
+     *
+ *
+     * Given a root category
+     * When I ask the API to create a root category having the same name  with autoRename parameter on true
+     * Then the record category is created the record category has a unique name by adding an integer suffix
+     * 
+ */ + @Test + @Bug(id = "RM-5116") + public void createDuplicateCategories() throws Exception + { + String categoryName = "Category name " + getRandomAlphanumeric(); + String categoryTitle = "Category title " + getRandomAlphanumeric(); + + + // Create the root record category + RecordCategory recordCategory = RecordCategory.builder() + .name(categoryName) + .properties(RecordCategoryProperties.builder() + .title(categoryTitle) + .build()) + .build(); + // Create the root record category + RecordCategory rootRecordCategory = getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory,FILE_PLAN_ALIAS); + + // Verify the status code + assertStatusCode(CREATED); + assertEquals(rootRecordCategory.getName(), categoryName); + + // Create the same root record category + getRestAPIFactory().getFilePlansAPI().createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS); + + // Verify the status code + assertStatusCode(CONFLICT); + + //create the same category with autoRename parameter on true + RecordCategory rootRecordCategoryAutoRename = getRestAPIFactory().getFilePlansAPI() + .createRootRecordCategory(recordCategory, FILE_PLAN_ALIAS,"autoRename=true"); + + // Verify the status code + assertStatusCode(CREATED); + assertNotEquals(rootRecordCategoryAutoRename.getName(), categoryName); + assertTrue(rootRecordCategoryAutoRename.getName().startsWith(categoryName)); + } + @Test public void listFilePlanChildren() throws Exception { diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java index b769d3d572..03359c0bf7 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/RecordCategoryTests.java @@ -38,8 +38,10 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo 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; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.BAD_REQUEST; +import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -47,6 +49,7 @@ 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.assertNotEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; @@ -294,6 +297,42 @@ public class RecordCategoryTests extends BaseRMRestTest assertEquals(folderProperties.getTitle(), TITLE_PREFIX + RECORD_FOLDER_NAME); assertNotNull(folderProperties.getIdentifier()); } + @Test + ( + dataProviderClass = TestData.class, + dataProvider = "categoryChild" + ) + @Bug(id = "RM-5116") + public void createdDuplicateChild(String childType)throws Exception + { + // create a root category + String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId(); + + // Create the record category child + RecordCategoryChild recordFolder = createRecordCategoryChild(rootRecordCategory, RECORD_FOLDER_NAME, childType); + + // check the response code + assertStatusCode(CREATED); + assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME); + + // Create a record category child with the same name as the exiting one + + RecordCategoryChild recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI().createRecordCategoryChild( + createRecordCategoryChildModel(RECORD_FOLDER_NAME, childType), rootRecordCategory); + + // check the response code + assertStatusCode(CONFLICT); + + // Create a record folder with the same name as the exiting one and with the autoRename parameter on true + recordFolderDuplicate = getRestAPIFactory().getRecordCategoryAPI() + .createRecordCategoryChild(createRecordCategoryChildModel(RECORD_FOLDER_NAME, + childType), + rootRecordCategory, "autoRename=true"); + // check the response code + assertStatusCode(CREATED); + assertNotEquals(recordFolderDuplicate.getName(), RECORD_FOLDER_NAME); + assertTrue(recordFolderDuplicate.getName().contains(RECORD_FOLDER_NAME)); + } /** *
diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
index 719d1dddd1..3deeab829c 100644
--- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
+++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/unfiledcontainers/UnfiledContainerTests.java
@@ -38,10 +38,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
 import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
 import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
 import static org.springframework.http.HttpStatus.BAD_REQUEST;
+import static org.springframework.http.HttpStatus.CONFLICT;
+import static org.springframework.http.HttpStatus.CREATED;
 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.assertNotEquals;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
 
@@ -59,6 +62,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChi
 import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
 import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
 import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
+import org.alfresco.utility.report.Bug;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.DataProvider;
@@ -163,7 +167,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
     public void createUnfiledRecordFolderChild(String folderType) throws Exception
     {
         String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
-        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
+        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType);
 
         assertNotNull(unfiledRecordFolderChild.getId());
 
@@ -184,7 +188,40 @@ public class UnfiledContainerTests extends BaseRMRestTest
         assertEquals(unfiledRecordFolder.getParentId(),
                 getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId());
     }
-    
+
+    @Test
+    (   description = "Create duplicate unfiled folder child",
+        dataProvider = "unfiledFolderTypes"
+    )
+    @Bug(id ="RM-5116, RM-5148")
+    public void createDuplicateUnfiledFolderChild(String folderType) throws Exception
+    {
+        String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
+        UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
+                    unfiledRecordFolderName, folderType);
+
+        // Verify the status code
+        assertStatusCode(CREATED);
+        assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
+		
+		// create the same unfiled folder
+        UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
+                    .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
+                                UNFILED_RECORDS_CONTAINER_ALIAS);
+
+        // Verify the status code
+        assertStatusCode(CONFLICT);
+
+        // create the same unfiled folder with the autoRename parameter on true
+        unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
+                    .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),UNFILED_RECORDS_CONTAINER_ALIAS,"autoRename=true");
+
+        //verify the response status code
+		assertStatusCode(CREATED);
+        assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName);
+        assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName));
+
+    }
     /**
      * 
      * Given that an unfiled records container exists

From dc05c563591e368a44a3ed33f7b2f77dcff0706b Mon Sep 17 00:00:00 2001
From: Rodica Sutu 
Date: Mon, 15 May 2017 08:45:03 +0300
Subject: [PATCH 2/2] add the author property

---
 .../model/fileplancomponents/FilePlanComponentFields.java     | 1 +
 .../rest/rm/community/model/record/RecordProperties.java      | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
index ac79160c48..723dbf6764 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java
@@ -48,6 +48,7 @@ public class FilePlanComponentFields
     public static final String PROPERTIES_VITAL_RECORD_INDICATOR = "rma:vitalRecordIndicator";
     public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
     public static final String PROPERTIES_OWNER = "cm:owner";
+    public static final String PROPERTIES_AUTHOR="cm:author";
 
     /** Common properties for record folders and records */
     public static final String PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE = "rma:recordSearchHasDispositionSchedule";
diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
index e2d0fabdb8..8732533cf2 100644
--- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
+++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java
@@ -27,6 +27,7 @@
 
 package org.alfresco.rest.rm.community.model.record;
 
+import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_AUTHOR;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_BOX;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_FILED;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DATE_TIME_ORIGINAL;
@@ -200,4 +201,7 @@ public class RecordProperties extends TestModel
 
     @JsonProperty (PROPERTIES_OWNER)
     private Owner owner;
+
+    @JsonProperty(PROPERTIES_AUTHOR)
+    private String author;
 }