mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4405: invalid containers tests + utility method renaming
This commit is contained in:
@@ -51,7 +51,6 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent
|
|||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.context.annotation.Scope;
|
import org.springframework.context.annotation.Scope;
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,8 +172,6 @@ public class FilePlanComponentAPI extends RestAPI<FilePlanComponentAPI>
|
|||||||
.auth().basic(currentUser.getUsername(), currentUser.getPassword())
|
.auth().basic(currentUser.getUsername(), currentUser.getPassword())
|
||||||
.multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name())
|
.multiPart("nodeBodyCreate", toJson(electronicRecordModel), ContentType.JSON.name())
|
||||||
.multiPart("filedata", recordContent, ContentType.BINARY.name())
|
.multiPart("filedata", recordContent, ContentType.BINARY.name())
|
||||||
.expect()
|
|
||||||
.statusCode(HttpStatus.CREATED.value())
|
|
||||||
.when()
|
.when()
|
||||||
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters())
|
.post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters())
|
||||||
.andReturn();
|
.andReturn();
|
||||||
|
@@ -30,7 +30,6 @@ import static java.lang.Integer.parseInt;
|
|||||||
|
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE;
|
import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE;
|
||||||
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
|
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
|
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.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.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
|
||||||
@@ -222,7 +221,7 @@ public class BaseRestTest extends RestTest
|
|||||||
* @return record folder
|
* @return record folder
|
||||||
* @throws Exception on failed creation
|
* @throws Exception on failed creation
|
||||||
*/
|
*/
|
||||||
public FilePlanComponent createFolderInFilePlan(UserModel user, String parentId) throws Exception
|
public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception
|
||||||
{
|
{
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
|
||||||
|
|
||||||
|
@@ -12,10 +12,13 @@
|
|||||||
package org.alfresco.rest.rm.community.fileplancomponents;
|
package org.alfresco.rest.rm.community.fileplancomponents;
|
||||||
|
|
||||||
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.HOLDS_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.FilePlanComponentType.CONTENT_TYPE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
|
||||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRestTest;
|
||||||
@@ -43,12 +46,28 @@ public class ElectronicRecordTests extends BaseRestTest
|
|||||||
/** image resource file to be used for records body */
|
/** image resource file to be used for records body */
|
||||||
private static final String IMAGE_FILE = "money.JPG";
|
private static final String IMAGE_FILE = "money.JPG";
|
||||||
|
|
||||||
|
/** Valid root containers where non-electronic records can be created */
|
||||||
|
@DataProvider(name = "invalidParentContainers")
|
||||||
|
public Object[][] invalidContainers() throws Exception {
|
||||||
|
return new Object[][] {
|
||||||
|
// record category
|
||||||
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(),
|
||||||
|
createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) },
|
||||||
|
// file plan root
|
||||||
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
||||||
|
// transfers
|
||||||
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS.toString()) },
|
||||||
|
// holds
|
||||||
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/** Valid root containers where non-electronic records can be created */
|
/** Valid root containers where non-electronic records can be created */
|
||||||
@DataProvider(name = "validContainers")
|
@DataProvider(name = "validContainers")
|
||||||
public Object[][] rootContainers() throws Exception {
|
public Object[][] rootContainers() throws Exception {
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
// an arbitrary record folder
|
// an arbitrary record folder
|
||||||
{ createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
||||||
// unfiled records root
|
// unfiled records root
|
||||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
|
||||||
// an arbitrary unfiled records folder
|
// an arbitrary unfiled records folder
|
||||||
@@ -57,6 +76,41 @@ public class ElectronicRecordTests extends BaseRestTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given a parent container that is NOT a record folder or an unfiled record folder
|
||||||
|
* When I try to create an electronic record within the parent container
|
||||||
|
* Then nothing happens
|
||||||
|
* And an error is reported
|
||||||
|
* </pre>
|
||||||
|
* @param container
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
(
|
||||||
|
dataProvider = "invalidParentContainers",
|
||||||
|
description = "Electronic records can't be created in invalid parent containers"
|
||||||
|
)
|
||||||
|
public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponent container) throws Exception
|
||||||
|
{
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
FilePlanComponent record = new FilePlanComponent("Record " + getRandomAlphanumeric(), CONTENT_TYPE.toString(),
|
||||||
|
new FilePlanComponentProperties());
|
||||||
|
filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId());
|
||||||
|
|
||||||
|
// verify the create request status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <pre>
|
||||||
|
* Given a parent container that is a record folder
|
||||||
|
* And the record folder is open
|
||||||
|
* When I try to create an electronic record within the parent container
|
||||||
|
* Then the electronic record is created
|
||||||
|
* And the details of the new record are returned
|
||||||
|
* </pre>
|
||||||
|
* and
|
||||||
* <pre>
|
* <pre>
|
||||||
* Given a parent container that is an unfiled record folder or the root unfiled record container
|
* Given a parent container that is an unfiled record folder or the root unfiled record container
|
||||||
* When I try to create an electronic record within the parent container
|
* When I try to create an electronic record within the parent container
|
||||||
|
@@ -81,7 +81,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
|||||||
public Object[][] rootContainers() throws Exception {
|
public Object[][] rootContainers() throws Exception {
|
||||||
return new Object[][] {
|
return new Object[][] {
|
||||||
// an arbitrary record folder
|
// an arbitrary record folder
|
||||||
{ createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
{ createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) },
|
||||||
// unfiled records root
|
// unfiled records root
|
||||||
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
|
{ getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) },
|
||||||
// an arbitrary unfiled records folder
|
// an arbitrary unfiled records folder
|
||||||
@@ -225,7 +225,7 @@ public class NonElectronicRecordTests extends BaseRestTest
|
|||||||
public void cantCreateInClosedFolder() throws Exception
|
public void cantCreateInClosedFolder() throws Exception
|
||||||
{
|
{
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
FilePlanComponent recordFolder = createFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
|
FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
|
||||||
|
|
||||||
// the folder should be open
|
// the folder should be open
|
||||||
assertFalse(recordFolder.getProperties().getIsClosed());
|
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||||
|
Reference in New Issue
Block a user