Check rma:recordSearch aspect is still present after records filing

This commit is contained in:
cagache
2019-12-09 16:57:31 +02:00
parent 56b82d8380
commit fcc10dd091
6 changed files with 192 additions and 267 deletions

View File

@@ -34,6 +34,11 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
*/ */
public class FilePlanComponentAspects public class FilePlanComponentAspects
{ {
/** Private constructor to prevent instantiation. */
private FilePlanComponentAspects()
{
}
// aspect present on completed records // aspect present on completed records
public static final String ASPECTS_COMPLETED_RECORD = "rma:declaredRecord"; public static final String ASPECTS_COMPLETED_RECORD = "rma:declaredRecord";
@@ -42,4 +47,10 @@ public class FilePlanComponentAspects
// aspect present on vital records // aspect present on vital records
public static final String ASPECTS_VITAL_RECORD = "rma:vitalRecord"; public static final String ASPECTS_VITAL_RECORD = "rma:vitalRecord";
// Frozen aspect
public static final String FROZEN_ASPECT = "rma:frozen";
// recordSearch aspect
public static final String RECORD_SEARCH_ASPECT = "rma:recordSearch";
} }

View File

@@ -818,7 +818,7 @@ public class BaseRMRestTest extends RestTest
*/ */
protected boolean hasAspect(String nodeId, String aspectName) throws Exception protected boolean hasAspect(String nodeId, String aspectName) throws Exception
{ {
return hasAspect(toFileModel(nodeId),aspectName); return hasAspect(toFileModel(nodeId), aspectName);
} }
/** /**

View File

@@ -107,9 +107,4 @@ public interface TestData
* The default hold reason * The default hold reason
*/ */
String HOLD_REASON = "Active content to be reviewed for the CASE McDermott, FINRA "; String HOLD_REASON = "Active content to be reviewed for the CASE McDermott, FINRA ";
/**
* Frozen aspect
*/
String FROZEN_ASPECT = "rma:frozen";
} }

View File

@@ -26,12 +26,13 @@
*/ */
package org.alfresco.rest.rm.community.hold; package org.alfresco.rest.rm.community.hold;
import static org.alfresco.rest.rm.community.base.TestData.FROZEN_ASPECT;
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_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.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;

View File

@@ -28,9 +28,9 @@ package org.alfresco.rest.rm.community.hold;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.alfresco.rest.rm.community.base.TestData.FROZEN_ASPECT;
import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION; import static org.alfresco.rest.rm.community.base.TestData.HOLD_DESCRIPTION;
import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON; import static org.alfresco.rest.rm.community.base.TestData.HOLD_REASON;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.FROZEN_ASPECT;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_READ_RECORDS;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;

View File

@@ -31,6 +31,7 @@ import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_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.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAspects.RECORD_SEARCH_ASPECT;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
@@ -41,7 +42,7 @@ import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.Assert.assertTrue;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record; import org.alfresco.rest.rm.community.model.record.Record;
@@ -50,10 +51,10 @@ import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
import org.alfresco.utility.report.Bug; import org.alfresco.utility.report.Bug;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -67,19 +68,35 @@ import org.testng.annotations.Test;
public class FileRecordsTests extends BaseRMRestTest public class FileRecordsTests extends BaseRMRestTest
{ {
private UnfiledContainerChild electronicRecord = UnfiledContainerChild.builder() private UnfiledContainerChild electronicRecord = UnfiledContainerChild.builder()
.name(ELECTRONIC_RECORD_NAME) .name(ELECTRONIC_RECORD_NAME)
.nodeType(CONTENT_TYPE) .nodeType(CONTENT_TYPE)
.content(RecordContent.builder().mimeType("text/plain").build()) .content(RecordContent.builder().mimeType("text/plain").build())
.build(); .build();
private UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder() private UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder()
.properties(UnfiledContainerChildProperties.builder() .properties(UnfiledContainerChildProperties.builder()
.description(NONELECTRONIC_RECORD_NAME) .description(NONELECTRONIC_RECORD_NAME)
.title("Title") .title("Title")
.build()) .build())
.name(NONELECTRONIC_RECORD_NAME) .name(NONELECTRONIC_RECORD_NAME)
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
private String targetFolderId, folderToLink, closedFolderId, unfiledRecordFolderId;
@BeforeClass (alwaysRun = true)
public void setupFileRecordsTests() throws Exception
{
// create 3 record folders and close one of them
targetFolderId = createCategoryFolderInFilePlan().getId();
folderToLink = createCategoryFolderInFilePlan().getId();
closedFolderId = createCategoryFolderInFilePlan().getId();
closeFolder(closedFolderId);
//create one unfiled record folder
unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
"Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
}
/** /**
* Invalid containers where electronic and non-electronic records can be filed * Invalid containers where electronic and non-electronic records can be filed
@@ -98,66 +115,62 @@ public class FileRecordsTests extends BaseRMRestTest
}; };
} }
/**
* Returns the ids of unfiled electronic and non-electronic records from Unfiled Records container
*/
@DataProvider (name = "unfiledRecordsFromUnfiledRecordsContainer")
public Object[][] getRecordsFromUnfiledRecordsContainer()
{
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord,
UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
return new String[][] {
{ recordElectronic.getId()},
{ recordNonElect.getId()}
};
}
/**
* Returns the ids of unfiled electronic and non-electronic records from an Unfiled Record Folder
*/
@DataProvider (name = "unfiledRecordsFromUnfiledRecordFolder")
public Object[][] getRecordsFromUnfiledRecordFolder()
{
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId,
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId);
return new String[][] {
{ recordElectronic.getId()},
{ recordNonElect.getId()}
};
}
/** /**
* Given an unfiled record in the root unfiled record container * Given an unfiled record in the root unfiled record container
* And an open record folder * And an open record folder
* When I file the unfiled record into the record folder * When I file the unfiled record into the record folder
* Then the record is filed * Then the record is filed
*/ */
@Test @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer")
public void fileRecordIntoExistingFolderFromUnfiledContainer() throws Exception public void fileRecordFromUnfiledContainerToOpenFolder(String unfiledRecordId) throws Exception
{ {
// get API instances // file the record to the folder created
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId);
// create a record folder
String folderId = createCategoryFolderInFilePlan().getId();
// create records
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS,
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
// file the record into the folder created
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build();
Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
// check the response status // check the response status
assertStatusCode(CREATED); assertStatusCode(CREATED);
// check the parent id for the record returned // check the parent id for the record returned
assertEquals(recordFiled.getParentId(),folderId); assertEquals(recordFiled.getParentId(), targetFolderId);
// check the record is filed into the record folder // check the record is filed to the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); assertTrue(isRecordChildOfRecordFolder(unfiledRecordId, targetFolderId), unfiledRecordId + " is not filed to " + targetFolderId);
assertTrue(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// check the record doesn't exist into unfiled record container // check the record doesn't exist into unfiled record container
assertFalse(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) assertFalse(isRecordChildOfUnfiledContainer(unfiledRecordId), unfiledRecordId + " exists in Unfiled Records");
.getEntries() assertTrue(hasAspect(unfiledRecordId, RECORD_SEARCH_ASPECT), "recordSearch aspect is lost after filing!");
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// file the non-electronic record into the folder created
Record nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.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(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
// check the record doesn't exist into unfiled record container
assertFalse(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
} }
/** /**
@@ -166,62 +179,23 @@ public class FileRecordsTests extends BaseRMRestTest
* When I file the unfiled record into the record folder * When I file the unfiled record into the record folder
* Then the record is filed * Then the record is filed
*/ */
@Test @Test (dataProvider = "unfiledRecordsFromUnfiledRecordFolder")
public void fileRecordIntoExistingFolderFromUnfiledRecordFolder() throws Exception public void fileRecordFromUnfiledRecordFolderToOpenFolder(String unfiledRecordId) throws Exception
{ {
// get API instances // file the record to the folder created
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId);
// create a record folder
String folderId = createCategoryFolderInFilePlan().getId();
// create records
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId);
// file the record into the folder created
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build();
Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
// check the response status // check the response status
assertStatusCode(CREATED); assertStatusCode(CREATED);
// check the parent id for the record returned // check the parent id for the record returned
assertEquals(recordFiled.getParentId(),folderId); assertEquals(recordFiled.getParentId(), targetFolderId);
// check the record is filed into the record folder // check the record is filed to the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); assertTrue(isRecordChildOfRecordFolder(unfiledRecordId, targetFolderId), unfiledRecordId + " is not filed to " + targetFolderId);
assertTrue(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// check the record doesn't exist into unfiled record folder // check the record doesn't exist into unfiled record folder
assertFalse(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) assertFalse(isRecordChildOfUnfiledRecordFolder(unfiledRecordId),
.getEntries() unfiledRecordId + " exists in " + unfiledRecordFolderId);
.stream() assertTrue(hasAspect(unfiledRecordId, RECORD_SEARCH_ASPECT), "recordSearch aspect is lost after filing!");
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// file the non-electronic record into the folder created
Record nonElectRecordFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.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(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
// check the record doesn't exist into unfiled record folder
assertFalse(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
} }
/** /**
@@ -231,55 +205,19 @@ public class FileRecordsTests extends BaseRMRestTest
* Then I get an unsupported operation exception * Then I get an unsupported operation exception
* *
*/ */
@Test @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer")
public void fileRecordIntoCloseFolderFromUnfiledContainer() throws Exception public void fileRecordFromUnfiledContainerToClosedFolder(String unfiledRecordId)
{ {
// get API instances // file the record to the closed record folder
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); fileRecordToFolder(unfiledRecordId, closedFolderId);
// create a record folder
String folderId = createCategoryFolderInFilePlan().getId();
closeFolder(folderId);
// create records
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
// file the record into the folder created
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build();
recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
// check the response status // check the response status
assertStatusCode(FORBIDDEN); assertStatusCode(FORBIDDEN);
// check the record is not filed into the record folder // check the record is not filed to the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); assertFalse(isRecordChildOfRecordFolder(unfiledRecordId, closedFolderId), unfiledRecordId + " is filed to " + closedFolderId);
assertFalse(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// check the record exist into unfiled record container // check the record exist into unfiled record container
assertTrue(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) assertTrue(isRecordChildOfUnfiledContainer(unfiledRecordId), unfiledRecordId + " doesn't exist in Unfiled Records");
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// file the non-electronic record into the folder created
recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId());
// check the response status code
assertStatusCode(FORBIDDEN);
// check the record is not added into the record folder
assertFalse(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
// check the record exist into unfiled record container
assertTrue(unfiledContainersAPI.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
.getEntries().stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
} }
/** /**
@@ -289,56 +227,20 @@ public class FileRecordsTests extends BaseRMRestTest
* Then I get an unsupported operation exception * Then I get an unsupported operation exception
* *
*/ */
@Test @Test(dataProvider = "unfiledRecordsFromUnfiledRecordFolder")
public void fileRecordIntoCloseFolderFromUnfiledRecordFolder() throws Exception public void fileRecordFromUnfiledRecordFolderToClosedFolder(String unfiledRecordId)
{ {
// get API instances // file the record into the closed folder created
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); fileRecordToFolder(unfiledRecordId, closedFolderId);
// create a record folder
String folderId = createCategoryFolderInFilePlan().getId();
closeFolder(folderId);
// create records
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId);
// file the record into the folder created
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(folderId).build();
recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
// check the response status // check the response status
assertStatusCode(FORBIDDEN); assertStatusCode(FORBIDDEN);
// check the record is not filed into the record folder // check the record is not filed into the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); assertFalse(isRecordChildOfRecordFolder(unfiledRecordId, closedFolderId), unfiledRecordId + " is filed to " + closedFolderId);
assertFalse(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// check the record exist into unfiled record folder // check the record exist into unfiled record folder
assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId) assertTrue(isRecordChildOfUnfiledRecordFolder(unfiledRecordId),
.getEntries() unfiledRecordId + " doesn't exist in " + unfiledRecordFolderId);
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordElectronic.getId())));
// file the non-electronic record into the folder created
recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId());
// check the response status code
assertStatusCode(FORBIDDEN);
// check the record is not added into the record folder
assertFalse(recordFolderAPI.getRecordFolderChildren(folderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
// check the record exist into unfiled record folder
assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolderChildren(unfiledRecordFolderId)
.getEntries().stream()
.anyMatch(c -> c.getEntry().getId().equals(recordNonElect.getId())));
} }
/** /**
@@ -347,71 +249,34 @@ public class FileRecordsTests extends BaseRMRestTest
* When I file the filed record into the record folder * When I file the filed record into the record folder
* Then the record is filed in both locations * Then the record is filed in both locations
*/ */
@Test @Test (dataProvider = "unfiledRecordsFromUnfiledRecordsContainer")
@Bug(id="RM-4578") @Bug (id = "RM-4578")
public void linkRecordInto() throws Exception public void linkRecordInto(String unfiledRecordId)
{ {
// get API instances // file the record to the open folder created
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); Record recordFiled = fileRecordToFolder(unfiledRecordId, targetFolderId);
// create a record folder
String parentFolderId = createCategoryFolderInFilePlan().getId();
// create records
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
// file the record into the folder created
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(parentFolderId).build();
Record recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
Record nonElectronicFiled = recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId());
// check the response status // check the response status
assertStatusCode(CREATED); assertStatusCode(CREATED);
// create the second folder // link the record to the second folder
String folderToLink = createCategoryFolderInFilePlan().getId(); Record recordLink = fileRecordToFolder(unfiledRecordId, folderToLink);
recordBodyFile = RecordBodyFile.builder().targetParentId(folderToLink).build();
// check the response status
assertStatusCode(CREATED); assertStatusCode(CREATED);
// link the electronic record assertTrue(recordLink.getParentId().equals(targetFolderId));
Record recordLink = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
assertTrue(recordLink.getParentId().equals(parentFolderId));
// check the response status code
assertStatusCode(CREATED);
// link the nonelectronic record
Record nonElectronicLink = recordsAPI.fileRecord(recordBodyFile, nonElectronicFiled.getId());
assertStatusCode(CREATED);
assertTrue(nonElectronicLink.getParentId().equals(parentFolderId));
// check the record is added into the record folder // check the record is added into the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId) assertTrue(recordFolderAPI.getRecordFolderChildren(targetFolderId)
.getEntries() .getEntries()
.stream() .stream()
.anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) &&
c.getEntry().getParentId().equals(parentFolderId))); c.getEntry().getParentId().equals(targetFolderId)));
// check the record doesn't exist into unfiled record container // check the record has a link in the second folder
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink) assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
.getEntries().stream() .getEntries().stream()
.anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) && .anyMatch(c -> c.getEntry().getId().equals(recordFiled.getId()) &&
c.getEntry().getParentId().equals(parentFolderId) && c.getEntry().getParentId().equals(targetFolderId) &&
!c.getEntry().getParentId().equals(folderToLink))); !c.getEntry().getParentId().equals(folderToLink)));
// check the record is added into the record folder
assertTrue(recordFolderAPI.getRecordFolderChildren(parentFolderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId()) &&
c.getEntry().getParentId().equals(parentFolderId)));
// check the record doesn't exist into unfiled record container
assertTrue(recordFolderAPI.getRecordFolderChildren(folderToLink)
.getEntries().stream()
.anyMatch(c -> c.getEntry().getId().equals(nonElectronicFiled.getId()) &&
c.getEntry().getParentId().equals(parentFolderId) &&
!c.getEntry().getParentId().equals(folderToLink)));
} }
/** /**
@@ -425,24 +290,77 @@ public class FileRecordsTests extends BaseRMRestTest
dataProvider = "invalidContainersToFile", dataProvider = "invalidContainersToFile",
description = "File the unfiled record to the container that is not a record folder" description = "File the unfiled record to the container that is not a record folder"
) )
public void invalidContainerToFile(String containerId) throws Exception public void invalidContainerToFile(String containerId)
{ {
// get API instances
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
// create records // create records
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)); UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS); UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
// file the record into the folder created // file the records to a container that is not a record folder
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(containerId).build(); fileRecordToFolder(recordElectronic.getId(), containerId);
recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId()); fileRecordToFolder(recordNonElect.getId(), containerId);
// check the response status
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
} }
/**
* Files the given record in the target record folder.
*
* @param recordId the id of the record to be filed
* @param targetFolderId the id of the target record folder
*/
private Record fileRecordToFolder(String recordId, String targetFolderId)
{
RecordBodyFile recordBodyFile = RecordBodyFile.builder().targetParentId(targetFolderId).build();
return getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordId);
}
/**
* Returns whether any child of the record folder match the provided record
*
* @param recordId the record id
* @param recordFolderId the record folder id
* @return true if any child of the record folder match the provided record, false otherwise
*/
private boolean isRecordChildOfRecordFolder(String recordId, String recordFolderId)
{
return getRestAPIFactory().getRecordFolderAPI()
.getRecordFolderChildren(recordFolderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordId));
}
/**
* Returns whether any child of the unfiled record folder match the provided record
*
* @param recordId the record id
* @return true if any child of the unfiled record folder match the provided record, false otherwise
*/
private boolean isRecordChildOfUnfiledRecordFolder(String recordId)
{
return getRestAPIFactory().getUnfiledRecordFoldersAPI()
.getUnfiledRecordFolderChildren(unfiledRecordFolderId)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordId));
}
/**
* Returns whether any child of the unfiled container match the provided record
*
* @param recordId the record id
* @return true if any child of the unfiled container match the provided record, false otherwise
*/
private boolean isRecordChildOfUnfiledContainer(String recordId)
{
return getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
.getEntries()
.stream()
.anyMatch(c -> c.getEntry().getId().equals(recordId));
}
} }