From ad656729c9d21e050a1871967df8ceeef8d54097 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Wed, 18 Jan 2017 12:22:24 +0000 Subject: [PATCH 1/7] MNT-16881 Add CreateChild permission to the write group. Note that the RM permission code in RecordsManagementPermissionPostProcessor is not navigating the permission group hierarchy correctly. This is a simple fix to solve the issue referenced, but the full fix will go into master. --- .../module/org_alfresco_module_rm/alfresco-global.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties index 4520306a4e..7f39bba3c9 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/alfresco-global.properties @@ -85,7 +85,7 @@ rm.patch.v22.convertToStandardFilePlan=false # these take a comma separated string of permissions from org.alfresco.service.cmr.security.PermissionService # read maps to ReadRecords and write to FileRecords rm.haspermissionmap.read=ReadProperties,ReadChildren -rm.haspermissionmap.write=WriteProperties,AddChildren +rm.haspermissionmap.write=WriteProperties,AddChildren,CreateChildren # # Extended auto-version behaviour. If true and other auto-version properties are satisfied, then From d940b065d5d0eddf8d7251046e5b6e6aa855083b Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 25 Jan 2017 14:12:33 +0200 Subject: [PATCH 2/7] -add tests for the issue RM-4568 --- .../ElectronicRecordTests.java | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) 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 5ab98ae61c..f99758b97f 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 @@ -26,6 +26,9 @@ */ package org.alfresco.rest.rm.community.fileplancomponents; +import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_NAME; +import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME; +import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME; 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; @@ -34,6 +37,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; @@ -42,7 +47,11 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.utility.report.Bug; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -241,4 +250,80 @@ public class ElectronicRecordTests extends BaseRMRestTest // and end with its extension assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf(".")))); } + + @Test + @Bug (id = "RM-4568") + /** + * Given I want to create an electronic record + * When I use the path relative to the filePlanComponentid + * Then the containers in the relativePath that don't exist are created before creating the electronic record + + */ + public void createElectronicRecordWithRelativePath() throws Exception + { + //the containers specified on the RELATIVE_PATH parameter don't exist on server + String RELATIVE_PATH = CATEGORY_NAME + "/"+ CATEGORY_NAME +"/"+ FOLDER_NAME; + FilePlanComponent electronicRecord = FilePlanComponent.builder() + .name(ELECTRONIC_RECORD_NAME) + .nodeType(CONTENT_TYPE.toString()) + .content(FilePlanComponentContent.builder().mimeType("text/plain").build()) + .properties(FilePlanComponentProperties.builder().description("Description").build()) + .relativePath(RELATIVE_PATH) + .build(); + + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().equals(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, + FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + //the category specified via the RELATIVE_PATH exist, folder doesn't exist + RELATIVE_PATH = CATEGORY_NAME + "/" + FOLDER_NAME; + electronicRecord.setRelativePath(RELATIVE_PATH); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, + FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + //the containers from the RELATIVE PATH exists + electronicRecord.setName(ELECTRONIC_RECORD_NAME + getRandomAlphanumeric()); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), + FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + String categoryId =filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME) + .getId(); + RELATIVE_PATH="Category two/"+FOLDER_NAME; + electronicRecord.setRelativePath(RELATIVE_PATH); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),categoryId); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + + } } From a513235bbb022c332f6c002e9c0f80e6ce23b128 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 25 Jan 2017 14:12:33 +0200 Subject: [PATCH 3/7] -add tests for the issue RM-4568 --- .../ElectronicRecordTests.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) 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 5ab98ae61c..fcbab41ccf 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 @@ -26,6 +26,9 @@ */ package org.alfresco.rest.rm.community.fileplancomponents; +import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_NAME; +import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME; +import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME; 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; @@ -34,6 +37,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; @@ -42,7 +47,10 @@ import static org.testng.Assert.assertTrue; import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields; import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.utility.report.Bug; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -241,4 +249,79 @@ public class ElectronicRecordTests extends BaseRMRestTest // and end with its extension assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf(".")))); } + + @Test + @Bug (id = "RM-4568") + /** + * Given I want to create an electronic record + * When I use the path relative to the filePlanComponentid + * Then the containers in the relativePath that don't exist are created before creating the electronic record + + */ + public void createElectronicRecordWithRelativePath() throws Exception + { + //the containers specified on the RELATIVE_PATH parameter don't exist on server + String RELATIVE_PATH = CATEGORY_NAME + "/"+ CATEGORY_NAME +"/"+ FOLDER_NAME; + FilePlanComponent electronicRecord = FilePlanComponent.builder() + .name(ELECTRONIC_RECORD_NAME) + .nodeType(CONTENT_TYPE.toString()) + .content(FilePlanComponentContent.builder().mimeType("text/plain").build()) + .relativePath(RELATIVE_PATH) + .build(); + + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().equals(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, + FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + //the category specified via the RELATIVE_PATH exist, folder doesn't exist + RELATIVE_PATH = CATEGORY_NAME + "/" + FOLDER_NAME; + electronicRecord.setRelativePath(RELATIVE_PATH); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, + FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + //the containers from the RELATIVE PATH exists + electronicRecord.setName(ELECTRONIC_RECORD_NAME + getRandomAlphanumeric()); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), + FILE_PLAN_ALIAS); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + //get newly created electronic record using the relativePath + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + .getId().equals(recordCreated.getId())); + + String categoryId =filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME) + .getId(); + RELATIVE_PATH="Category two/"+FOLDER_NAME; + electronicRecord.setRelativePath(RELATIVE_PATH); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),categoryId); + // verify the create request status code + assertStatusCode(CREATED); + // get newly created electronic record and verify its properties + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + + } } From 970cf4ee064e16eebc8ad04e66c9601ce4029be6 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Wed, 25 Jan 2017 16:26:57 +0200 Subject: [PATCH 4/7] minor updates --- .../community/fileplancomponents/ElectronicRecordTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 f99758b97f..2936131f06 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 @@ -313,9 +313,10 @@ public class ElectronicRecordTests extends BaseRMRestTest assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) .getId().equals(recordCreated.getId())); - String categoryId =filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME) + //create the container structure relative to the categoryId + String categoryId = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME) .getId(); - RELATIVE_PATH="Category two/"+FOLDER_NAME; + RELATIVE_PATH = CATEGORY_NAME+ CATEGORY_NAME+"/"+FOLDER_NAME; electronicRecord.setRelativePath(RELATIVE_PATH); recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),categoryId); @@ -324,6 +325,5 @@ public class ElectronicRecordTests extends BaseRMRestTest // get newly created electronic record and verify its properties assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); - } } From a50450b8626603851232080f36a766bab7a069f8 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 26 Jan 2017 16:48:57 +0200 Subject: [PATCH 5/7] formatting updates --- .../fileplancomponents/ElectronicRecordTests.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 2936131f06..4d1e82bc43 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 @@ -273,16 +273,16 @@ public class ElectronicRecordTests extends BaseRMRestTest FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, - createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); // verify the create request status code - assertStatusCode(CREATED); + assertStatusCode(CREATED); // get newly created electronic record and verify its properties assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().equals(FOLDER_NAME)); //get newly created electronic record using the relativePath assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, - FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) .getId().equals(recordCreated.getId())); //the category specified via the RELATIVE_PATH exist, folder doesn't exist @@ -296,7 +296,7 @@ public class ElectronicRecordTests extends BaseRMRestTest assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); //get newly created electronic record using the relativePath assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, - FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName()) + FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName()) .getId().equals(recordCreated.getId())); //the containers from the RELATIVE PATH exists From 054129283761d117e78fbf1e5b8b199195865712 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 26 Jan 2017 17:50:47 +0200 Subject: [PATCH 6/7] try to fix diff indentation --- .../ElectronicRecordTests.java | 62 +++++++++++-------- 1 file changed, 36 insertions(+), 26 deletions(-) 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 4d1e82bc43..42183c39d2 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 @@ -257,32 +257,40 @@ public class ElectronicRecordTests extends BaseRMRestTest * Given I want to create an electronic record * When I use the path relative to the filePlanComponentid * Then the containers in the relativePath that don't exist are created before creating the electronic record - */ public void createElectronicRecordWithRelativePath() throws Exception { //the containers specified on the RELATIVE_PATH parameter don't exist on server - String RELATIVE_PATH = CATEGORY_NAME + "/"+ CATEGORY_NAME +"/"+ FOLDER_NAME; + String RELATIVE_PATH = CATEGORY_NAME + "/" + CATEGORY_NAME + "/" + FOLDER_NAME; FilePlanComponent electronicRecord = FilePlanComponent.builder() .name(ELECTRONIC_RECORD_NAME) .nodeType(CONTENT_TYPE.toString()) - .content(FilePlanComponentContent.builder().mimeType("text/plain").build()) - .properties(FilePlanComponentProperties.builder().description("Description").build()) + .content(FilePlanComponentContent + .builder() + .mimeType("text/plain") + .build() + ) + .properties(FilePlanComponentProperties + .builder() + .description("Description") + .build() + ) .relativePath(RELATIVE_PATH) .build(); FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); - FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, - createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); + FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS + ); // verify the create request status code assertStatusCode(CREATED); // get newly created electronic record and verify its properties - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().equals(FOLDER_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()) + .getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()) + .getName().equals(FOLDER_NAME)); //get newly created electronic record using the relativePath - assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, - FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) .getId().equals(recordCreated.getId())); //the category specified via the RELATIVE_PATH exist, folder doesn't exist @@ -292,38 +300,40 @@ public class ElectronicRecordTests extends BaseRMRestTest // verify the create request status code assertStatusCode(CREATED); // get newly created electronic record and verify its properties - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()) + .getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()) + .getName().startsWith(FOLDER_NAME)); //get newly created electronic record using the relativePath - assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, - FilePlanComponentFields.RELATIVE_PATH+"="+RELATIVE_PATH+"/"+recordCreated.getName()) + assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) .getId().equals(recordCreated.getId())); //the containers from the RELATIVE PATH exists electronicRecord.setName(ELECTRONIC_RECORD_NAME + getRandomAlphanumeric()); - recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, - createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), - FILE_PLAN_ALIAS); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); // verify the create request status code assertStatusCode(CREATED); // get newly created electronic record and verify its properties - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()) + .getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()) + .getName().startsWith(FOLDER_NAME)); //get newly created electronic record using the relativePath assertTrue(filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + RELATIVE_PATH + "/" + recordCreated.getName()) .getId().equals(recordCreated.getId())); //create the container structure relative to the categoryId - String categoryId = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "="+CATEGORY_NAME) - .getId(); - RELATIVE_PATH = CATEGORY_NAME+ CATEGORY_NAME+"/"+FOLDER_NAME; + String categoryId = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS, FilePlanComponentFields.RELATIVE_PATH + "=" + CATEGORY_NAME) + .getId(); + RELATIVE_PATH = CATEGORY_NAME + CATEGORY_NAME + "/" + FOLDER_NAME; electronicRecord.setRelativePath(RELATIVE_PATH); - recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, - createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME),categoryId); + recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), categoryId); // verify the create request status code assertStatusCode(CREATED); // get newly created electronic record and verify its properties - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()).getName().startsWith(ELECTRONIC_RECORD_NAME)); - assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()).getName().startsWith(FOLDER_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getId()) + .getName().startsWith(ELECTRONIC_RECORD_NAME)); + assertTrue(filePlanComponentsAPI.getFilePlanComponent(recordCreated.getParentId()) + .getName().startsWith(FOLDER_NAME)); } } From 5df1cce8954d96e07057bf60428e5ac27abed578 Mon Sep 17 00:00:00 2001 From: Rodica Sutu Date: Thu, 26 Jan 2017 17:54:23 +0200 Subject: [PATCH 7/7] fix the test failure --- .../fileplancomponents/ElectronicRecordTests.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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 42183c39d2..23ce665a8b 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 @@ -49,7 +49,6 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentContent; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; import org.alfresco.utility.report.Bug; import org.testng.annotations.DataProvider; @@ -270,17 +269,11 @@ public class ElectronicRecordTests extends BaseRMRestTest .mimeType("text/plain") .build() ) - .properties(FilePlanComponentProperties - .builder() - .description("Description") - .build() - ) .relativePath(RELATIVE_PATH) .build(); FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); - FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS - ); + FilePlanComponent recordCreated = filePlanComponentsAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), FILE_PLAN_ALIAS); // verify the create request status code assertStatusCode(CREATED);