From d554f9fdd25bc8fa06a9119aefcedd45fc615bd5 Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Mon, 12 Dec 2016 11:20:54 +0000 Subject: [PATCH] RM-4542: record name doesn't default to file name --- .../requests/FilePlanComponentAPI.java | 1 + .../ElectronicRecordTests.java | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) 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 9d8c385a91..3a4ae7afa9 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 @@ -178,6 +178,7 @@ public class FilePlanComponentAPI extends RestAPI .auth().basic(currentUser.getUsername(), currentUser.getPassword()) .multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name()) .multiPart("filedata", recordContent, ContentType.BINARY.name()) + .multiPart("name", electronicRecordModel.getName() != null ? electronicRecordModel.getName() : recordContent.getName()) .when() .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) .andReturn(); 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 2b30770dc8..8dc9c84b83 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 @@ -223,6 +223,37 @@ public class ElectronicRecordTests extends BaseRestTest // verify the create request status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // get newly created electonic record and verify its properties + FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); + // created record will have record identifier inserted in its name but will be prefixed with + // the name it was created as + assertTrue(electronicRecord.getName().startsWith(record.getName())); + } + + /** + * This test verified that in the test client implementation if record name isn't specified it + * defaults to filed file name. + * @param container valid record container + * @throws Exception if record creation failed + */ + @Test + ( + dataProvider = "validRootContainers", + description = "Electronic records can be created in unfiled record folder or unfiled record root" + ) + public void recordNameDerivedFromFileName(FilePlanComponent container) throws Exception + { + filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + + // record object without name set + FilePlanComponent record = new FilePlanComponent(); + record.setNodeType(CONTENT_TYPE.toString()); + record.setProperties(new FilePlanComponentProperties()); + String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); + + // verify the create request status code + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // get newly created electonic record and verify its properties FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); // record will have record identifier inserted in its name but will for sure start with file name