mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4391: Closed folder creation test.
This commit is contained in:
@@ -48,6 +48,7 @@ public class FilePlanComponentFields
|
|||||||
public static final String IS_CLOSED = "isClosed";
|
public static final String IS_CLOSED = "isClosed";
|
||||||
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
|
public static final String PROPERTIES_REVIEW_PERIOD = "rma:reviewPeriod";
|
||||||
public static final String PROPERTIES_LOCATION = "rma:location";
|
public static final String PROPERTIES_LOCATION = "rma:location";
|
||||||
|
public static final String PROPERTIES_IS_CLOSED = "rma:isClosed"; // not to be confused with IS_CLOSED!
|
||||||
|
|
||||||
// for non-electronic records
|
// for non-electronic records
|
||||||
public static final String PROPERTIES_BOX = "rma:box";
|
public static final String PROPERTIES_BOX = "rma:box";
|
||||||
|
@@ -30,6 +30,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_FILE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_FILE;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_HOLD_REASON;
|
||||||
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_IS_CLOSED;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_NUMBER_OF_COPIES;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_NUMBER_OF_COPIES;
|
||||||
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PHYSICAL_SIZE;
|
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_PHYSICAL_SIZE;
|
||||||
@@ -80,6 +81,9 @@ public class FilePlanComponentProperties
|
|||||||
@JsonProperty(PROPERTIES_LOCATION)
|
@JsonProperty(PROPERTIES_LOCATION)
|
||||||
private String location;
|
private String location;
|
||||||
|
|
||||||
|
@JsonProperty(value = PROPERTIES_IS_CLOSED, required = false)
|
||||||
|
private Boolean isClosed;
|
||||||
|
|
||||||
@JsonProperty(value = PROPERTIES_BOX, required = false)
|
@JsonProperty(value = PROPERTIES_BOX, required = false)
|
||||||
private String box;
|
private String box;
|
||||||
|
|
||||||
@@ -303,4 +307,20 @@ public class FilePlanComponentProperties
|
|||||||
{
|
{
|
||||||
this.physicalSize = physicalSize;
|
this.physicalSize = physicalSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the isClosed
|
||||||
|
*/
|
||||||
|
public Boolean getIsClosed()
|
||||||
|
{
|
||||||
|
return this.isClosed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param isClosed the isClosed to set
|
||||||
|
*/
|
||||||
|
public void setIsClosed(Boolean isClosed)
|
||||||
|
{
|
||||||
|
this.isClosed = isClosed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
|
|||||||
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.site.RMSiteCompliance.STANDARD;
|
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
|
||||||
import static org.springframework.http.HttpStatus.CREATED;
|
import static org.springframework.http.HttpStatus.CREATED;
|
||||||
|
import static org.springframework.http.HttpStatus.OK;
|
||||||
|
|
||||||
import com.jayway.restassured.RestAssured;
|
import com.jayway.restassured.RestAssured;
|
||||||
|
|
||||||
@@ -190,4 +191,24 @@ public class BaseRestTest extends RestTest
|
|||||||
return fpc;
|
return fpc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to close folder
|
||||||
|
* @param folderToClose
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public FilePlanComponent closeFolder(String folderId) throws Exception
|
||||||
|
{
|
||||||
|
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
|
||||||
|
// build fileplan component + properties for update request
|
||||||
|
FilePlanComponentProperties properties = new FilePlanComponentProperties();
|
||||||
|
properties.setIsClosed(true);
|
||||||
|
FilePlanComponent filePlanComponent = new FilePlanComponent();
|
||||||
|
filePlanComponent.setProperties(properties);
|
||||||
|
|
||||||
|
FilePlanComponent updatedComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent, folderId);
|
||||||
|
restWrapper.assertStatusCodeIs(OK);
|
||||||
|
return updatedComponent;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -121,24 +121,12 @@ public class NonElectronicRecordTests extends BaseRestTest
|
|||||||
public void canCreateInOpenFolder() throws Exception
|
public void canCreateInOpenFolder() throws Exception
|
||||||
{
|
{
|
||||||
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
FilePlanComponent recordFolder = createFolderInFilePlan();
|
||||||
// create root category
|
|
||||||
FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(
|
|
||||||
new FilePlanComponent("Category " + getRandomAlphanumeric(),
|
|
||||||
RECORD_CATEGORY_TYPE.toString(),
|
|
||||||
new FilePlanComponentProperties()),
|
|
||||||
FILE_PLAN_ALIAS.toString());
|
|
||||||
|
|
||||||
// create record folder as a child of recordCategory
|
|
||||||
FilePlanComponent recordFolder = filePlanComponentAPI.withParams("include=" + IS_CLOSED)
|
|
||||||
.createFilePlanComponent(new FilePlanComponent("Folder " + getRandomAlphanumeric(),
|
|
||||||
RECORD_FOLDER_TYPE.toString(),
|
|
||||||
new FilePlanComponentProperties()),
|
|
||||||
recordCategory.getId());
|
|
||||||
|
|
||||||
// the folder should be open
|
// the folder should be open
|
||||||
assertFalse(recordFolder.isClosed());
|
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||||
|
|
||||||
|
// use these properties for non-electronic record to be created
|
||||||
String title = "Title " + getRandomAlphanumeric();
|
String title = "Title " + getRandomAlphanumeric();
|
||||||
String description = "Description " + getRandomAlphanumeric();
|
String description = "Description " + getRandomAlphanumeric();
|
||||||
String box = "Box "+ getRandomAlphanumeric();
|
String box = "Box "+ getRandomAlphanumeric();
|
||||||
@@ -181,4 +169,54 @@ public class NonElectronicRecordTests extends BaseRestTest
|
|||||||
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
assertEquals(copies, nonElectronicRecord.getProperties().getNumberOfCopies());
|
||||||
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
assertEquals(size, nonElectronicRecord.getProperties().getPhysicalSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a parent container that is a record folder
|
||||||
|
* And the record folder is closed
|
||||||
|
* When I try to create a non-electronic record within the parent container
|
||||||
|
* Then nothing happens
|
||||||
|
* And an error is reported
|
||||||
|
* @throws Exception on failed component creation
|
||||||
|
*/
|
||||||
|
@Test(description = "Non-electronic record can't be created in closed record folder")
|
||||||
|
public void noCreateInClosedFolder() throws Exception
|
||||||
|
{
|
||||||
|
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
|
||||||
|
FilePlanComponent recordFolder = createFolderInFilePlan();
|
||||||
|
|
||||||
|
// the folder should be open
|
||||||
|
assertFalse(recordFolder.getProperties().getIsClosed());
|
||||||
|
|
||||||
|
// close the folder
|
||||||
|
closeFolder(recordFolder.getId());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
filePlanComponentAPI.createFilePlanComponent(
|
||||||
|
new FilePlanComponent("Record " + getRandomAlphanumeric(),
|
||||||
|
NON_ELECTRONIC_RECORD_TYPE.toString(),
|
||||||
|
new FilePlanComponentProperties()),
|
||||||
|
recordFolder.getId()).getId();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// verify the status code
|
||||||
|
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method to create a randomly-named <category>/<folder> structure in fileplan
|
||||||
|
* @return record folder
|
||||||
|
* @throws Exception on failed creation
|
||||||
|
*/
|
||||||
|
private FilePlanComponent createFolderInFilePlan() throws Exception
|
||||||
|
{
|
||||||
|
// create root category
|
||||||
|
FilePlanComponent recordCategory = createCategory(FILE_PLAN_ALIAS.toString(), "Category " + getRandomAlphanumeric());
|
||||||
|
|
||||||
|
// and return a folder underneath
|
||||||
|
return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user