mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-4488 (Refactor REST API Automation test code according to the latest changes)
This commit is contained in:
@@ -43,6 +43,7 @@ import org.alfresco.rest.RestTest;
|
|||||||
import org.alfresco.rest.core.RestAPIFactory;
|
import org.alfresco.rest.core.RestAPIFactory;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
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.FilePlanComponentProperties;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||||
import org.alfresco.utility.data.DataUser;
|
import org.alfresco.utility.data.DataUser;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -137,11 +138,13 @@ public class BaseRMRestTest extends RestTest
|
|||||||
*/
|
*/
|
||||||
public void createRMSiteIfNotExists() throws Exception
|
public void createRMSiteIfNotExists() throws Exception
|
||||||
{
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
// Check RM site doesn't exist
|
// Check RM site doesn't exist
|
||||||
if (!getRestAPIFactory().getRMSiteAPI().existsRMSite())
|
if (!rmSiteAPI.existsRMSite())
|
||||||
{
|
{
|
||||||
// Create the RM site
|
// Create the RM site
|
||||||
getRestAPIFactory().getRMSiteAPI().createRMSite(createStandardRMSiteModel());
|
rmSiteAPI.createRMSite(createStandardRMSiteModel());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
@@ -40,6 +40,7 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
import org.alfresco.rest.rm.community.model.user.UserPermissions;
|
||||||
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
import org.alfresco.rest.rm.community.model.user.UserRoles;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||||
import org.alfresco.test.AlfrescoTest;
|
import org.alfresco.test.AlfrescoTest;
|
||||||
import org.alfresco.utility.constants.UserRole;
|
import org.alfresco.utility.constants.UserRole;
|
||||||
@@ -191,20 +192,22 @@ public class DeleteRecordTests extends BaseRMRestTest
|
|||||||
|
|
||||||
// grant deleteUser Filing privileges on randomFolder category, this will be
|
// grant deleteUser Filing privileges on randomFolder category, this will be
|
||||||
// inherited to randomFolder
|
// inherited to randomFolder
|
||||||
rmUserAPI.addUserPermission(getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(randomFolder.getParentId()),
|
FilePlanComponentAPI filePlanComponentsAPIAsAdmin = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
rmUserAPI.addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()),
|
||||||
deleteUser, UserPermissions.PERMISSION_FILING);
|
deleteUser, UserPermissions.PERMISSION_FILING);
|
||||||
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK);
|
||||||
|
|
||||||
// create a non-electronic record in randomFolder
|
// create a non-electronic record in randomFolder
|
||||||
FilePlanComponent newRecord = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId());
|
FilePlanComponent newRecord = filePlanComponentsAPIAsAdmin.createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId());
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
// verify the user can see the newRecord
|
// verify the user can see the newRecord
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI(deleteUser).getFilePlanComponent(newRecord.getId());
|
FilePlanComponentAPI filePlanComponentsAPIAsUser = getRestAPIFactory().getFilePlanComponentsAPI(deleteUser);
|
||||||
|
filePlanComponentsAPIAsUser.getFilePlanComponent(newRecord.getId());
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
// try to delete newRecord
|
// try to delete newRecord
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI(deleteUser).deleteFilePlanComponent(newRecord.getId());
|
filePlanComponentsAPIAsUser.deleteFilePlanComponent(newRecord.getId());
|
||||||
assertStatusCode(FORBIDDEN);
|
assertStatusCode(FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,12 +218,14 @@ public class DeleteRecordTests extends BaseRMRestTest
|
|||||||
*/
|
*/
|
||||||
private void deleteAndVerify(FilePlanComponent record) throws Exception
|
private void deleteAndVerify(FilePlanComponent record) throws Exception
|
||||||
{
|
{
|
||||||
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
|
||||||
// delete it and verify status
|
// delete it and verify status
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(record.getId());
|
filePlanComponentsAPI.deleteFilePlanComponent(record.getId());
|
||||||
assertStatusCode(NO_CONTENT);
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
// try to get deleted file plan component
|
// try to get deleted file plan component
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(record.getId());
|
filePlanComponentsAPI.getFilePlanComponent(record.getId());
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ import static org.testng.Assert.assertTrue;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -197,13 +198,14 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
public void canCreateElectronicRecordsInValidContainers(FilePlanComponent container) throws Exception
|
public void canCreateElectronicRecordsInValidContainers(FilePlanComponent container) throws Exception
|
||||||
{
|
{
|
||||||
FilePlanComponent record = createElectronicRecordModel();
|
FilePlanComponent record = createElectronicRecordModel();
|
||||||
String newRecordId = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
String newRecordId = filePlanComponentsAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||||
|
|
||||||
// verify the create request status code
|
// verify the create request status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
// get newly created electronic record and verify its properties
|
// get newly created electronic record and verify its properties
|
||||||
FilePlanComponent electronicRecord = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
FilePlanComponent electronicRecord = filePlanComponentsAPI.getFilePlanComponent(newRecordId);
|
||||||
// created record will have record identifier inserted in its name but will be prefixed with
|
// created record will have record identifier inserted in its name but will be prefixed with
|
||||||
// the name it was created as
|
// the name it was created as
|
||||||
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
assertTrue(electronicRecord.getName().startsWith(record.getName()));
|
||||||
@@ -227,13 +229,14 @@ public class ElectronicRecordTests extends BaseRMRestTest
|
|||||||
.nodeType(CONTENT_TYPE)
|
.nodeType(CONTENT_TYPE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
String newRecordId = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
String newRecordId = filePlanComponentsAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId();
|
||||||
|
|
||||||
// verify the create request status code
|
// verify the create request status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
// get newly created electonic record and verify its properties
|
// get newly created electonic record and verify its properties
|
||||||
FilePlanComponent electronicRecord = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(newRecordId);
|
FilePlanComponent electronicRecord = filePlanComponentsAPI.getFilePlanComponent(newRecordId);
|
||||||
// record will have record identifier inserted in its name but will for sure start with file name
|
// record will have record identifier inserted in its name but will for sure start with file name
|
||||||
// and end with its extension
|
// and end with its extension
|
||||||
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf("."))));
|
||||||
|
@@ -47,6 +47,8 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|||||||
import org.alfresco.rest.rm.community.base.TestData;
|
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.FilePlanComponent;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.alfresco.utility.report.Bug;
|
import org.alfresco.utility.report.Bug;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
@@ -73,11 +75,13 @@ public class FilePlanTests extends BaseRMRestTest
|
|||||||
)
|
)
|
||||||
public void getFilePlanComponentWhenRMIsNotCreated(String filePlanComponentAlias) throws Exception
|
public void getFilePlanComponentWhenRMIsNotCreated(String filePlanComponentAlias) throws Exception
|
||||||
{
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
// Check RM Site Exist
|
// Check RM Site Exist
|
||||||
if (getRestAPIFactory().getRMSiteAPI().existsRMSite())
|
if (rmSiteAPI.existsRMSite())
|
||||||
{
|
{
|
||||||
// Delete RM Site
|
// Delete RM Site
|
||||||
getRestAPIFactory().getRMSiteAPI().deleteRMSite();
|
rmSiteAPI.deleteRMSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the file plan component
|
// Get the file plan component
|
||||||
@@ -264,16 +268,18 @@ public class FilePlanTests extends BaseRMRestTest
|
|||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
|
||||||
// Create the special containers into RM site - parent folder
|
// Create the special containers into RM site - parent folder
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, rmSiteId);
|
filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, rmSiteId);
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
|
||||||
// Create the special containers into RM site - parent folder
|
// Create the special containers into RM site - parent folder
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS);
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
|
|
||||||
// Create the special containers into the root of special containers containers
|
// Create the special containers into the root of special containers containers
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(filePlanComponent, filePlanComponentAlias);
|
filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, filePlanComponentAlias);
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ import java.util.Random;
|
|||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
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.FilePlanComponentProperties;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.alfresco.utility.constants.UserRole;
|
import org.alfresco.utility.constants.UserRole;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -81,7 +82,8 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
.nodeType(RECORD_CATEGORY_TYPE)
|
.nodeType(RECORD_CATEGORY_TYPE)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
FilePlanComponent recordCategory = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS);
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
FilePlanComponent recordCategory = filePlanComponentsAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
// iterate through all invalid parent containers and try to create/file an electronic record
|
// iterate through all invalid parent containers and try to create/file an electronic record
|
||||||
asList(FILE_PLAN_ALIAS, TRANSFERS_ALIAS, HOLDS_ALIAS, recordCategory.getId())
|
asList(FILE_PLAN_ALIAS, TRANSFERS_ALIAS, HOLDS_ALIAS, recordCategory.getId())
|
||||||
@@ -90,7 +92,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), id);
|
filePlanComponentsAPI.createFilePlanComponent(createNonElectronicRecordModel(), id);
|
||||||
}
|
}
|
||||||
catch (Exception error)
|
catch (Exception error)
|
||||||
{
|
{
|
||||||
@@ -162,7 +164,8 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// create non-electronic record
|
// create non-electronic record
|
||||||
String nonElectronicId = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
String nonElectronicId = filePlanComponentsAPI.createFilePlanComponent(
|
||||||
filePlanComponent,
|
filePlanComponent,
|
||||||
container.getId()).getId();
|
container.getId()).getId();
|
||||||
|
|
||||||
@@ -170,7 +173,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
|
|||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
// get newly created non-electonic record and verify its properties
|
// get newly created non-electonic record and verify its properties
|
||||||
FilePlanComponent nonElectronicRecord = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(nonElectronicId);
|
FilePlanComponent nonElectronicRecord = filePlanComponentsAPI.getFilePlanComponent(nonElectronicId);
|
||||||
|
|
||||||
assertEquals(title, nonElectronicRecord.getProperties().getTitle());
|
assertEquals(title, nonElectronicRecord.getProperties().getTitle());
|
||||||
assertEquals(description, nonElectronicRecord.getProperties().getDescription());
|
assertEquals(description, nonElectronicRecord.getProperties().getDescription());
|
||||||
|
@@ -49,6 +49,7 @@ 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.FilePlanComponent;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
|
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.FilePlanComponentsCollection;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.alfresco.utility.report.Bug;
|
import org.alfresco.utility.report.Bug;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -139,7 +140,8 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create the record category
|
// Create the record category
|
||||||
FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
FilePlanComponent filePlanComponent = filePlanComponentsAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
String newCategoryName = "Rename " + categoryName;
|
String newCategoryName = "Rename " + categoryName;
|
||||||
|
|
||||||
@@ -147,7 +149,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build();
|
FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build();
|
||||||
|
|
||||||
// Update the record category
|
// Update the record category
|
||||||
FilePlanComponent renamedFilePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
FilePlanComponent renamedFilePlanComponent = filePlanComponentsAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
@@ -156,7 +158,7 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
assertEquals(renamedFilePlanComponent.getName(), newCategoryName);
|
assertEquals(renamedFilePlanComponent.getName(), newCategoryName);
|
||||||
|
|
||||||
// Get actual FILE_PLAN_ALIAS id
|
// Get actual FILE_PLAN_ALIAS id
|
||||||
FilePlanComponent parentComponent = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(FILE_PLAN_ALIAS);
|
FilePlanComponent parentComponent = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
// verify renamed component still has this parent
|
// verify renamed component still has this parent
|
||||||
assertEquals(renamedFilePlanComponent.getParentId(), parentComponent.getId());
|
assertEquals(renamedFilePlanComponent.getParentId(), parentComponent.getId());
|
||||||
@@ -189,16 +191,17 @@ public class RecordCategoryTest extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create the record category
|
// Create the record category
|
||||||
FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
FilePlanComponent filePlanComponent = filePlanComponentsAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
|
||||||
|
|
||||||
// Delete the record category
|
// Delete the record category
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponent.getId());
|
filePlanComponentsAPI.deleteFilePlanComponent(filePlanComponent.getId());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(NO_CONTENT);
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
// Deleted component should no longer be retrievable
|
// Deleted component should no longer be retrievable
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent.getId());
|
filePlanComponentsAPI.getFilePlanComponent(filePlanComponent.getId());
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,7 @@ 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.FilePlanComponentProperties;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentReviewPeriod;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentReviewPeriod;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.alfresco.utility.report.Bug;
|
import org.alfresco.utility.report.Bug;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
@@ -128,7 +129,8 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
@Bug(id="RM-4327")
|
@Bug(id="RM-4327")
|
||||||
public void createFolderIntoSpecialContainers(String filePlanComponent) throws Exception
|
public void createFolderIntoSpecialContainers(String filePlanComponent) throws Exception
|
||||||
{
|
{
|
||||||
String componentID = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponent).getId();
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
String componentID = filePlanComponentsAPI.getFilePlanComponent(filePlanComponent).getId();
|
||||||
|
|
||||||
// Build the record category properties
|
// Build the record category properties
|
||||||
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
FilePlanComponent recordFolder = FilePlanComponent.builder()
|
||||||
@@ -140,7 +142,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create a record folder
|
// Create a record folder
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, componentID);
|
filePlanComponentsAPI.createFilePlanComponent(recordFolder, componentID);
|
||||||
|
|
||||||
// Check the API Response code
|
// Check the API Response code
|
||||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||||
@@ -254,12 +256,13 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
|
||||||
|
|
||||||
// Delete the Record folder
|
// Delete the Record folder
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(folder.getId());
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
filePlanComponentsAPI.deleteFilePlanComponent(folder.getId());
|
||||||
// Check the Response Status Code
|
// Check the Response Status Code
|
||||||
assertStatusCode(NO_CONTENT);
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
// Check the File Plan Component is not found
|
// Check the File Plan Component is not found
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder.getId());
|
filePlanComponentsAPI.getFilePlanComponent(folder.getId());
|
||||||
// Check the Response Status Code
|
// Check the Response Status Code
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
@@ -364,7 +367,8 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create the record folder
|
// Create the record folder
|
||||||
FilePlanComponent folder = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS, "include=" + PATH);
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
FilePlanComponent folder = filePlanComponentsAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||||
//Check the API response code
|
//Check the API response code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
@@ -376,10 +380,10 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
//Check the path return contains the RELATIVE_PATH
|
//Check the path return contains the RELATIVE_PATH
|
||||||
assertTrue(folder.getPath().getName().contains(relativePath));
|
assertTrue(folder.getPath().getName().contains(relativePath));
|
||||||
//check the parent is a category
|
//check the parent is a category
|
||||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder.getParentId()).getIsCategory());
|
assertTrue(filePlanComponentsAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||||
|
|
||||||
//check the created folder from the server
|
//check the created folder from the server
|
||||||
folder = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder.getId(), "include=" + PATH);
|
folder = filePlanComponentsAPI.getFilePlanComponent(folder.getId(), "include=" + PATH);
|
||||||
//Check the API response code
|
//Check the API response code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
// Verify the returned properties for the file plan component - record folder
|
// Verify the returned properties for the file plan component - record folder
|
||||||
@@ -400,7 +404,7 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create the record folder
|
// Create the record folder
|
||||||
FilePlanComponent folder2 = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS, "include=" + PATH);
|
FilePlanComponent folder2 = filePlanComponentsAPI.createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS, "include=" + PATH);
|
||||||
//Check the API response code
|
//Check the API response code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
|
|
||||||
@@ -412,10 +416,10 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
|
assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
|
||||||
|
|
||||||
//check the parent is a category
|
//check the parent is a category
|
||||||
assertTrue(getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder.getParentId()).getIsCategory());
|
assertTrue(filePlanComponentsAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
|
||||||
|
|
||||||
// Check the folder created on the server
|
// Check the folder created on the server
|
||||||
folder2 = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder2.getId(), "include=" + PATH);
|
folder2 = filePlanComponentsAPI.getFilePlanComponent(folder2.getId(), "include=" + PATH);
|
||||||
//Check the API response code
|
//Check the API response code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
@@ -430,11 +434,12 @@ public class RecordFolderTests extends BaseRMRestTest
|
|||||||
@AfterClass (alwaysRun = true)
|
@AfterClass (alwaysRun = true)
|
||||||
public void tearDown() throws Exception
|
public void tearDown() throws Exception
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(FILE_PLAN_ALIAS).getEntries().forEach(filePlanComponentEntry ->
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
filePlanComponentsAPI.listChildComponents(FILE_PLAN_ALIAS).getEntries().forEach(filePlanComponentEntry ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponentModel().getId());
|
filePlanComponentsAPI.deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponentModel().getId());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -52,6 +52,7 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
|||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
|
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.FilePlanComponentProperties;
|
||||||
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
@@ -193,7 +194,8 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Create it as a child of parentFolder
|
// Create it as a child of parentFolder
|
||||||
FilePlanComponent childFolder = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, parentFolder.getId());
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
FilePlanComponent childFolder = filePlanComponentsAPI.createFilePlanComponent(unfiledFolder, parentFolder.getId());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
@@ -217,7 +219,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
|
|
||||||
// Does child's parent point to it?
|
// Does child's parent point to it?
|
||||||
// Perform another call as our parentFolder had been executed before childFolder existed
|
// Perform another call as our parentFolder had been executed before childFolder existed
|
||||||
FilePlanComponentsCollection parentsChildren = getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(parentFolder.getId());
|
FilePlanComponentsCollection parentsChildren = filePlanComponentsAPI.listChildComponents(parentFolder.getId());
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
List<String> childIds = parentsChildren.getEntries()
|
List<String> childIds = parentsChildren.getEntries()
|
||||||
.stream()
|
.stream()
|
||||||
@@ -258,12 +260,13 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Update the unfiled records folder
|
// Update the unfiled records folder
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
filePlanComponentsAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
|
|
||||||
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
// This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
|
||||||
FilePlanComponent renamedFolder = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folderToModify.getId());
|
FilePlanComponent renamedFolder = filePlanComponentsAPI.getFilePlanComponent(folderToModify.getId());
|
||||||
|
|
||||||
// Verify the returned file plan component
|
// Verify the returned file plan component
|
||||||
assertEquals(modified + folderToModify.getName(), renamedFolder.getName());
|
assertEquals(modified + folderToModify.getName(), renamedFolder.getName());
|
||||||
@@ -288,13 +291,14 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
|
|||||||
assertEquals(folderName, folderToDelete.getName());
|
assertEquals(folderName, folderToDelete.getName());
|
||||||
|
|
||||||
// Delete folderToDelete
|
// Delete folderToDelete
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(folderToDelete.getId());
|
FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
|
||||||
|
filePlanComponentsAPI.deleteFilePlanComponent(folderToDelete.getId());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(NO_CONTENT);
|
assertStatusCode(NO_CONTENT);
|
||||||
|
|
||||||
// Deleted component should no longer be retrievable
|
// Deleted component should no longer be retrievable
|
||||||
getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folderToDelete.getId());
|
filePlanComponentsAPI.getFilePlanComponent(folderToDelete.getId());
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -50,6 +50,7 @@ import static org.testng.Assert.assertNotNull;
|
|||||||
|
|
||||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||||
import org.alfresco.rest.rm.community.model.site.RMSite;
|
import org.alfresco.rest.rm.community.model.site.RMSite;
|
||||||
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
|
||||||
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
|
||||||
import org.alfresco.utility.data.RandomData;
|
import org.alfresco.utility.data.RandomData;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
@@ -80,15 +81,17 @@ public class RMSiteTests extends BaseRMRestTest
|
|||||||
)
|
)
|
||||||
public void createRMSiteAsAdminUser() throws Exception
|
public void createRMSiteAsAdminUser() throws Exception
|
||||||
{
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
// Check if the RM site exists
|
// Check if the RM site exists
|
||||||
if (getRestAPIFactory().getRMSiteAPI().existsRMSite())
|
if (rmSiteAPI.existsRMSite())
|
||||||
{
|
{
|
||||||
// Delete the RM site
|
// Delete the RM site
|
||||||
getRestAPIFactory().getRMSiteAPI().deleteRMSite();
|
rmSiteAPI.deleteRMSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the RM site
|
// Create the RM site
|
||||||
RMSite rmSiteResponse = getRestAPIFactory().getRMSiteAPI().createRMSite(createStandardRMSiteModel());
|
RMSite rmSiteResponse = rmSiteAPI.createRMSite(createStandardRMSiteModel());
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(CREATED);
|
assertStatusCode(CREATED);
|
||||||
@@ -160,8 +163,10 @@ public class RMSiteTests extends BaseRMRestTest
|
|||||||
)
|
)
|
||||||
public void getRMSite() throws Exception
|
public void getRMSite() throws Exception
|
||||||
{
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
// Check if RM site exists
|
// Check if RM site exists
|
||||||
if (!getRestAPIFactory().getRMSiteAPI().existsRMSite())
|
if (!rmSiteAPI.existsRMSite())
|
||||||
{
|
{
|
||||||
// Verify the status code when RM site doesn't exist
|
// Verify the status code when RM site doesn't exist
|
||||||
assertStatusCode(NOT_FOUND);
|
assertStatusCode(NOT_FOUND);
|
||||||
@@ -170,7 +175,7 @@ public class RMSiteTests extends BaseRMRestTest
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Get the RM site
|
// Get the RM site
|
||||||
RMSite rmSiteModel = getRestAPIFactory().getRMSiteAPI().getSite();
|
RMSite rmSiteModel = rmSiteAPI.getSite();
|
||||||
|
|
||||||
// Verify the status code
|
// Verify the status code
|
||||||
assertStatusCode(OK);
|
assertStatusCode(OK);
|
||||||
@@ -193,11 +198,13 @@ public class RMSiteTests extends BaseRMRestTest
|
|||||||
@Bug (id="RM-4289")
|
@Bug (id="RM-4289")
|
||||||
public void createRMSiteAsAnotherAdminUser() throws Exception
|
public void createRMSiteAsAnotherAdminUser() throws Exception
|
||||||
{
|
{
|
||||||
|
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
|
||||||
|
|
||||||
// Check if the RM site exists
|
// Check if the RM site exists
|
||||||
if (getRestAPIFactory().getRMSiteAPI().existsRMSite())
|
if (rmSiteAPI.existsRMSite())
|
||||||
{
|
{
|
||||||
// Delete the RM site
|
// Delete the RM site
|
||||||
getRestAPIFactory().getRMSiteAPI().deleteRMSite();
|
rmSiteAPI.deleteRMSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create user
|
// Create user
|
||||||
|
Reference in New Issue
Block a user