mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- updates and add tests
This commit is contained in:
@@ -119,14 +119,15 @@ public class RecordsAPI extends RMModelRequest
|
||||
* @param recordId The id of the record to file
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to add children to {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>new name clashes with an existing node in the current parent container</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
* <ul>
|
||||
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is not a record</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to file to {@code fileplanComponentId}</li>
|
||||
* <li>{@code recordId} does not exist</li>
|
||||
* <li>targetParentId from recordBodyFile does not exist</li>
|
||||
* <li>model integrity exception: the action breaks system's integrity restrictions</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
public FilePlanComponent fileRecord(RecordBodyFile recordBodyFile, String recordId) throws Exception
|
||||
{
|
||||
@@ -137,21 +138,21 @@ public class RecordsAPI extends RMModelRequest
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a file plan component with the given properties under the parent node with the given id
|
||||
* File the record recordId into file plan structure based on the location sent via the request body
|
||||
*
|
||||
* @param filePlanComponentModel The properties of the file plan component to be created
|
||||
* @param parameters The URL parameters to add
|
||||
* @param parentId The id of the parent where the new file plan component should be created
|
||||
* @param recordBodyFile The properties where to file the record
|
||||
* @param recordId The id of the record to file
|
||||
* @return The {@link FilePlanComponent} with the given properties
|
||||
* @throws Exception for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code fileplanComponentId} is not a valid format</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to add children to {@code fileplanComponentId}</li>
|
||||
* <li>{@code fileplanComponentId} does not exist</li>
|
||||
* <li>new name clashes with an existing node in the current parent container</li>
|
||||
* <li>model integrity exception, including node name with invalid characters</li>
|
||||
* </ul>
|
||||
* <ul>
|
||||
* <li>Invalid parameter: {@code recordBodyFile} is not a valid format,{@code recordId} is not a record</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to file to {@code fileplanComponentId}</li>
|
||||
* <li>{@code recordId} does not exist</li>
|
||||
* <li>targetParentId from recordBodyFile does not exist</li>
|
||||
* <li>model integrity exception: the action breaks system's integrity restrictions</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
public FilePlanComponent fileRecord(RecordBodyFile recordBodyFile, String recordId, String parameters) throws Exception
|
||||
{
|
||||
|
@@ -55,15 +55,32 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
* When I file the unfiled record into the record folder
|
||||
* Then the record is filed
|
||||
*/
|
||||
/**
|
||||
* Unfiled containers from where record can be filed
|
||||
*/
|
||||
@DataProvider (name = "unfiledContainer")
|
||||
public Object[][] getUnfiledContainer() throws Exception
|
||||
{
|
||||
return new Object[][] {
|
||||
//unfiled container
|
||||
{ getFilePlanComponent(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
|
||||
// an arbitrary unfiled records folder
|
||||
{ createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()).getId() }
|
||||
};
|
||||
}
|
||||
@Test
|
||||
public void fileRecordIntoExistingFolder() throws Exception
|
||||
(
|
||||
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), UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
FilePlanComponent recordNonElectId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
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();
|
||||
@@ -80,7 +97,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
)
|
||||
);
|
||||
//check the record doesn't exist into unfiled record container
|
||||
assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId)
|
||||
.getEntries().stream()
|
||||
.anyMatch(c -> c.getFilePlanComponentModel().getId()
|
||||
.equals(recordElectronic.getId())
|
||||
@@ -100,7 +117,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
)
|
||||
);
|
||||
//check the record doesn't exist into unfiled record container
|
||||
assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
assertFalse(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId)
|
||||
.getEntries().stream()
|
||||
.anyMatch(c -> c.getFilePlanComponentModel().getId()
|
||||
.equals(recordNonElectId.getId())
|
||||
@@ -116,14 +133,18 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void fileRecordIntoCloseFolder() throws Exception
|
||||
(
|
||||
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), UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
FilePlanComponent recordNonElectId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
|
||||
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();
|
||||
@@ -139,7 +160,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
)
|
||||
);
|
||||
//check the record doesn't exist into unfiled record container
|
||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId)
|
||||
.getEntries().stream()
|
||||
.anyMatch(c -> c.getFilePlanComponentModel().getId()
|
||||
.equals(recordElectronic.getId())
|
||||
@@ -157,7 +178,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
)
|
||||
);
|
||||
//check the record doesn't exist into unfiled record container
|
||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(UNFILED_RECORDS_CONTAINER_ALIAS)
|
||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(unfiledContainerId)
|
||||
.getEntries().stream()
|
||||
.anyMatch(c -> c.getFilePlanComponentModel().getId()
|
||||
.equals(recordNonElectId.getId())
|
||||
@@ -245,7 +266,7 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
* Then I get an unsupported operation exception
|
||||
*/
|
||||
/**
|
||||
* Valid root containers where electronic and non-electronic records can be created
|
||||
* Invalid containers where electronic and non-electronic records can be filed
|
||||
*/
|
||||
@DataProvider (name = "invalidContainersForFile")
|
||||
public Object[][] getFolderContainers() throws Exception
|
||||
@@ -283,4 +304,70 @@ public class FileRecordsTests extends BaseRMRestTest
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an unfiled record in the root unfiled record container or a unfiled record folder
|
||||
* When I file the unfiled record into the record folder using the relativePath
|
||||
* 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 "
|
||||
)
|
||||
public void fileRecordIntoRelativePath(String unfiledContainerId) throws Exception
|
||||
{
|
||||
//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);
|
||||
|
||||
//file the record into the folder created
|
||||
RecordBodyFile recordBodyFile = RecordBodyFile.builder().relativePath(RELATIVE_PATH).build();
|
||||
FilePlanComponent recordFiled = getRestAPIFactory().getRecordsAPI().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();
|
||||
//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())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user