RM-4542: record name doesn't default to file name

This commit is contained in:
Kristijan Conkas
2016-12-12 11:20:54 +00:00
parent 08cc908c5b
commit d554f9fdd2
2 changed files with 32 additions and 0 deletions

View File

@@ -178,6 +178,7 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
.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();

View File

@@ -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