From abb6178ed4edcdc1e4b52ac96a488510d70bedae Mon Sep 17 00:00:00 2001 From: Kristijan Conkas Date: Thu, 5 Jan 2017 11:06:52 +0000 Subject: [PATCH] RM-4430: Pre-merge import and javadoc tidy-up, minor improvements --- .../requests/igCoreAPI/RecordsAPI.java | 2 +- .../rm/community/base/BaseRMRestTest.java | 5 - .../fileplancomponents/FileRecordsTests.java | 520 +++++++++--------- 3 files changed, 263 insertions(+), 264 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RecordsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RecordsAPI.java index 292ed2da97..8ad7e6a012 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RecordsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RecordsAPI.java @@ -48,7 +48,7 @@ import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; /** - *Records REST API Wrapper + * Records REST API Wrapper * *@author Rodica Sutu *@since 2.6 diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index b8840f41da..cc1db1e740 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -39,11 +39,6 @@ import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.OK; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.nio.charset.Charset; - import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestAPIFactory; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FileRecordsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FileRecordsTests.java index f95cea13b3..57a15021f6 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FileRecordsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FileRecordsTests.java @@ -48,6 +48,8 @@ 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.FilePlanComponentProperties; import org.alfresco.rest.rm.community.model.fileplancomponents.RecordBodyFile; +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RecordsAPI; import org.alfresco.utility.report.Bug; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -75,12 +77,7 @@ public class FileRecordsTests extends BaseRMRestTest .name(NONELECTRONIC_RECORD_NAME) .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) .build(); - /** - * Given an unfiled record in the root unfiled record container or a unfiled record folder - * And an open record folder - * When I file the unfiled record into the record folder - * Then the record is filed - */ + /** * Unfiled containers from where record can be filed */ @@ -94,203 +91,7 @@ public class FileRecordsTests extends BaseRMRestTest { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()).getId() } }; } - @Test - ( - dataProvider = "unfiledContainer", - description = "File record from unfiled containers " - ) - public void fileRecordIntoExistingFolder(String unfiledContainerId) throws Exception - { - //create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - - //create records - FilePlanComponent recordElectronic = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); - FilePlanComponent recordNonElectId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, unfiledContainerId); - - //file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - FilePlanComponent recordFiled =getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); - //check the response status - assertStatusCode(CREATED); - //check the parent id for the record returned - assertEquals(recordFiled.getParentId(),folderId); - //check the record is filed into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c->c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //file the non-electronic record into the folder created - FilePlanComponent nonElectRecordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElectId.getId()); - //check the response status code - assertStatusCode(CREATED); - //check the parent id for the record returned - assertEquals(nonElectRecordFiled.getParentId(), folderId); - //check the record is added into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); - } - - /** - * Given an unfiled record in the root unfiled record container or a unfiled record folder - * And a closed record folder - * When I file the unfiled record into the record folder - * Then I get an unsupported operation exception - * - */ - @Test - ( - dataProvider = "unfiledContainer", - description = "File record from unfiled containers into a closed folder " - ) - public void fileRecordIntoCloseFolder(String unfiledContainerId) throws Exception - { - //create a record folder - String folderId = createCategoryFolderInFilePlan().getId(); - closeFolder(folderId); - //create records - FilePlanComponent recordElectronic = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); - FilePlanComponent recordNonElectId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, unfiledContainerId); - - //file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); - getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); - //check the response status - assertStatusCode(FORBIDDEN); - - //check the record is filed into the record folder - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //file the non-electronic record into the folder created - FilePlanComponent nonElectRecordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElectId.getId()); - //check the response status code - assertStatusCode(FORBIDDEN); - //check the record is added into the record folder - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); - } - - /** - * Given a filed record in a record folder - * And an open record folder - * When I file the filed record into the record folder - * Then the record is filed in both locations - */ - @Test - @Bug(id="RM-4578") - public void linkRecordInto() throws Exception - { - //create a record folder - String parentFolderId = createCategoryFolderInFilePlan().getId(); - - //create records - FilePlanComponent recordElectronic = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), UNFILED_RECORDS_CONTAINER_ALIAS); - FilePlanComponent recordNonElect = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - - //file the record into the folder created - RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(parentFolderId).build(); - FilePlanComponent recordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); - FilePlanComponent nonElectronicFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElect.getId()); - //check the response status - assertStatusCode(CREATED); - - //create the second folder - String folderToLink = createCategoryFolderInFilePlan().getId(); - recordBodyFile = RecordBodyFile.builder().targetParentId(folderToLink).build(); - - //check the response status - assertStatusCode(CREATED); - //link the electronic record - FilePlanComponent recordLink = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); - assertTrue(recordLink.getParentId().equals(parentFolderId)); - //check the response status code - assertStatusCode(CREATED); - //link the nonelectronic record - FilePlanComponent nonElectronicLink = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, nonElectronicFiled.getId()); - assertStatusCode(CREATED); - assertTrue(nonElectronicLink.getParentId().equals(parentFolderId)); - - //check the record is added into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(parentFolderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordFiled.getId())&& c.getFilePlanComponentModel().getParentId().equals(parentFolderId) - ) - ); - //check the record doesn't exist into unfiled record container - //TODO add a check after the issue will be fixed RM-4578 - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderToLink) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordFiled.getId()) //&& c.getFilePlanComponentModel().getParentId().equals(parentFolderId) - ) - ); - - //check the record is added into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(parentFolderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(nonElectronicFiled.getId()) && c.getFilePlanComponentModel().getParentId().equals(parentFolderId) - ) - ); - //check the record doesn't exist into unfiled record container - //TODO add a check after the issue will be fixed RM-4578 - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderToLink) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(nonElectronicFiled.getId()) //&& c.getFilePlanComponentModel().getParentId().equals(parentFolderId) - ) - ); - } - - /** - * Given an unfiled or filed record - * And a container that is NOT a record folder - * When I file the unfiled or filed record to the container - * Then I get an unsupported operation exception - */ + /** * Invalid containers where electronic and non-electronic records can be filed */ @@ -308,6 +109,207 @@ public class FileRecordsTests extends BaseRMRestTest { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()).getId() } }; } + + /** + * Given an unfiled record in the root unfiled record container or a unfiled record folder + * And an open record folder + * When I file the unfiled record into the record folder + * Then the record is filed + */ + @Test + ( + dataProvider = "unfiledContainer", + description = "File record from unfiled containers " + ) + public void fileRecordIntoExistingFolder(String unfiledContainerId) throws Exception + { + // get API instances + FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + + // create a record folder + String folderId = createCategoryFolderInFilePlan().getId(); + + // create records + FilePlanComponent recordElectronic = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); + FilePlanComponent recordNonElectId = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, unfiledContainerId); + + // file the record into the folder created + RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); + FilePlanComponent recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // check the response status + assertStatusCode(CREATED); + // check the parent id for the record returned + assertEquals(recordFiled.getParentId(),folderId); + + // check the record is filed into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c->c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // check the record doesn't exist into unfiled record container + assertFalse(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // file the non-electronic record into the folder created + FilePlanComponent nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElectId.getId()); + // check the response status code + assertStatusCode(CREATED); + // check the parent id for the record returned + assertEquals(nonElectRecordFiled.getParentId(), folderId); + + // check the record is added into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); + + // check the record doesn't exist into unfiled record container + assertFalse(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); + } + + /** + * Given an unfiled record in the root unfiled record container or a unfiled record folder + * And a closed record folder + * When I file the unfiled record into the record folder + * Then I get an unsupported operation exception + * + */ + @Test + ( + dataProvider = "unfiledContainer", + description = "File record from unfiled containers into a closed folder " + ) + public void fileRecordIntoCloseFolder(String unfiledContainerId) throws Exception + { + // get API instances + FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + + // create a record folder + String folderId = createCategoryFolderInFilePlan().getId(); + closeFolder(folderId); + // create records + FilePlanComponent recordElectronic = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); + FilePlanComponent recordNonElectId = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, unfiledContainerId); + + // file the record into the folder created + RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build(); + recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + // check the response status + assertStatusCode(FORBIDDEN); + + // check the record is filed into the record folder + assertFalse(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // check the record doesn't exist into unfiled record container + assertTrue(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // file the non-electronic record into the folder created + recordsAPI.fileRecord(recordBodyFile, recordNonElectId.getId()); + // check the response status code + assertStatusCode(FORBIDDEN); + + // check the record is added into the record folder + assertFalse(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); + + // check the record doesn't exist into unfiled record container + assertTrue(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries().stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); + } + + /** + * Given a filed record in a record folder + * And an open record folder + * When I file the filed record into the record folder + * Then the record is filed in both locations + */ + @Test + @Bug(id="RM-4578") + public void linkRecordInto() throws Exception + { + // get API instances + FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + + // create a record folder + String parentFolderId = createCategoryFolderInFilePlan().getId(); + + // create records + FilePlanComponent recordElectronic = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), UNFILED_RECORDS_CONTAINER_ALIAS); + FilePlanComponent recordNonElect = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); + + // file the record into the folder created + RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(parentFolderId).build(); + FilePlanComponent recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + FilePlanComponent nonElectronicFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); + // check the response status + assertStatusCode(CREATED); + + // create the second folder + String folderToLink = createCategoryFolderInFilePlan().getId(); + recordBodyFile = RecordBodyFile.builder().targetParentId(folderToLink).build(); + + // check the response status + assertStatusCode(CREATED); + // link the electronic record + FilePlanComponent recordLink = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); + assertTrue(recordLink.getParentId().equals(parentFolderId)); + // check the response status code + assertStatusCode(CREATED); + // link the nonelectronic record + FilePlanComponent nonElectronicLink = recordsAPI.fileRecord(recordBodyFile, nonElectronicFiled.getId()); + assertStatusCode(CREATED); + assertTrue(nonElectronicLink.getParentId().equals(parentFolderId)); + + // check the record is added into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(parentFolderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordFiled.getId()) && + c.getFilePlanComponentModel().getParentId().equals(parentFolderId))); + + // check the record doesn't exist into unfiled record container + // TODO add a check after the issue will be fixed RM-4578 + assertTrue(filePlanComponentAPI.listChildComponents(folderToLink) + .getEntries().stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordFiled.getId()))); + + // check the record is added into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(parentFolderId) + .getEntries().stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(nonElectronicFiled.getId()) && + c.getFilePlanComponentModel().getParentId().equals(parentFolderId))); + + // check the record doesn't exist into unfiled record container + // TODO add a check after the issue will be fixed RM-4578 + assertTrue(filePlanComponentAPI.listChildComponents(folderToLink) + .getEntries().stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(nonElectronicFiled.getId()))); + } + + /** + * Given an unfiled or filed record + * And a container that is NOT a record folder + * When I file the unfiled or filed record to the container + * Then I get an unsupported operation exception + */ @Test ( dataProvider = "invalidContainersForFile", @@ -315,18 +317,21 @@ public class FileRecordsTests extends BaseRMRestTest ) public void invalidContainerToFile(String containerId) throws Exception { + // get API instances + FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + + // create records + FilePlanComponent recordElectronic = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), UNFILED_RECORDS_CONTAINER_ALIAS); + FilePlanComponent recordNonElect = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - //create records - FilePlanComponent recordElectronic = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), UNFILED_RECORDS_CONTAINER_ALIAS); - FilePlanComponent recordNonElect = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); - - //file the record into the folder created + // file the record into the folder created RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(containerId).build(); - getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); + recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); assertStatusCode(BAD_REQUEST); - getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElect.getId()); - //check the response status + recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); + // check the response status assertStatusCode(BAD_REQUEST); } @@ -336,64 +341,63 @@ public class FileRecordsTests extends BaseRMRestTest * Then the filePlan structure from relativePath is created and the record is filed into the specified path */ @Test - ( - dataProvider = "unfiledContainer", - description = "File record from unfiled containers " - ) + ( + dataProvider = "unfiledContainer", + description = "File record from unfiled containers " + ) public void fileRecordIntoRelativePath(String unfiledContainerId) throws Exception { - //create a record folder + // get API instances + FilePlanComponentAPI filePlanComponentAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); + + // create a record folder String RELATIVE_PATH = "CATEGORY" + getRandomAlphanumeric() + "/FOLDER"; - //create records - FilePlanComponent recordElectronic = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); - FilePlanComponent recordNonElectId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, unfiledContainerId); + // create records + FilePlanComponent recordElectronic = filePlanComponentAPI.createElectronicRecord(electronicRecord, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME), unfiledContainerId); + FilePlanComponent recordNonElectId = filePlanComponentAPI.createFilePlanComponent(nonelectronicRecord, unfiledContainerId); - //file the record into the folder created + // file the record into the folder created RecordBodyFile recordBodyFile = RecordBodyFile.builder().relativePath(RELATIVE_PATH).build(); - FilePlanComponent recordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId()); + FilePlanComponent recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId()); - //check the response status + // check the response status assertStatusCode(CREATED); - //Get the folder ID created - String folderId= getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(FILE_PLAN_ALIAS, "relativePath="+RELATIVE_PATH).getId(); - //check the parent id for the record returned + // get the folder ID created + String folderId = filePlanComponentAPI.getFilePlanComponent(FILE_PLAN_ALIAS, "relativePath="+RELATIVE_PATH).getId(); + // check the parent id for the record returned assertEquals(recordFiled.getParentId(), folderId); - //check the record is filed into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordElectronic.getId()) - ) - ); - //file the non-electronic record into the folder created - FilePlanComponent nonElectRecordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElectId.getId()); - //check the response status code + // check the record is filed into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // check the record doesn't exist into unfiled record container + assertFalse(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordElectronic.getId()))); + + // file the non-electronic record into the folder created + FilePlanComponent nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElectId.getId()); + // check the response status code assertStatusCode(CREATED); - //check the parent id for the record returned + // check the parent id for the record returned assertEquals(nonElectRecordFiled.getParentId(), folderId); - //check the record is added into the record folder - assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(folderId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); - //check the record doesn't exist into unfiled record container - assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId) - .getEntries().stream() - .anyMatch(c -> c.getFilePlanComponentModel().getId() - .equals(recordNonElectId.getId()) - ) - ); + + // check the record is added into the record folder + assertTrue(filePlanComponentAPI.listChildComponents(folderId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); + + // check the record doesn't exist into unfiled record container + assertFalse(filePlanComponentAPI.listChildComponents(unfiledContainerId) + .getEntries() + .stream() + .anyMatch(c -> c.getFilePlanComponentModel().getId().equals(recordNonElectId.getId()))); } - }