mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4430: Pre-merge import and javadoc tidy-up, minor improvements
This commit is contained in:
@@ -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;
|
||||
|
@@ -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,17 +317,20 @@ 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 = 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);
|
||||
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(containerId).build();
|
||||
getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId());
|
||||
recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
|
||||
getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElect.getId());
|
||||
recordsAPI.fileRecord(recordBodyFile, recordNonElect.getId());
|
||||
// check the response status
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
@@ -342,58 +347,57 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
)
|
||||
public void fileRecordIntoRelativePath(String unfiledContainerId) throws Exception
|
||||
{
|
||||
// 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);
|
||||
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().relativePath(RELATIVE_PATH).build();
|
||||
FilePlanComponent recordFiled = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordElectronic.getId());
|
||||
FilePlanComponent recordFiled = recordsAPI.fileRecord(recordBodyFile, recordElectronic.getId());
|
||||
|
||||
// check the response status
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
//Get the folder ID created
|
||||
String folderId= getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(FILE_PLAN_ALIAS, "relativePath="+RELATIVE_PATH).getId();
|
||||
// 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())
|
||||
)
|
||||
);
|
||||
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(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId)
|
||||
.getEntries().stream()
|
||||
.anyMatch(c -> c.getFilePlanComponentModel().getId()
|
||||
.equals(recordElectronic.getId())
|
||||
)
|
||||
);
|
||||
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 = getRestAPIFactory().getRecordsAPI().fileRecord(recordBodyFile, recordNonElectId.getId());
|
||||
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(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())));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user