- Create a utility class with the toJson() method to convert models to json object

- update the test to use models
This commit is contained in:
Rodica Sutu
2016-11-28 10:11:01 +02:00
parent 74b8e0ac18
commit e87df92099
14 changed files with 283 additions and 293 deletions

View File

@@ -30,27 +30,20 @@ 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.FOLDER_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
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.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import com.google.gson.JsonObject;
import com.jayway.restassured.RestAssured;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.site.RMSite;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
import org.alfresco.utility.data.DataUser;
@@ -127,15 +120,9 @@ public class BaseRestTest extends RestTest
{
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Build the RM site properties
JsonObject rmSiteProperties = buildObject()
.add(TITLE, RM_TITLE)
.add(DESCRIPTION, RM_DESCRIPTION)
.add(COMPLIANCE, STANDARD.toString())
.getJson();
// Create the RM site
rmSiteAPI.createRMSite(rmSiteProperties);
RMSite rmSite= new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD);
rmSiteAPI.createRMSite(rmSite);
// Verify the status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
@@ -195,14 +182,9 @@ public class BaseRestTest extends RestTest
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
JsonObject componentProperties = buildObject().add(NAME, componentName)
.add(NODE_TYPE, componentType.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, componentTitle)
.end()
.getJson();
FilePlanComponent filePlanComponent=new FilePlanComponent(componentName, componentType.toString(),new FilePlanComponentProperties(componentTitle));
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, parentComponentId);
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId);
restWrapper.assertStatusCodeIs(CREATED);
return fpc;
}

View File

@@ -33,13 +33,8 @@ import static org.alfresco.rest.rm.community.base.AllowableOperations.DELETE;
import static org.alfresco.rest.rm.community.base.AllowableOperations.UPDATE;
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.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.OK;
@@ -48,12 +43,12 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
@@ -75,6 +70,9 @@ public class FilePlanTests extends BaseRestTest
@Autowired
private FilePlanComponentAPI filePlanComponentAPI;
@Autowired
protected RestWrapper restWrapper;
@Autowired
private RMSiteAPI rmSiteAPI;
@@ -111,6 +109,8 @@ public class FilePlanTests extends BaseRestTest
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND);
}
/**
* Given that a file plan exists
* When I ask the API for the details of the file plan
@@ -160,7 +160,7 @@ public class FilePlanTests extends BaseRestTest
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Get the file plan special containers with the optional parameter allowableOperations
FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include=allowableOperations").getFilePlanComponent(specialContainerAlias);
FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include="+ ALLOWABLE_OPERATIONS).getFilePlanComponent(specialContainerAlias);
// Check the list of allowableOperations returned
if(specialContainerAlias.equals(TRANSFERS_ALIAS.toString()))
@@ -199,15 +199,12 @@ public class FilePlanTests extends BaseRestTest
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Build the file plan root properties
JsonObject filePlanProperties = buildObject()
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, FILE_PLAN_TITLE)
.add(PROPERTIES_DESCRIPTION, FILE_PLAN_DESCRIPTION)
.end()
.getJson();
FilePlanComponent filePlanComponent= new FilePlanComponent();
FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION);
filePlanComponent.setProperties(filePlanComponentProperties);
// Update the record category
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanProperties,FILE_PLAN_ALIAS.toString());
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString());
// Verify the response status code
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
@@ -252,10 +249,10 @@ public class FilePlanTests extends BaseRestTest
*/
@Test
(
description = "Check the response code when deleting the special file plan components with non RM user",
dataProviderClass = TestData.class,
dataProvider = "getContainers"
)
description = "Check the response code when deleting the special file plan components with non RM user",
dataProviderClass = TestData.class,
dataProvider = "getContainers"
)
public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception
{
// Create RM Site if doesn't exist
@@ -304,23 +301,20 @@ public class FilePlanTests extends BaseRestTest
String name = filePlanAlias + getRandomAlphanumeric();
// Build the file plan root properties
JsonObject componentProperties = buildObject()
.add(NAME, name)
.add(NODE_TYPE, rmType.toString())
.getJson();
FilePlanComponent filePlanComponent=new FilePlanComponent(name,rmType.toString(),new FilePlanComponentProperties());
// Authenticate with admin user
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Create the special containers into RM site - parent folder
filePlanComponentAPI.createFilePlanComponent(componentProperties, rmSiteId);
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
// Create the special containers into RM site - parent folder
filePlanComponentAPI.createFilePlanComponent(componentProperties, FILE_PLAN_ALIAS.toString());
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS.toString());
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
// Create the special containers into the root of special containers containers
filePlanComponentAPI.createFilePlanComponent(componentProperties, filePlanAlias.toString());
filePlanComponentAPI.createFilePlanComponent(filePlanComponent, filePlanAlias.toString());
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}

View File

@@ -27,14 +27,9 @@
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.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
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.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
@@ -49,8 +44,6 @@ import static org.testng.Assert.fail;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
@@ -101,16 +94,10 @@ public class RecordCategoryTest extends BaseRestTest
String categoryTitle = "Category title " + getRandomAlphanumeric();
// Build the record category properties
JsonObject recordCategoryProperties = buildObject().
add(NAME, categoryName).
add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()).
addObject(PROPERTIES).
add(PROPERTIES_TITLE, categoryTitle).
end().
getJson();
FilePlanComponent recordCategory= new FilePlanComponent(categoryName,RECORD_CATEGORY_TYPE.toString(),
new FilePlanComponentProperties(categoryTitle));
// Create the record category
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString());
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
@@ -122,7 +109,6 @@ public class RecordCategoryTest extends BaseRestTest
assertEquals(filePlanComponent.getName(), categoryName);
assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString());
assertFalse(filePlanComponent.isHasRetentionSchedule());
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
@@ -153,26 +139,19 @@ public class RecordCategoryTest extends BaseRestTest
String categoryTitle = "Category title " + getRandomAlphanumeric();
// Build the record category properties
JsonObject recordCategoryProperties = buildObject().
add(NAME, categoryName).
add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()).
addObject(PROPERTIES).
add(PROPERTIES_TITLE, categoryTitle).
end().
getJson();
FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(),
new FilePlanComponentProperties(categoryTitle));
// Create the record category
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString());
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
String newCategoryName = "Rename " + categoryName;
// Build the properties which will be updated
JsonObject updateRecordCategoryProperties = buildObject().
add(NAME, newCategoryName).
getJson();
FilePlanComponent recordCategoryUpdated = new FilePlanComponent(newCategoryName);
// Update the record category
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(updateRecordCategoryProperties, filePlanComponent.getId());
FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
// Verify the status code
restWrapper.assertStatusCodeIs(OK);
@@ -207,16 +186,10 @@ public class RecordCategoryTest extends BaseRestTest
String categoryTitle = "Category title " + getRandomAlphanumeric();
// Build the record category properties
JsonObject recordCategoryProperties = buildObject().
add(NAME, categoryName).
add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()).
addObject(PROPERTIES).
add(PROPERTIES_TITLE, categoryTitle).
end().
getJson();
FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(),
new FilePlanComponentProperties(categoryTitle));
// Create the record category
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString());
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
// Delete the record category
filePlanComponentAPI.deleteFilePlanComponent(filePlanComponent.getId());
@@ -368,20 +341,15 @@ public class RecordCategoryTest extends BaseRestTest
{
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
// Authenticate with admin user
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
//Build node properties
JsonObject componentProperties = buildObject()
.add(NAME, COMPONENT_NAME)
.add(NODE_TYPE, nodeType)
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, "Title for " + COMPONENT_NAME)
.end()
.getJson();
FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType,
new FilePlanComponentProperties("Title for " + COMPONENT_NAME));
//create the invalid node type
filePlanComponentAPI.createFilePlanComponent(componentProperties, category.getId());
filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}
@@ -411,16 +379,10 @@ public class RecordCategoryTest extends BaseRestTest
private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType) throws Exception
{
RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
JsonObject componentProperties = buildObject().
add(NAME, componentName).
add(NODE_TYPE, componentType.toString()).
addObject(PROPERTIES).
add(PROPERTIES_TITLE, "Title for " + componentName).
end().
getJson();
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, parentComponentId);
//Build node properties
FilePlanComponent component = new FilePlanComponent(componentName, componentType.toString(),
new FilePlanComponentProperties("Title for " + componentName));
FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId);
restWrapper.assertStatusCodeIs(CREATED);
return fpc;
}

View File

@@ -31,17 +31,8 @@ import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME;
import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.IS_CLOSED;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
@@ -56,19 +47,17 @@ import static org.testng.AssertJUnit.assertTrue;
import java.util.ArrayList;
import java.util.NoSuchElementException;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.base.TestData;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
@@ -103,18 +92,15 @@ public class RecordFolderTests extends BaseRestTest
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
FilePlanComponent filePlanComponent=createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
// Build the record category properties
JsonObject recordFolderProperties = buildObject()
.add(NAME, FOLDER_NAME)
.add(NODE_TYPE, RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, FOLDER_TITLE)
.end()
.getJson();
FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(FOLDER_TITLE);
FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), filePlanComponentProperties);
// Create the record folder
FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolderProperties, filePlanComponent.getId());
FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId());
//filePlanComponentAPI.createFilePlanComponent(recordFolderProperties, filePlanComponent.getId());
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
// Check folder has been created within the category created
assertEquals(filePlanComponent.getId(),folder.getParentId());
// Verify the returned properties for the file plan component - record folder
@@ -151,16 +137,10 @@ public class RecordFolderTests extends BaseRestTest
String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId();
// Build the record category properties
JsonObject recordFolderProperties = buildObject()
.add(NAME, FOLDER_NAME)
.add(NODE_TYPE, RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, FOLDER_TITLE)
.end()
.getJson();
FilePlanComponent recordFolder= new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(),
new FilePlanComponentProperties(FOLDER_TITLE));
// Create a record folder
filePlanComponentAPI.createFilePlanComponent(recordFolderProperties, componentID);
filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID);
// Check the API Response code
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
@@ -224,22 +204,16 @@ public class RecordFolderTests extends BaseRestTest
String folderName= "The folder name is updated" + getRandomAlphanumeric();
String folderTitle = "Update title " + getRandomAlphanumeric();
String location="Location"+getRandomAlphanumeric();
String review_period="month|1";
// Build the file plan root properties
JsonObject folderProperties = buildObject()
.add(NAME, folderName)
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, folderTitle)
.add(PROPERTIES_DESCRIPTION, folderDescription)
.add(PROPERTIES_VITAL_RECORD_INDICATOR,true)
.add(PROPERTIES_REVIEW_PERIOD, review_period)
.add(PROPERTIES_LOCATION, location)
.end()
.getJson();
FilePlanComponentProperties filePlanComponentProperties= new FilePlanComponentProperties(folderTitle, folderDescription);
filePlanComponentProperties.setVitalRecord(true);
filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1"));
filePlanComponentProperties.setLocation(location);
FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties);
// Update the record category
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(folderProperties, folder.getId());
FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
// Check the Response Status Code
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
@@ -361,7 +335,7 @@ public class RecordFolderTests extends BaseRestTest
);
}
@AfterClass (alwaysRun = true)
//@AfterClass (alwaysRun = true)
public void tearDown() throws Exception
{
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());

View File

@@ -27,11 +27,6 @@
package org.alfresco.rest.rm.community.fileplancomponents;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE;
@@ -41,7 +36,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT;
@@ -54,8 +48,6 @@ import static org.testng.Assert.assertTrue;
import java.util.List;
import java.util.stream.Collectors;
import com.google.gson.JsonObject;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
@@ -83,7 +75,8 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
private DataUser dataUser;
/** invalid root level types, at unfiled records root level these shouldn't be possible to create */
@DataProvider(name = "invalidRootTypes")
@DataProvider(name = "invalidRootTypes")
public Object[][] createData1() {
return new Object[][] {
{ FILE_PLAN_TYPE },
@@ -114,20 +107,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
String folderDescription = folderName + " Description";
// Build unfiled records folder properties
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, folderName)
.add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, folderTitle)
.add(PROPERTIES_DESCRIPTION, folderDescription)
.end()
.getJson();
FilePlanComponent unfiledFolder=new FilePlanComponent(folderName,UNFILED_RECORD_FOLDER_TYPE.toString(),
new FilePlanComponentProperties(folderTitle,folderDescription));
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
// Verify the returned file plan component
assertFalse(filePlanComponent.isIsCategory());
@@ -136,7 +123,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
assertEquals(filePlanComponent.getName(), folderName);
assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
assertFalse(filePlanComponent.isHasRetentionSchedule());
assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
@@ -164,17 +150,13 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
logger.info("creating " + componentType.toString());
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, folderName)
.add(NODE_TYPE, componentType.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, folderTitle)
.add(PROPERTIES_DESCRIPTION, folderDescription)
.end()
.getJson();
// Build unfiled records folder properties
FilePlanComponent unfiledFolder = new FilePlanComponent(folderName, componentType.toString(),
new FilePlanComponentProperties(folderTitle, folderDescription));
try
{
filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
UNFILED_RECORDS_CONTAINER_ALIAS.toString());
}
catch (Exception error)
@@ -182,7 +164,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
}
// Verify the status code
restWrapper.assertStatusCodeIs(UNPROCESSABLE_ENTITY);
filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
}
/**
@@ -207,17 +189,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
assertEquals(parentFolderName, parentFolder.getName());
// Build the unfiled records folder properties
JsonObject unfiledFolderProperties = buildObject()
.add(NAME, childFolderName)
.add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, childFolderTitle)
.add(PROPERTIES_DESCRIPTION, childFolderDescription)
.end()
.getJson();
FilePlanComponent unfiledFolder = new FilePlanComponent(childFolderName, UNFILED_RECORD_FOLDER_TYPE.toString(),
new FilePlanComponentProperties(childFolderTitle, childFolderDescription));
// Create it as a child of parentFolder
FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties,
FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
parentFolder.getId());
// Verify the status code
@@ -230,7 +206,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
assertEquals(childFolder.getName(), childFolderName);
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
assertFalse(childFolder.isHasRetentionSchedule());
// assertFalse(childFolder.isHasRetentionSchedule());
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
@@ -277,16 +253,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
assertEquals(folderName, folderToModify.getName());
// Build the properties which will be updated
JsonObject updateFolderProperties = buildObject()
.add(NAME, modified + folderToModify.getName())
.addObject(PROPERTIES)
.add(PROPERTIES_TITLE, modified + folderToModify.getProperties().getTitle())
.add(PROPERTIES_DESCRIPTION, modified + folderToModify.getProperties().getDescription())
.end()
.getJson();
FilePlanComponent folderToUpdate=new FilePlanComponent(modified + folderToModify.getName(),
new FilePlanComponentProperties(modified + folderToModify.getProperties().getTitle(),
modified + folderToModify.getProperties().getDescription()));
// Update the unfiled records folder
filePlanComponentAPI.updateFilePlanComponent(updateFolderProperties, folderToModify.getId());
filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
// Verify the status code
restWrapper.assertStatusCodeIs(OK);

View File

@@ -31,10 +31,6 @@ import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_EMAIL;
import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION;
import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE;
import static org.jglue.fluentjson.JsonBuilderFactory.buildObject;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED;
@@ -46,13 +42,11 @@ import static org.springframework.social.alfresco.api.entities.Site.Visibility.P
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import com.google.gson.JsonObject;
import org.alfresco.dataprep.UserService;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.rest.rm.community.base.BaseRestTest;
import org.alfresco.rest.rm.community.model.site.RMSite;
import org.alfresco.rest.rm.community.requests.RMSiteAPI;
import org.alfresco.rest.core.RestWrapper;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.RandomData;
@@ -100,26 +94,20 @@ public class RMSiteTests extends BaseRestTest
rmSiteAPI.deleteRMSite();
}
// Build the RM site properties
JsonObject rmSiteProperties = buildObject()
.add(TITLE, RM_TITLE)
.add(DESCRIPTION, RM_DESCRIPTION)
.add(COMPLIANCE, STANDARD.toString())
.getJson();
// Create the RM site
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD);
RMSite rmSiteResponse=rmSiteAPI.createRMSite(rmSite);
// Verify the status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
// Verify the returned file plan component
assertEquals(rmSite.getId(), RM_ID);
assertEquals(rmSite.getTitle(), RM_TITLE);
assertEquals(rmSite.getDescription(), RM_DESCRIPTION);
assertEquals(rmSite.getCompliance(), STANDARD);
assertEquals(rmSite.getVisibility(), PUBLIC);
assertEquals(rmSite.getRole(), UserRole.SiteManager.toString());
assertEquals(rmSiteResponse.getId(), RM_ID);
assertEquals(rmSiteResponse.getTitle(), RM_TITLE);
assertEquals(rmSiteResponse.getDescription(), RM_DESCRIPTION);
assertEquals(rmSiteResponse.getCompliance(), STANDARD);
assertEquals(rmSiteResponse.getVisibility(), PUBLIC);
assertEquals(rmSiteResponse.getRole(), UserRole.SiteManager.toString());
}
/**
@@ -143,15 +131,9 @@ public class RMSiteTests extends BaseRestTest
String newTitle = RM_TITLE + "createRMSiteWhenSiteExists";
String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
// Build the RM site properties
JsonObject rmSiteProperties = buildObject()
.add(TITLE, newTitle)
.add(DESCRIPTION, newDescription)
.add(COMPLIANCE, STANDARD.toString())
.getJson();
// Create the RM site
rmSiteAPI.createRMSite(rmSiteProperties);
RMSite rmSite = new RMSite(newTitle, newDescription, STANDARD);
rmSiteAPI.createRMSite(rmSite);
// Verify the status code
restWrapper.assertStatusCodeIs(CONFLICT);
@@ -253,15 +235,9 @@ public class RMSiteTests extends BaseRestTest
// Authenticate as that new user
rmSiteAPI.usingRestWrapper().authenticateUser(userModel);
// Build the RM site properties
JsonObject rmSiteProperties = buildObject()
.add(TITLE, RM_TITLE)
.add(DESCRIPTION, RM_DESCRIPTION)
.add(COMPLIANCE, DOD5015.toString())
.getJson();
// Create the RM site
RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties);
RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, DOD5015);
rmSite=rmSiteAPI.createRMSite(rmSite);
// Verify the status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
@@ -288,18 +264,17 @@ public class RMSiteTests extends BaseRestTest
String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric();
String NEW_DESCRIPTION=RM_DESCRIPTION+ RandomData.getRandomAlphanumeric();
// Build the RM site properties
JsonObject rmSiteToUpdate = buildObject()
.add(TITLE, NEW_TITLE)
.add(DESCRIPTION, NEW_DESCRIPTION)
.getJson();
// Authenticate with admin user
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Create the site if it does not exist
createRMSiteIfNotExists();
//Create RM site model
RMSite rmSiteToUpdate=new RMSite();
rmSiteToUpdate.setTitle(NEW_TITLE);
rmSiteToUpdate.setDescription(NEW_DESCRIPTION);
// Disconnect the user from the API session
rmSiteAPI.usingRestWrapper().disconnect();
@@ -310,7 +285,7 @@ public class RMSiteTests extends BaseRestTest
rmSiteAPI.usingRestWrapper().authenticateUser(nonRMuser);
// Create the RM site
RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate);
rmSiteAPI.updateRMSite(rmSiteToUpdate);
// Verify the status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
@@ -322,7 +297,7 @@ public class RMSiteTests extends BaseRestTest
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// Update the RM Site
rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate);
RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate);
// Verify the response status code
rmSiteAPI.usingRestWrapper().assertStatusCodeIs(OK);
@@ -350,9 +325,7 @@ public class RMSiteTests extends BaseRestTest
createRMSiteIfNotExists();
// Build the RM site properties
JsonObject rmSiteToUpdate = buildObject()
.add(COMPLIANCE, DOD5015.toString())
.getJson();
RMSite rmSiteToUpdate = new RMSite(DOD5015);
// Update the RM site
rmSiteAPI.updateRMSite(rmSiteToUpdate);