From b890344cb35249626d2c83e686de44b032297b05 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Fri, 9 Dec 2016 15:23:20 +0000 Subject: [PATCH] RM-4405: CI remediation. --- .../requests/FilePlanComponentAPI.java | 28 ++++++------------- .../rest/rm/community/base/BaseRestTest.java | 16 +++++++++++ .../rest/rm/community/base/TestData.java | 3 +- .../ElectronicRecordTests.java | 21 ++++---------- .../NonElectronicRecordTests.java | 17 +---------- 5 files changed, 32 insertions(+), 53 deletions(-) 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 7bbde28e17..9d8c385a91 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 @@ -129,8 +129,14 @@ public class FilePlanComponentAPI extends RestAPI public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception { mandatoryObject("filePlanComponentProperties", filePlanComponentModel); - - return doCreateFilePlanComponent(toJson(filePlanComponentModel), parentId); + mandatoryString("parentId", parentId); + + return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( + POST, + toJson(filePlanComponentModel), + "fileplan-components/{fileplanComponentId}/children?{parameters}", + parentId, + getParameters())); } /** @@ -181,24 +187,6 @@ public class FilePlanComponentAPI extends RestAPI /* return a FilePlanComponent object representing Response */ return response.jsonPath().getObject("entry", FilePlanComponent.class); } - - /** - * Helper method for handling low-level fileplan component creation requests - * @param requestBody - * @param parentId - * @return Newly created {@link FilePlanComponent} - * @throws Exception - */ - private FilePlanComponent doCreateFilePlanComponent(String requestBody, String parentId) throws Exception - { - mandatoryString("parentId", parentId); - return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( - POST, - requestBody, - "fileplan-components/{fileplanComponentId}/children?{parameters}", - parentId, - getParameters())); - } /** * Updates a file plan component 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 4c95788f3e..4a11cf446c 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,6 +30,8 @@ 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.FILE_PLAN_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.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; @@ -55,6 +57,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; /** * Base class for all IG REST API Tests @@ -98,6 +101,19 @@ public class BaseRestTest extends RestTest public static final String RM_TITLE = "Records Management"; public static final String RM_DESCRIPTION = "Records Management Site"; + /** Valid root containers where electronic and non-electronic records can be created */ + @DataProvider(name = "validContainers") + public Object[][] rootContainers() throws Exception { + return new Object[][] { + // an arbitrary record folder + { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, + // unfiled records root + { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, + // an arbitrary unfiled records folder + { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) } + }; + } + /** * @see org.alfresco.rest.RestTest#checkServerHealth() */ 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 43c9147d5f..ee890dfab9 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 @@ -50,7 +50,7 @@ import org.testng.annotations.DataProvider; * @since 2.6 */ public interface TestData -{ +{ /** * A user with ALFRESCO_ADMINISTRATORS role. *

"GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created. @@ -141,5 +141,4 @@ public interface TestData { CONTENT_TYPE.toString()} }; } - } 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 7f11a05162..c63182bdb3 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 @@ -50,9 +50,13 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * + * Create/File electronic records tests + *
+ * These tests only test the creation and filing of electronic records, update at + * present isn't implemented in the API under test. + *

* @author Kristijan Conkas - * @since + * @since 2.6 */ public class ElectronicRecordTests extends BaseRestTest { @@ -81,19 +85,6 @@ public class ElectronicRecordTests extends BaseRestTest }; } - /** Valid root containers where electronic records can be created */ - @DataProvider(name = "validContainers") - public Object[][] rootContainers() throws Exception { - return new Object[][] { - // an arbitrary record folder - { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, - // unfiled records root - { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, - // an arbitrary unfiled records folder - { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) } - }; - } - /** *

      * Given a parent container that is NOT a record folder or an unfiled record folder
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 9bf340632c..7fa64e3a45 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
@@ -31,7 +31,6 @@ import static java.util.Arrays.asList;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.HOLDS_ALIAS;
 import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_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.NON_ELECTRONIC_RECORD_TYPE;
 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;
@@ -56,7 +55,6 @@ import org.alfresco.utility.data.DataUser;
 import org.alfresco.utility.model.SiteModel;
 import org.alfresco.utility.model.UserModel;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
@@ -75,20 +73,7 @@ public class NonElectronicRecordTests extends BaseRestTest
     
     @Autowired
     private RMSiteAPI rmSiteAPI;
-    
-    /** 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
-            { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
-            // unfiled records root
-            { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
-            // an arbitrary unfiled records folder
-            { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) }
-        };
-    }
-    
+        
     /**
      * 
      * Given a parent container that is NOT a record folder or an unfiled record folder