APPS-947 Refactor community rest api to be run in parallel

This commit is contained in:
cagache
2021-04-10 21:10:05 +03:00
parent f0d7e650a4
commit 4762d1cfda
32 changed files with 694 additions and 928 deletions

View File

@@ -94,12 +94,12 @@ public class AuditAddToHoldTests extends BaseRMRestTest
private RecordCategory recordCategory; private RecordCategory recordCategory;
private RecordCategoryChild recordFolder; private RecordCategoryChild recordFolder;
private List<AuditEntry> auditEntries; private List<AuditEntry> auditEntries;
private List<String> holdsList = asList(HOLD1, HOLD2); private final List<String> holdsList = asList(HOLD1, HOLD2);
private List<String> holdsListRef = new ArrayList<>(); private List<String> holdsListRef = new ArrayList<>();
private String hold1NodeRef; private String hold1NodeRef;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void preconditionForAuditAddToHoldTests() throws Exception public void preconditionForAuditAddToHoldTests()
{ {
STEP("Create 2 holds."); STEP("Create 2 holds.");
hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(),
@@ -128,10 +128,9 @@ public class AuditAddToHoldTests extends BaseRMRestTest
* Data provider with valid nodes that can be added to a hold * Data provider with valid nodes that can be added to a hold
* *
* @return the node id, the node name and the node path * @return the node id, the node name and the node path
* @throws Exception
*/ */
@DataProvider (name = "validNodesForAddToHold") @DataProvider (name = "validNodesForAddToHold")
public Object[][] getValidNodesForAddToHold() throws Exception public Object[][] getValidNodesForAddToHold()
{ {
FileModel contentToBeAdded = dataContent.usingAdmin().usingSite(privateSite) FileModel contentToBeAdded = dataContent.usingAdmin().usingSite(privateSite)
.createContent(CMISUtil.DocumentType.TEXT_PLAIN); .createContent(CMISUtil.DocumentType.TEXT_PLAIN);
@@ -184,7 +183,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
* Then the add to hold event isn't audited * Then the add to hold event isn't audited
*/ */
@Test @Test
public void unsuccessfulAddToHoldIsNotAudited() throws Exception public void unsuccessfulAddToHoldIsNotAudited()
{ {
STEP("Create a new record"); STEP("Create a new record");
Record recordToBeAdded = createElectronicRecord(recordFolder.getId(), PREFIX + "record"); Record recordToBeAdded = createElectronicRecord(recordFolder.getId(), PREFIX + "record");
@@ -207,7 +206,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
* Then only an entry has been created in the audit log for the record folder added * Then only an entry has been created in the audit log for the record folder added
*/ */
@Test @Test
public void addToHoldIsNotAuditedForRecordFolderChildren() throws Exception public void addToHoldIsNotAuditedForRecordFolderChildren()
{ {
STEP("Create a new record folder with a record inside"); STEP("Create a new record folder with a record inside");
RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder"); RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder");
@@ -232,7 +231,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest
* Then multiple entries have been created in the audit log for each add to hold event * Then multiple entries have been created in the audit log for each add to hold event
*/ */
@Test @Test
public void addToHoldIsAuditedInBulkAddition() throws Exception public void addToHoldIsAuditedInBulkAddition()
{ {
STEP("Create a new record"); STEP("Create a new record");
Record recordToBeAdded = createElectronicRecord(recordFolder.getId(), PREFIX + "record"); Record recordToBeAdded = createElectronicRecord(recordFolder.getId(), PREFIX + "record");
@@ -308,6 +307,6 @@ public class AuditAddToHoldTests extends BaseRMRestTest
holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef)); holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef));
dataSite.usingAdmin().deleteSite(privateSite); dataSite.usingAdmin().deleteSite(privateSite);
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategory.getId()); deleteRecordCategory(recordCategory.getId());
} }
} }

View File

@@ -68,7 +68,7 @@ public class AuditCreateHoldTests extends BaseRMRestTest
private final String HOLD1 = PREFIX + "createHold"; private final String HOLD1 = PREFIX + "createHold";
private final String HOLD2 = PREFIX + "createHold2"; private final String HOLD2 = PREFIX + "createHold2";
private final String HOLD3 = PREFIX + "createHold3"; private final String HOLD3 = PREFIX + "createHold3";
private List<String> holdsListRef = new ArrayList<>(); private final List<String> holdsListRef = new ArrayList<>();
@Autowired @Autowired
private RMAuditService rmAuditService; private RMAuditService rmAuditService;

View File

@@ -42,7 +42,6 @@ import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -83,7 +82,6 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
private final String HOLD1 = PREFIX + "hold1"; private final String HOLD1 = PREFIX + "hold1";
private final String HOLD2 = PREFIX + "hold2"; private final String HOLD2 = PREFIX + "hold2";
private final String HOLD3 = PREFIX + "hold3"; private final String HOLD3 = PREFIX + "hold3";
private final String DELETED_HOLD = PREFIX + "deletedHold";
@Autowired @Autowired
private RMAuditService rmAuditService; private RMAuditService rmAuditService;
@@ -98,13 +96,13 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
private RecordCategoryChild recordFolder, heldRecordFolder; private RecordCategoryChild recordFolder, heldRecordFolder;
private Record heldRecord; private Record heldRecord;
private List<AuditEntry> auditEntries; private List<AuditEntry> auditEntries;
private List<String> holdsList = asList(HOLD1, HOLD2, HOLD3); private final List<String> holdsList = asList(HOLD1, HOLD2, HOLD3);
private List<String> holdsListRef = new ArrayList<>(); private List<String> holdsListRef = new ArrayList<>();
private FileModel heldContent; private FileModel heldContent;
private String hold1NodeRef; private String hold1NodeRef;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void preconditionForAuditRemoveFromHoldTests() throws Exception public void preconditionForAuditRemoveFromHoldTests()
{ {
STEP("Create an user with full rights to remove content from a hold."); STEP("Create an user with full rights to remove content from a hold.");
rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId); rmAdmin = roleService.createUserWithRMRole(UserRoles.ROLE_RM_ADMIN.roleId);
@@ -117,7 +115,6 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
HOLD1, HOLD_REASON, HOLD_DESCRIPTION); HOLD1, HOLD_REASON, HOLD_DESCRIPTION);
String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION);
String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION); String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION);
String deleteNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), DELETED_HOLD, HOLD_REASON, HOLD_DESCRIPTION);
holdsListRef = asList(hold1NodeRef, hold2NodeRef, hold3NodeRef); holdsListRef = asList(hold1NodeRef, hold2NodeRef, hold3NodeRef);
STEP("Create a new record category with a record folder."); STEP("Create a new record category with a record folder.");
@@ -216,7 +213,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
* Then only an entry has been created in the audit log for the record folder removed * Then only an entry has been created in the audit log for the record folder removed
*/ */
@Test @Test
public void removeFromHoldNotAuditedForRecordFolderChildren() throws Exception public void removeFromHoldNotAuditedForRecordFolderChildren()
{ {
STEP("Create a new record folder with a record inside"); STEP("Create a new record folder with a record inside");
RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder"); RecordCategoryChild notEmptyRecFolder = createRecordFolder(recordCategory.getId(), PREFIX + "notEmptyRecFolder");
@@ -324,6 +321,6 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest
holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef)); holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef));
dataSite.usingAdmin().deleteSite(privateSite); dataSite.usingAdmin().deleteSite(privateSite);
asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user));
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategory.getId()); deleteRecordCategory(recordCategory.getId());
} }
} }

View File

@@ -59,8 +59,6 @@ public class AuditUserEventsTests extends BaseRMRestTest
* Given I have created a new user * Given I have created a new user
* When I view the RM audit * When I view the RM audit
* Then there is an entry showing that I created a user * Then there is an entry showing that I created a user
*
* @throws Exception
*/ */
@Test @Test
@AlfrescoTest(jira = "RM-6223") @AlfrescoTest(jira = "RM-6223")

View File

@@ -143,7 +143,7 @@ public class BaseRMRestTest extends RestTest
/** Valid root containers where electronic and non-electronic records can be created */ /** Valid root containers where electronic and non-electronic records can be created */
@DataProvider(name = "validRootContainers") @DataProvider(name = "validRootContainers")
public Object[][] getValidRootContainers() throws Exception public Object[][] getValidRootContainers()
{ {
return new String[][] return new String[][]
{ {
@@ -171,7 +171,7 @@ public class BaseRMRestTest extends RestTest
* Helper method to create the RM Site via the POST request * Helper method to create the RM Site via the POST request
* if the site doesn't exist * if the site doesn't exist
*/ */
public void createRMSiteIfNotExists() throws Exception public void createRMSiteIfNotExists()
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
@@ -189,7 +189,7 @@ public class BaseRMRestTest extends RestTest
/** /**
* Helper method to delete the RM site if exists and to create a new one * Helper method to delete the RM site if exists and to create a new one
*/ */
public void createRMSite(RMSite rmSiteModel) throws Exception public void createRMSite(RMSite rmSiteModel)
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
if (rmSiteAPI.existsRMSite()) if (rmSiteAPI.existsRMSite())
@@ -207,9 +207,9 @@ public class BaseRMRestTest extends RestTest
* *
* @param categoryName The name of the category * @param categoryName The name of the category
* @return The created category * @return The created category
* @throws Exception on unsuccessful component creation * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategory createRootCategory(String categoryName) throws Exception public RecordCategory createRootCategory(String categoryName)
{ {
return createRootCategory(getAdminUser(), categoryName, RECORD_CATEGORY_TITLE); return createRootCategory(getAdminUser(), categoryName, RECORD_CATEGORY_TITLE);
} }
@@ -233,9 +233,9 @@ public class BaseRMRestTest extends RestTest
* @param categoryName The name of the category * @param categoryName The name of the category
* @param categoryTitle The title of the category * @param categoryTitle The title of the category
* @return The created category * @return The created category
* @throws Exception on unsuccessful component creation * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategory createRootCategory(String categoryName, String categoryTitle) throws Exception public RecordCategory createRootCategory(String categoryName, String categoryTitle)
{ {
return createRootCategory(getAdminUser(), categoryName, categoryTitle); return createRootCategory(getAdminUser(), categoryName, categoryTitle);
} }
@@ -263,9 +263,9 @@ public class BaseRMRestTest extends RestTest
* @param name The name of the record category child * @param name The name of the record category child
* @param type The type of the record category child * @param type The type of the record category child
* @return The created {@link RecordCategoryChild} * @return The created {@link RecordCategoryChild}
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)} * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name, String type) throws Exception public RecordCategoryChild createRecordCategoryChild(UserModel user, String recordCategoryId, String name, String type)
{ {
RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type); RecordCategoryChild recordCategoryChildModel = createRecordCategoryChildModel(name, type);
return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel, recordCategoryId); return getRestAPIFactory().getRecordCategoryAPI(user).createRecordCategoryChild(recordCategoryChildModel, recordCategoryId);
@@ -278,9 +278,9 @@ public class BaseRMRestTest extends RestTest
* @param name The name of the record category child * @param name The name of the record category child
* @param type The type of the record category child * @param type The type of the record category child
* @return The created {@link RecordCategoryChild} * @return The created {@link RecordCategoryChild}
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)} * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type) throws Exception public RecordCategoryChild createRecordCategoryChild(String recordCategoryId, String name, String type)
{ {
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type); return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, type);
} }
@@ -291,9 +291,9 @@ public class BaseRMRestTest extends RestTest
* @param recordCategoryId The id of the record category * @param recordCategoryId The id of the record category
* @param name The name of the record category child * @param name The name of the record category child
* @return The created {@link RecordCategoryChild} * @return The created {@link RecordCategoryChild}
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)} * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategoryChild createRecordCategory(String recordCategoryId, String name) throws Exception public RecordCategoryChild createRecordCategory(String recordCategoryId, String name)
{ {
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, RECORD_CATEGORY_TYPE); return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, RECORD_CATEGORY_TYPE);
} }
@@ -304,9 +304,9 @@ public class BaseRMRestTest extends RestTest
* @param recordCategoryId The id of the record category * @param recordCategoryId The id of the record category
* @param name The name of the record category child * @param name The name of the record category child
* @return The created {@link RecordCategoryChild} * @return The created {@link RecordCategoryChild}
* @throws Exception {@link RecordCategoryAPI#createRecordCategoryChild(RecordCategoryChild, String)} * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategoryChild createRecordFolder(String recordCategoryId, String name) throws Exception public RecordCategoryChild createRecordFolder(String recordCategoryId, String name)
{ {
return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, RECORD_FOLDER_TYPE); return createRecordCategoryChild(getAdminUser(), recordCategoryId, name, RECORD_FOLDER_TYPE);
} }
@@ -332,9 +332,9 @@ public class BaseRMRestTest extends RestTest
* @param recordCategoryId The id of the record category * @param recordCategoryId The id of the record category
* @param name The name of the folder * @param name The name of the folder
* @return The created folder * @return The created folder
* @throws Exception on unsuccessful component creation * @throws RuntimeException on unsuccessful component creation
*/ */
public RecordCategoryChild createFolder(String recordCategoryId, String name) throws Exception public RecordCategoryChild createFolder(String recordCategoryId, String name)
{ {
return createFolder(getAdminUser(), recordCategoryId, name); return createFolder(getAdminUser(), recordCategoryId, name);
} }
@@ -346,9 +346,9 @@ public class BaseRMRestTest extends RestTest
* @param parentId The id of the parent folder * @param parentId The id of the parent folder
* @param nodeType The child type * @param nodeType The child type
* @return The created folder * @return The created folder
* @throws Exception on unsuccessful component creation * @throws RuntimeException on unsuccessful component creation
*/ */
public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName, String nodeType) throws Exception public UnfiledContainerChild createUnfiledRecordsFolderChild(UserModel user, String parentId, String childName, String nodeType)
{ {
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType); UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(childModel, parentId); UnfiledContainerChild child = getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(childModel, parentId);
@@ -363,9 +363,9 @@ public class BaseRMRestTest extends RestTest
* @param parentId The id of the parent folder * @param parentId The id of the parent folder
* @param nodeType The child type * @param nodeType The child type
* @return The created folder * @return The created folder
* @throws Exception on unsuccessful component creation * @throws RuntimeException on unsuccessful component creation
*/ */
public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType) throws Exception public UnfiledContainerChild createUnfiledRecordsFolderChild(String parentId, String childName, String nodeType)
{ {
return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType); return createUnfiledRecordsFolderChild(getAdminUser(), parentId, childName, nodeType);
} }
@@ -376,11 +376,11 @@ public class BaseRMRestTest extends RestTest
* @param user The user under whose privileges this structure is going to be created * @param user The user under whose privileges this structure is going to be created
* @param parentId The id of the parent container * @param parentId The id of the parent container
* @param childName The name of the child * @param childName The name of the child
* @oaram nodeType the child type * @param nodeType the child type
* @return The created chid * @return The created chid
* @throws Exception on unsuccessful child creation * @throws RuntimeException on unsuccessful child creation
*/ */
public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType) throws Exception public UnfiledContainerChild createUnfiledContainerChild(UserModel user, String parentId, String childName, String nodeType)
{ {
UnfiledContainerChild child = null; UnfiledContainerChild child = null;
UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType); UnfiledContainerChild childModel = createUnfiledContainerChildModel(childName, nodeType);
@@ -403,11 +403,11 @@ public class BaseRMRestTest extends RestTest
* *
* @param parentId The id of the parent container * @param parentId The id of the parent container
* @param childName The name of the child * @param childName The name of the child
* @oaram nodeType the child type * @param nodeType the child type
* @return The created chid * @return The created chid
* @throws Exception on unsuccessful child creation * @throws RuntimeException on unsuccessful child creation
*/ */
public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType) throws Exception public UnfiledContainerChild createUnfiledContainerChild(String parentId, String childName, String nodeType)
{ {
return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType); return createUnfiledContainerChild(getAdminUser(), parentId, childName, nodeType);
} }
@@ -417,9 +417,8 @@ public class BaseRMRestTest extends RestTest
* *
* @param folderId The id of the folder * @param folderId The id of the folder
* @return The closed folder * @return The closed folder
* @throws Exception
*/ */
protected RecordFolder closeFolder(String folderId) throws Exception protected RecordFolder closeFolder(String folderId)
{ {
RecordFolder recordFolderModel = RecordFolder.builder() RecordFolder recordFolderModel = RecordFolder.builder()
.properties(RecordFolderProperties.builder() .properties(RecordFolderProperties.builder()
@@ -437,9 +436,8 @@ public class BaseRMRestTest extends RestTest
* *
* @param recordId The id of the record to complete * @param recordId The id of the record to complete
* @return The completed record * @return The completed record
* @throws Exception
*/ */
public Record completeRecord(String recordId) throws Exception public Record completeRecord(String recordId)
{ {
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
List<String> aspects = recordsAPI.getRecord(recordId).getAspectNames(); List<String> aspects = recordsAPI.getRecord(recordId).getAspectNames();
@@ -532,7 +530,6 @@ public class BaseRMRestTest extends RestTest
* @param parentId the id of the parent * @param parentId the id of the parent
* @param name the name of the record * @param name the name of the record
* @return the created record * @return the created record
* @throws Exception
*/ */
public Record createElectronicRecord(String parentId, String name) public Record createElectronicRecord(String parentId, String name)
{ {
@@ -546,7 +543,6 @@ public class BaseRMRestTest extends RestTest
* @param parentId the id of the parent * @param parentId the id of the parent
* @param name the name of the record * @param name the name of the record
* @return the created record * @return the created record
* @throws Exception
*/ */
public Record createElectronicRecord(String parentId, String name, UserModel user) public Record createElectronicRecord(String parentId, String name, UserModel user)
{ {
@@ -561,9 +557,8 @@ public class BaseRMRestTest extends RestTest
* @param parentId the id of the parent * @param parentId the id of the parent
* @param name the name of the record * @param name the name of the record
* @return the created record * @return the created record
* @throws Exception
*/ */
public Record createNonElectronicRecord(String parentId, String name) throws Exception public Record createNonElectronicRecord(String parentId, String name)
{ {
return createNonElectronicRecord(parentId, name, null); return createNonElectronicRecord(parentId, name, null);
} }
@@ -575,9 +570,8 @@ public class BaseRMRestTest extends RestTest
* @param name the name of the record * @param name the name of the record
* @param user the user who creates the non-electronic record * @param user the user who creates the non-electronic record
* @return the created record * @return the created record
* @throws Exception
*/ */
public Record createNonElectronicRecord(String parentId, String name, UserModel user) throws Exception public Record createNonElectronicRecord(String parentId, String name, UserModel user)
{ {
RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user); RecordFolderAPI recordFolderAPI = restAPIFactory.getRecordFolderAPI(user);
Record recordModel = Record.builder().name(name).nodeType(NON_ELECTRONIC_RECORD_TYPE).build(); Record recordModel = Record.builder().name(name).nodeType(NON_ELECTRONIC_RECORD_TYPE).build();
@@ -623,9 +617,8 @@ public class BaseRMRestTest extends RestTest
* @param user * @param user
* @param term * @param term
* @return * @return
* @throws Exception
*/ */
public List<String> searchForContentAsUser(UserModel user, String term) throws Exception public List<String> searchForContentAsUser(UserModel user, String term)
{ {
getRestAPIFactory().getRmRestWrapper().authenticateUser(user); getRestAPIFactory().getRmRestWrapper().authenticateUser(user);
RestRequestQueryModel queryReq = new RestRequestQueryModel(); RestRequestQueryModel queryReq = new RestRequestQueryModel();
@@ -833,7 +826,7 @@ public class BaseRMRestTest extends RestTest
{ {
try try
{ {
Utility.sleep(5000, 15000, Utility.sleep(1000, 10000,
() -> { () -> {
Optional<UnfiledContainerChildEntry> matchingRecord = getRestAPIFactory().getUnfiledContainersAPI() Optional<UnfiledContainerChildEntry> matchingRecord = getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS) .getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS)
@@ -863,7 +856,7 @@ public class BaseRMRestTest extends RestTest
{ {
try try
{ {
Utility.sleep(5000, 15000, Utility.sleep(1000, 10000,
() -> { () -> {
Optional<RecordFolderEntry> matchingRecord = getRestAPIFactory().getRecordFolderAPI() Optional<RecordFolderEntry> matchingRecord = getRestAPIFactory().getRecordFolderAPI()
.getRecordFolderChildren(recFolder.getId()) .getRecordFolderChildren(recFolder.getId())
@@ -892,7 +885,7 @@ public class BaseRMRestTest extends RestTest
{ {
try try
{ {
Utility.sleep(5000, 15000, Utility.sleep(1000, 10000,
() -> { () -> {
UnfiledContainerChildEntry matchingRecord = getRestAPIFactory().getUnfiledContainersAPI() UnfiledContainerChildEntry matchingRecord = getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS, "include=properties,aspectNames") .getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS, "include=properties,aspectNames")
@@ -926,7 +919,7 @@ public class BaseRMRestTest extends RestTest
{ {
try try
{ {
Utility.sleep(5000, 15000, Utility.sleep(1000, 10000,
() -> { () -> {
RecordFolderEntry matchingRecord = getRestAPIFactory().getRecordFolderAPI() RecordFolderEntry matchingRecord = getRestAPIFactory().getRecordFolderAPI()
.getRecordFolderChildren(recordFolder.getId(),"include=properties,aspectNames") .getRecordFolderChildren(recordFolder.getId(),"include=properties,aspectNames")

View File

@@ -45,6 +45,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.FORBIDDEN;
@@ -65,7 +66,6 @@ import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.base.DataProviderClass; import org.alfresco.rest.rm.community.base.DataProviderClass;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan; import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
import org.alfresco.rest.rm.community.model.fileplan.FilePlanProperties; import org.alfresco.rest.rm.community.model.fileplan.FilePlanProperties;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryCollection;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryProperties;
@@ -115,8 +115,8 @@ public class FilePlanTests extends BaseRMRestTest
* Then I get the 404 response code * Then I get the 404 response code
* </pre> * </pre>
*/ */
@Test @Test (priority = 1)
public void getFilePlanWhenRMIsNotCreated() throws Exception public void getFilePlanWhenRMIsNotCreated()
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
@@ -141,19 +141,18 @@ public class FilePlanTests extends BaseRMRestTest
* </pre> * </pre>
*/ */
@Test @Test
public void getFilePlanWhenRMIsCreated() throws Exception public void getFilePlanWhenRMIsCreated()
{ {
// Create RM Site if doesn't exist // Create RM Site if doesn't exist
createRMSiteIfNotExists(); createRMSiteIfNotExists();
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS); FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
// Check the response code // Check the response code
assertStatusCode(OK); assertStatusCode(OK);
//check file plan details //check file plan details
assertTrue(filePlan.getNodeType().equals(FilePlanComponentType.FILE_PLAN_TYPE)); assertEquals(FILE_PLAN_TYPE, filePlan.getNodeType());
assertTrue(filePlan.getName().equals(ContainerName.documentLibrary.toString())); assertEquals(ContainerName.documentLibrary.toString(), filePlan.getName());
} }
/** /**
@@ -164,11 +163,8 @@ public class FilePlanTests extends BaseRMRestTest
* </pre> * </pre>
*/ */
@Test @Test
public void includeAllowableOperations() throws Exception public void includeAllowableOperations()
{ {
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Check the list of allowableOperations returned // Check the list of allowableOperations returned
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS, "include=" + ALLOWABLE_OPERATIONS); FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS, "include=" + ALLOWABLE_OPERATIONS);
@@ -178,7 +174,6 @@ public class FilePlanTests extends BaseRMRestTest
// Check the list of allowableOperations doesn't contain DELETE operation // Check the list of allowableOperations doesn't contain DELETE operation
assertFalse(filePlan.getAllowableOperations().contains(DELETE), assertFalse(filePlan.getAllowableOperations().contains(DELETE),
"The list of allowable operations contains delete option" + filePlan.getAllowableOperations().toString()); "The list of allowable operations contains delete option" + filePlan.getAllowableOperations().toString());
} }
/** /**
@@ -189,11 +184,8 @@ public class FilePlanTests extends BaseRMRestTest
* </pre> * </pre>
*/ */
@Test @Test
public void getFilePlanWithNonRMuser() throws Exception public void getFilePlanWithNonRMuser()
{ {
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Create a random user // Create a random user
UserModel nonRMuser = getDataUser().createRandomTestUser("testUser"); UserModel nonRMuser = getDataUser().createRandomTestUser("testUser");
@@ -212,14 +204,11 @@ public class FilePlanTests extends BaseRMRestTest
*/ */
@Test @Test
@Bug (id = "RM-4295") @Bug (id = "RM-4295")
public void updateFilePlan() throws Exception public void updateFilePlan()
{ {
String FILE_PLAN_DESCRIPTION = "Description updated " + getRandomAlphanumeric(); String FILE_PLAN_DESCRIPTION = "Description updated " + getRandomAlphanumeric();
String FILE_PLAN_TITLE = "Title updated " + getRandomAlphanumeric(); String FILE_PLAN_TITLE = "Title updated " + getRandomAlphanumeric();
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Build object for updating the filePlan // Build object for updating the filePlan
FilePlan filePlanComponent = FilePlan.builder() FilePlan filePlanComponent = FilePlan.builder()
.properties(FilePlanProperties.builder() .properties(FilePlanProperties.builder()
@@ -256,16 +245,11 @@ public class FilePlanTests extends BaseRMRestTest
*/ */
@Test @Test
@Bug (id = "RM-4295") @Bug (id = "RM-4295")
public void updateFilePlanName() throws Exception public void updateFilePlanName()
{ {
String FILE_PLAN_NAME = "File Plan name updated " + getRandomAlphanumeric();
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Build object for updating the filePlan // Build object for updating the filePlan
FilePlan filePlanComponent = FilePlan.builder() FilePlan filePlanComponent = FilePlan.builder()
.name(FILE_PLAN_NAME) .name(getRandomName("File Plan name updated "))
.build(); .build();
// Update the file plan // Update the file plan
@@ -294,7 +278,7 @@ public class FilePlanTests extends BaseRMRestTest
dataProviderClass = DataProviderClass.class, dataProviderClass = DataProviderClass.class,
dataProvider = "categoryTypes" dataProvider = "categoryTypes"
) )
public void createFilePlanChildren(String nodeType) throws Exception public void createFilePlanChildren(String nodeType)
{ {
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
String categoryTitle = "Category title " + getRandomAlphanumeric(); String categoryTitle = "Category title " + getRandomAlphanumeric();
@@ -338,7 +322,7 @@ public class FilePlanTests extends BaseRMRestTest
*/ */
@Test @Test
@Bug(id = "RM-5116") @Bug(id = "RM-5116")
public void createDuplicateCategories() throws Exception public void createDuplicateCategories()
{ {
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
String categoryTitle = "Category title " + getRandomAlphanumeric(); String categoryTitle = "Category title " + getRandomAlphanumeric();
@@ -375,15 +359,13 @@ public class FilePlanTests extends BaseRMRestTest
} }
@Test @Test
public void listFilePlanChildren() throws Exception public void listFilePlanChildren()
{ {
//delete all the root categories //delete all the root categories
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry -> getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
{ deleteRecordCategory(recordCategoryEntry.getEntry().getId()));
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategoryEntry.getEntry().getId());
});
// Add child folders // Add child folders
ArrayList<RecordCategory> children = new ArrayList<RecordCategory>(); ArrayList<RecordCategory> children = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
@@ -415,7 +397,7 @@ public class FilePlanTests extends BaseRMRestTest
RecordCategory createdComponent = children.stream() RecordCategory createdComponent = children.stream()
.filter(child -> child.getId().equals(recordCategoryChildId)) .filter(child -> child.getId().equals(recordCategoryChildId))
.findFirst() .findFirst()
.get(); .orElseThrow();
// Created by // Created by
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -444,7 +426,7 @@ public class FilePlanTests extends BaseRMRestTest
description = "Create a record folder/unfiled container/unfiled folder/record/file plan container", description = "Create a record folder/unfiled container/unfiled folder/record/file plan container",
dataProvider = "childrenNotAllowedForFilePlan" dataProvider = "childrenNotAllowedForFilePlan"
) )
public void createChildrenNotAllowedInFilePlan(String nodeType) throws Exception public void createChildrenNotAllowedInFilePlan(String nodeType)
{ {
String componentName = "Component" + getRandomAlphanumeric(); String componentName = "Component" + getRandomAlphanumeric();
@@ -468,16 +450,13 @@ public class FilePlanTests extends BaseRMRestTest
} }
@Test @Test
public void listChildrenUserPermission() throws Exception public void listChildrenUserPermission()
{ {
// Create RM Site if doesn't exist
createRMSiteIfNotExists();
// Create a random user // Create a random user
UserModel managerUser = getDataUser().createRandomTestUser("managerUser"); UserModel managerUser = getDataUser().createRandomTestUser("managerUser");
// Add child folders // Add child folders
ArrayList<RecordCategory> children = new ArrayList<RecordCategory>(); ArrayList<RecordCategory> children = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_CHILDREN/2; i++) for (int i = 0; i < NUMBER_OF_CHILDREN/2; i++)
{ {
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
@@ -493,7 +472,7 @@ public class FilePlanTests extends BaseRMRestTest
getRestAPIFactory().getFilePlansAPI(managerUser).getRootRecordCategories(FILE_PLAN_ALIAS) getRestAPIFactory().getFilePlansAPI(managerUser).getRootRecordCategories(FILE_PLAN_ALIAS)
.assertThat().entriesListIsEmpty().assertThat().paginationExist(); .assertThat().entriesListIsEmpty().assertThat().paginationExist();
ArrayList<RecordCategory> childrenManager = new ArrayList<RecordCategory>(); ArrayList<RecordCategory> childrenManager = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_CHILDREN / 2; i++) for (int i = 0; i < NUMBER_OF_CHILDREN / 2; i++)
{ {
String categoryName = "Category for manager " + getRandomAlphanumeric(); String categoryName = "Category for manager " + getRandomAlphanumeric();

View File

@@ -95,7 +95,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
private FolderModel testFolder; private FolderModel testFolder;
private FileModel testFile; private FileModel testFile;
private RecordCategory recordCategory; private RecordCategory recordCategory;
private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedRecordFolder, recordFolderWithSpacesInName; private RecordCategoryChild recordFolder, subcategoryRecordFolder, closedRecordFolder, recordFolderWithSpacesInName;
private UnfiledContainerChild unfiledContainerFolder; private UnfiledContainerChild unfiledContainerFolder;
private String holdNodeRef; private String holdNodeRef;
@@ -154,7 +154,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
} }
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void declareAndFileDocumentAsRecordSetup() throws Exception public void declareAndFileDocumentAsRecordSetup()
{ {
STEP("Create test collaboration site to store documents in."); STEP("Create test collaboration site to store documents in.");
publicSite = dataSite.usingAdmin().createPublicRandomSite(); publicSite = dataSite.usingAdmin().createPublicRandomSite();
@@ -164,7 +164,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
STEP("Create record categories and record folders"); STEP("Create record categories and record folders");
recordCategory = createRootCategory(getRandomName("recordCategory")); recordCategory = createRootCategory(getRandomName("recordCategory"));
subCategory = createRecordCategory(recordCategory.getId(), getRandomName("subCategory")); RecordCategoryChild subCategory = createRecordCategory(recordCategory.getId(), getRandomName("subCategory"));
recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder")); recordFolder = createFolder(recordCategory.getId(), getRandomName("recordFolder"));
subcategoryRecordFolder = createFolder(subCategory.getId(), getRandomName("recordFolder")); subcategoryRecordFolder = createFolder(subCategory.getId(), getRandomName("recordFolder"));
unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
@@ -180,7 +180,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
} }
@BeforeMethod(alwaysRun = true) @BeforeMethod(alwaysRun = true)
public void createDocument() throws Exception public void createDocument()
{ {
STEP("Create a document in the collaboration site"); STEP("Create a document in the collaboration site");
testFile = dataContent.usingSite(publicSite) testFile = dataContent.usingSite(publicSite)
@@ -429,7 +429,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
* Then I get an invalid operation exception * Then I get an invalid operation exception
*/ */
@Test @Test
public void declareAndFileTwiceDifferentLocations() throws Exception public void declareAndFileTwiceDifferentLocations()
{ {
STEP("Create a document in the collaboration site"); STEP("Create a document in the collaboration site");
FileModel testFile = dataContent.usingSite(publicSite).usingAdmin() FileModel testFile = dataContent.usingSite(publicSite).usingAdmin()

View File

@@ -76,7 +76,7 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
RecordsAPI recordsAPI; RecordsAPI recordsAPI;
@BeforeClass(alwaysRun=true) @BeforeClass(alwaysRun=true)
public void declareDocumentAsRecordSetup() throws Exception public void declareDocumentAsRecordSetup()
{ {
// create test user and test collaboration site to store documents in // create test user and test collaboration site to store documents in
testUser = getDataUser().createRandomTestUser(); testUser = getDataUser().createRandomTestUser();
@@ -208,11 +208,10 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
* When I declare the record as a record * When I declare the record as a record
* Then I get a invalid operation exception * Then I get a invalid operation exception
* </pre> * </pre>
* @throws Exception for malformed JSON API response
*/ */
@Test(description = "Record can't be declared a record") @Test(description = "Record can't be declared a record")
@AlfrescoTest(jira = "RM-4429") @AlfrescoTest(jira = "RM-4429")
public void recordCantBeDeclaredARecord() throws Exception public void recordCantBeDeclaredARecord()
{ {
// create a non-electronic record in a random folder // create a non-electronic record in a random folder
Record nonelectronicRecord = Record.builder() Record nonelectronicRecord = Record.builder()
@@ -238,11 +237,10 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
* When I declare the node as a record * When I declare the node as a record
* Then I get a invalid operation exception * Then I get a invalid operation exception
* </pre> * </pre>
* @throws Exception for malformed JSON API response
*/ */
@Test(description = "Node that is not a document can't be declared a record") @Test(description = "Node that is not a document can't be declared a record")
@AlfrescoTest(jira = "RM-4429") @AlfrescoTest(jira = "RM-4429")
public void nonDocumentCantBeDeclaredARecord() throws Exception public void nonDocumentCantBeDeclaredARecord()
{ {
FolderModel otherTestFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder(); FolderModel otherTestFolder = dataContent.usingSite(testSite).usingUser(testUser).createFolder();
@@ -258,7 +256,7 @@ public class DeclareDocumentAsRecordTests extends BaseRMRestTest
*/ */
@Test (description = "Declaring as record a file that already has its version declared as record is successful") @Test (description = "Declaring as record a file that already has its version declared as record is successful")
@AlfrescoTest (jira = "RM-6786") @AlfrescoTest (jira = "RM-6786")
public void declareAsRecordAFileWithARecordVersion() throws Exception public void declareAsRecordAFileWithARecordVersion()
{ {
STEP("Create a file."); STEP("Create a file.");
FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);

View File

@@ -99,7 +99,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest
private HoldsAPI holdsAPI; private HoldsAPI holdsAPI;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void declareAndFileVersionAsRecordSetup() throws Exception public void declareAndFileVersionAsRecordSetup()
{ {
STEP("Create test collaboration site to store documents in."); STEP("Create test collaboration site to store documents in.");
publicSite = dataSite.usingAdmin().createPublicRandomSite(); publicSite = dataSite.usingAdmin().createPublicRandomSite();
@@ -127,7 +127,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest
} }
@BeforeMethod (alwaysRun = true) @BeforeMethod (alwaysRun = true)
public void createDocument() throws Exception public void createDocument()
{ {
STEP("Create a document in the collaboration site"); STEP("Create a document in the collaboration site");
testFile = dataContent.usingSite(publicSite) testFile = dataContent.usingSite(publicSite)

View File

@@ -98,8 +98,8 @@ public class AddToHoldsTests extends BaseRMRestTest
private String holdNodeRef; private String holdNodeRef;
private FileModel documentHeld, contentToAddToHold, contentAddToHoldNoPermission; private FileModel documentHeld, contentToAddToHold, contentAddToHoldNoPermission;
private UserModel userAddHoldPermission; private UserModel userAddHoldPermission;
private List<UserModel> users = new ArrayList<>(); private final List<UserModel> users = new ArrayList<>();
private List<String> nodesToBeClean = new ArrayList<>(); private final List<String> nodesToBeClean = new ArrayList<>();
@Autowired @Autowired
private HoldsAPI holdsAPI; private HoldsAPI holdsAPI;
@@ -233,7 +233,7 @@ public class AddToHoldsTests extends BaseRMRestTest
* @return object with user model and the node ref to be added to hold * @return object with user model and the node ref to be added to hold
*/ */
@DataProvider (name = "userWithoutPermissionForAddToHold") @DataProvider (name = "userWithoutPermissionForAddToHold")
public Object[][] getUserWithoutPermissionForAddToHold() throws Exception public Object[][] getUserWithoutPermissionForAddToHold()
{ {
//create record folder //create record folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
@@ -299,7 +299,7 @@ public class AddToHoldsTests extends BaseRMRestTest
* Data provider with invalid node types that can be added to a hold * Data provider with invalid node types that can be added to a hold
*/ */
@DataProvider (name = "invalidNodesForAddToHold") @DataProvider (name = "invalidNodesForAddToHold")
public Object[][] getInvalidNodesForAddToHold() throws Exception public Object[][] getInvalidNodesForAddToHold()
{ {
//create locked file //create locked file
FileModel contentLocked = dataContent.usingAdmin().usingSite(testSite) FileModel contentLocked = dataContent.usingAdmin().usingSite(testSite)
@@ -360,6 +360,6 @@ public class AddToHoldsTests extends BaseRMRestTest
holdsAPI.deleteHold(getAdminUser(), holdNodeRef); holdsAPI.deleteHold(getAdminUser(), holdNodeRef);
dataSite.usingAdmin().deleteSite(testSite); dataSite.usingAdmin().deleteSite(testSite);
users.forEach(user -> getDataUser().usingAdmin().deleteUser(user)); users.forEach(user -> getDataUser().usingAdmin().deleteUser(user));
nodesToBeClean.forEach( category -> getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(category)); nodesToBeClean.forEach( category -> deleteRecordCategory(category));
} }
} }

View File

@@ -96,7 +96,7 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
private RMRolesAndActionsAPI rmRolesAndActionsAPI; private RMRolesAndActionsAPI rmRolesAndActionsAPI;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void preconditionForPreventActionsOnFrozenContent() throws Exception public void preconditionForPreventActionsOnFrozenContent()
{ {
STEP("Create a hold."); STEP("Create a hold.");
holdNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getUsername(), holdNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getUsername(),
@@ -262,12 +262,10 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
* When I add a disposition schedule * When I add a disposition schedule
* Then I am successful * Then I am successful
* And the record search disposition schedule properties are updated * And the record search disposition schedule properties are updated
*
* @throws Exception
*/ */
@Test @Test
@AlfrescoTest (jira = "RM-6929") @AlfrescoTest (jira = "RM-6929")
public void createDispositionScheduleOnCategoryWithHeldChildren() throws Exception public void createDispositionScheduleOnCategoryWithHeldChildren()
{ {
STEP("Create a retention schedule on the category with frozen children"); STEP("Create a retention schedule on the category with frozen children");
RecordCategory categoryWithRS = getRestAPIFactory().getRecordCategoryAPI() RecordCategory categoryWithRS = getRestAPIFactory().getRecordCategoryAPI()
@@ -290,12 +288,10 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
* When I execute the retain action * When I execute the retain action
* Then the action is executed * Then the action is executed
* And the record search disposition schedule properties are updated * And the record search disposition schedule properties are updated
*
* @throws Exception
*/ */
@Test @Test
@AlfrescoTest (jira = "RM-6931") @AlfrescoTest (jira = "RM-6931")
public void retainActionOnFrozenHeldRecords() throws Exception public void retainActionOnFrozenHeldRecords()
{ {
STEP("Add a category with a disposition schedule."); STEP("Add a category with a disposition schedule.");
categoryWithRS = createRootCategory(getRandomName("CategoryWithRS")); categoryWithRS = createRootCategory(getRandomName("CategoryWithRS"));
@@ -326,8 +322,8 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest
{ {
holdsAPI.deleteHold(getAdminUser(), holdNodeRef); holdsAPI.deleteHold(getAdminUser(), holdNodeRef);
dataSite.usingAdmin().deleteSite(testSite); dataSite.usingAdmin().deleteSite(testSite);
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordFolder.getParentId()); deleteRecordCategory(recordFolder.getParentId());
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(categoryWithRS.getId()); deleteRecordCategory(categoryWithRS.getId());
} }
} }

View File

@@ -88,8 +88,8 @@ public class RemoveFromHoldsTests extends BaseRMRestTest
private String holdNodeRefOne; private String holdNodeRefOne;
private String holdNodeRefTwo; private String holdNodeRefTwo;
private FileModel contentHeld, contentAddToManyHolds; private FileModel contentHeld, contentAddToManyHolds;
private Set<UserModel> usersToBeClean = new HashSet<>(); private final Set<UserModel> usersToBeClean = new HashSet<>();
private Set<String> nodesToBeClean = new HashSet<>(); private final Set<String> nodesToBeClean = new HashSet<>();
@Autowired @Autowired
private HoldsAPI holdsAPI; private HoldsAPI holdsAPI;
@Autowired @Autowired
@@ -202,10 +202,9 @@ public class RemoveFromHoldsTests extends BaseRMRestTest
/** /**
* Data provider with user without right permission or capability to remove from hold a specific node * Data provider with user without right permission or capability to remove from hold a specific node
* @return user model and the node ref to be removed from hold * @return user model and the node ref to be removed from hold
* @throws Exception
*/ */
@DataProvider (name = "userWithoutPermissionForRemoveFromHold") @DataProvider (name = "userWithoutPermissionForRemoveFromHold")
public Object[][] getUserWithoutPermissionForAddToHold() throws Exception public Object[][] getUserWithoutPermissionForAddToHold()
{ {
//create record folder //create record folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
@@ -277,10 +276,9 @@ public class RemoveFromHoldsTests extends BaseRMRestTest
* Data provider with user with right permission or capability to remove from hold a specific node * Data provider with user with right permission or capability to remove from hold a specific node
* *
* @return user model and the node ref to be removed from hold * @return user model and the node ref to be removed from hold
* @throws Exception
*/ */
@DataProvider (name = "userWithPermissionForRemoveFromHold") @DataProvider (name = "userWithPermissionForRemoveFromHold")
public Object[][] getUserWithPermissionForAddToHold() throws Exception public Object[][] getUserWithPermissionForAddToHold()
{ {
//create record folder //create record folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
@@ -332,7 +330,7 @@ public class RemoveFromHoldsTests extends BaseRMRestTest
dataSite.usingAdmin().deleteSite(testSite); dataSite.usingAdmin().deleteSite(testSite);
dataSite.usingAdmin().deleteSite(privateSite); dataSite.usingAdmin().deleteSite(privateSite);
usersToBeClean.forEach(user -> getDataUser().usingAdmin().deleteUser(user)); usersToBeClean.forEach(user -> getDataUser().usingAdmin().deleteUser(user));
nodesToBeClean.forEach(category -> getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(category)); nodesToBeClean.forEach(category -> deleteRecordCategory(category));
} }
} }

View File

@@ -58,7 +58,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
*/ */
@AlfrescoTest (jira = "MNT-19967") @AlfrescoTest (jira = "MNT-19967")
@Test @Test
public void testRSInheritanceOnRecordsWhenOnlyACategoryHasRS() throws Exception public void testRSInheritanceOnRecordsWhenOnlyACategoryHasRS()
{ {
STEP("Create record category with retention schedule and apply it to records."); STEP("Create record category with retention schedule and apply it to records.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
@@ -94,7 +94,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
* Then recFolder should inherit the RS from rootCategory * Then recFolder should inherit the RS from rootCategory
*/ */
@Test @Test
public void testRSInheritanceOnRecordFoldersWhenOnlyACategoryHasRS() throws Exception public void testRSInheritanceOnRecordFoldersWhenOnlyACategoryHasRS()
{ {
STEP("Create record category with retention schedule and apply it to record folders."); STEP("Create record category with retention schedule and apply it to record folders.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
@@ -126,7 +126,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
* Then both records should inherit the RS from subCategory1 * Then both records should inherit the RS from subCategory1
*/ */
@Test @Test
public void testRSInheritanceOnRecordsWhen2CategoriesHaveRS() throws Exception public void testRSInheritanceOnRecordsWhen2CategoriesHaveRS()
{ {
STEP("Create record category with retention schedule and apply it to records."); STEP("Create record category with retention schedule and apply it to records.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
@@ -174,7 +174,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
* Then recFolder should inherit the RS from subCategory1 * Then recFolder should inherit the RS from subCategory1
*/ */
@Test @Test
public void testRSInheritanceOnRecordFoldersWhen2CategoriesHaveRS() throws Exception public void testRSInheritanceOnRecordFoldersWhen2CategoriesHaveRS()
{ {
STEP("Create record category with retention schedule and apply it to record folders."); STEP("Create record category with retention schedule and apply it to record folders.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
@@ -213,7 +213,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
* Then both records should inherit the RS from subCategory * Then both records should inherit the RS from subCategory
*/ */
@Test @Test
public void testMixedRSInheritanceWhenFirstParentHasRSOnRecords() throws Exception public void testMixedRSInheritanceWhenFirstParentHasRSOnRecords()
{ {
STEP("Create record category with retention schedule and apply it to folder records."); STEP("Create record category with retention schedule and apply it to folder records.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));
@@ -260,7 +260,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest
* and record folder inherits the RS from subCategory * and record folder inherits the RS from subCategory
*/ */
@Test @Test
public void testMixedRSInheritanceWhenFirstParentHasRSOnFolders() throws Exception public void testMixedRSInheritanceWhenFirstParentHasRSOnFolders()
{ {
STEP("Create record category with retention schedule and apply it to records."); STEP("Create record category with retention schedule and apply it to records.");
RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory"));

View File

@@ -28,12 +28,10 @@ package org.alfresco.rest.rm.community.recordcategories;
import static java.time.LocalDateTime.now; import static java.time.LocalDateTime.now;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME; import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
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.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
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;
@@ -87,6 +85,8 @@ import org.testng.annotations.Test;
*/ */
public class RecordCategoryTests extends BaseRMRestTest public class RecordCategoryTests extends BaseRMRestTest
{ {
public static final String RECORD_CATEGORY_NAME = "CATEGORY NAME" + getRandomAlphanumeric();
/** Number of children (for children creation test) */ /** Number of children (for children creation test) */
private static final int NUMBER_OF_CHILDREN = 10; private static final int NUMBER_OF_CHILDREN = 10;
private static final int NUMBER_OF_FOLDERS = 5; private static final int NUMBER_OF_FOLDERS = 5;
@@ -98,7 +98,7 @@ public class RecordCategoryTests extends BaseRMRestTest
* Invalid containers that cannot be deleted with record category end-point * Invalid containers that cannot be deleted with record category end-point
*/ */
@DataProvider (name = "invalidContainersToDelete") @DataProvider (name = "invalidContainersToDelete")
public Object[][] getNodesToDelete() throws Exception public Object[][] getNodesToDelete()
{ {
return new String[][] { return new String[][] {
{ FILE_PLAN_ALIAS }, { FILE_PLAN_ALIAS },
@@ -122,7 +122,7 @@ public class RecordCategoryTests extends BaseRMRestTest
( (
description = "Rename root category" description = "Rename root category"
) )
public void renameCategory() throws Exception public void renameCategory()
{ {
// Create record category first // Create record category first
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
@@ -163,7 +163,7 @@ public class RecordCategoryTests extends BaseRMRestTest
( (
description = "Delete category" description = "Delete category"
) )
public void deleteCategory() throws Exception public void deleteCategory()
{ {
// Create record category first // Create record category first
String categoryName = "Category name " + getRandomAlphanumeric(); String categoryName = "Category name " + getRandomAlphanumeric();
@@ -201,7 +201,7 @@ public class RecordCategoryTests extends BaseRMRestTest
description = "Delete invalid nodes with delete category endpoint", description = "Delete invalid nodes with delete category endpoint",
dataProvider = "invalidContainersToDelete" dataProvider = "invalidContainersToDelete"
) )
public void deleteInvalidNodes(String nodeId) throws Exception public void deleteInvalidNodes(String nodeId)
{ {
// Delete the record category // Delete the record category
@@ -224,7 +224,7 @@ public class RecordCategoryTests extends BaseRMRestTest
( (
description = "Create child category" description = "Create child category"
) )
public void createSubcategory() throws Exception public void createSubcategory()
{ {
// Create root level category // Create root level category
RecordCategory rootCategory = createRootCategory(getRandomAlphanumeric()); RecordCategory rootCategory = createRootCategory(getRandomAlphanumeric());
@@ -272,7 +272,7 @@ public class RecordCategoryTests extends BaseRMRestTest
dataProvider = "folderTypes" dataProvider = "folderTypes"
) )
@Bug (id = "RM-4572") @Bug (id = "RM-4572")
public void createFolderTest(String folderType) throws Exception public void createFolderTest(String folderType)
{ {
// Authenticate with admin user // Authenticate with admin user
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()); RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
@@ -304,7 +304,7 @@ public class RecordCategoryTests extends BaseRMRestTest
dataProvider = "categoryChild" dataProvider = "categoryChild"
) )
@Bug(id = "RM-5116") @Bug(id = "RM-5116")
public void createdDuplicateChild(String childType)throws Exception public void createdDuplicateChild(String childType)
{ {
// create a root category // create a root category
String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId(); String rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId();
@@ -354,7 +354,7 @@ public class RecordCategoryTests extends BaseRMRestTest
description = "Get children of a record category excluding the disposition schedule" description = "Get children of a record category excluding the disposition schedule"
) )
@Bug (id="RM-5115") @Bug (id="RM-5115")
public void getRecordCategoryChildren() throws Exception public void getRecordCategoryChildren()
{ {
// Create root level category // Create root level category
RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric()); RecordCategory rootRecordCategory = createRootCategory(getRandomAlphanumeric());
@@ -374,7 +374,7 @@ public class RecordCategoryTests extends BaseRMRestTest
recordCategoriesAPI.addDispositionScheduleSteps(userName, userPassword, categoryName, cutOffStep); recordCategoriesAPI.addDispositionScheduleSteps(userName, userPassword, categoryName, cutOffStep);
// Add record category children // Add record category children
List<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>(); List<RecordCategoryChild> children = new ArrayList<>();
for (int i=0; i < NUMBER_OF_CHILDREN; i++) for (int i=0; i < NUMBER_OF_CHILDREN; i++)
{ {
// Create a record category child // Create a record category child
@@ -408,7 +408,7 @@ public class RecordCategoryTests extends BaseRMRestTest
RecordCategoryChild createdComponent = children.stream() RecordCategoryChild createdComponent = children.stream()
.filter(child -> child.getId().equals(recordCategoryChildId)) .filter(child -> child.getId().equals(recordCategoryChildId))
.findFirst() .findFirst()
.get(); .orElseThrow();
// Created by // Created by
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -457,7 +457,7 @@ public class RecordCategoryTests extends BaseRMRestTest
dataProvider = "childrenNotAllowedForCategory" dataProvider = "childrenNotAllowedForCategory"
) )
@Bug (id="RM-4367, RM-4572") @Bug (id="RM-4367, RM-4572")
public void createTypesNotAllowedInCategory(String nodeType) throws Exception public void createTypesNotAllowedInCategory(String nodeType)
{ {
String componentName = "Component" + getRandomAlphanumeric(); String componentName = "Component" + getRandomAlphanumeric();
@@ -481,13 +481,13 @@ public class RecordCategoryTests extends BaseRMRestTest
( (
description = "Get children of a record category" description = "Get children of a record category"
) )
public void getFolders() throws Exception public void getFolders()
{ {
// Authenticate with admin user // Authenticate with admin user
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()); RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
// Add child folders // Add child folders
ArrayList<RecordCategoryChild> children = new ArrayList<RecordCategoryChild>(); ArrayList<RecordCategoryChild> children = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_FOLDERS; i++) for (int i = 0; i < NUMBER_OF_FOLDERS; i++)
{ {
// Create a record folder // Create a record folder
@@ -516,7 +516,7 @@ public class RecordCategoryTests extends BaseRMRestTest
RecordCategoryChild createdComponent = children.stream() RecordCategoryChild createdComponent = children.stream()
.filter(child -> child.getId().equals(recordCategoryChildId)) .filter(child -> child.getId().equals(recordCategoryChildId))
.findFirst() .findFirst()
.get(); .orElseThrow();
// Created by // Created by
assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(recordCategoryChild.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -552,7 +552,7 @@ public class RecordCategoryTests extends BaseRMRestTest
description = "Create a folder using record-categories endpoint, based on the relativePath. " + description = "Create a folder using record-categories endpoint, based on the relativePath. " +
"Containers in the relativePath that do not exist are created before the node is created" "Containers in the relativePath that do not exist are created before the node is created"
) )
public void createRecordFolderWithRelativePath() throws Exception public void createRecordFolderWithRelativePath()
{ {
// The record category to be created // The record category to be created
RecordCategory recordCategoryModel = RecordCategory.builder() RecordCategory recordCategoryModel = RecordCategory.builder()
@@ -600,7 +600,7 @@ public class RecordCategoryTests extends BaseRMRestTest
assertStatusCode(OK); assertStatusCode(OK);
// Verify the returned details for the record folder // Verify the returned details for the record folder
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType())); assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
// Check the path return contains the relativePath // Check the path return contains the relativePath
assertTrue(recordFolder.getPath().getName().contains(relativePath)); assertTrue(recordFolder.getPath().getName().contains(relativePath));
@@ -638,7 +638,7 @@ public class RecordCategoryTests extends BaseRMRestTest
assertStatusCode(OK); assertStatusCode(OK);
// Verify the returned details for the record folder // Verify the returned details for the record folder
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType())); assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
// Check the path return contains the newRelativePath // Check the path return contains the newRelativePath
assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath)); assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
@@ -657,7 +657,7 @@ public class RecordCategoryTests extends BaseRMRestTest
description = "Create a sub-category using record-categories endpoint, based on the relativePath. " + description = "Create a sub-category using record-categories endpoint, based on the relativePath. " +
"Containers in the relativePath that do not exist are created before the node is created" "Containers in the relativePath that do not exist are created before the node is created"
) )
public void createRecordSubCategoryWithRelativePath() throws Exception public void createRecordSubCategoryWithRelativePath()
{ {
// The record category to be created // The record category to be created
RecordCategory recordCategoryModel = RecordCategory.builder() RecordCategory recordCategoryModel = RecordCategory.builder()
@@ -704,7 +704,7 @@ public class RecordCategoryTests extends BaseRMRestTest
assertStatusCode(OK); assertStatusCode(OK);
// Verify the returned details for the record folder // Verify the returned details for the record folder
assertTrue(RECORD_CATEGORY_TYPE.equals(recordSubCategory.getNodeType())); assertEquals(recordSubCategory.getNodeType(), RECORD_CATEGORY_TYPE);
// Check the path return contains the relativePath // Check the path return contains the relativePath
assertTrue(recordSubCategory.getPath().getName().contains(relativePath)); assertTrue(recordSubCategory.getPath().getName().contains(relativePath));
@@ -742,7 +742,7 @@ public class RecordCategoryTests extends BaseRMRestTest
assertStatusCode(OK); assertStatusCode(OK);
// Verify the returned details for the record folder // Verify the returned details for the record folder
assertTrue(RECORD_CATEGORY_TYPE.equals(recordSubCategory.getNodeType())); assertEquals(recordSubCategory.getNodeType(), RECORD_CATEGORY_TYPE);
// Check the path return contains the newRelativePath // Check the path return contains the newRelativePath
assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath)); assertTrue(newRecordFolder.getPath().getName().contains(newRelativePath));
@@ -762,7 +762,7 @@ public class RecordCategoryTests extends BaseRMRestTest
dataProvider = "getContainers" dataProvider = "getContainers"
) )
@Bug (id = "RM-4327") @Bug (id = "RM-4327")
public void createRecordFolderIntoSpecialContainers(String containerAlias) throws Exception public void createRecordFolderIntoSpecialContainers(String containerAlias)
{ {
String containerId; String containerId;
if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias)) if (FILE_PLAN_ALIAS.equalsIgnoreCase(containerAlias))

View File

@@ -44,6 +44,7 @@ import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
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.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
@@ -67,8 +68,6 @@ import org.testng.annotations.Test;
*/ */
public class ElectronicRecordTests extends BaseRMRestTest public class ElectronicRecordTests extends BaseRMRestTest
{ {
private static final String TEXT_PLAIN_VALUE = "text/plain";
/** Invalid parent containers where electronic records can't be created */ /** Invalid parent containers where electronic records can't be created */
@DataProvider(name = "invalidParentContainers") @DataProvider(name = "invalidParentContainers")
public Object[][] invalidParentContainers() public Object[][] invalidParentContainers()
@@ -92,7 +91,6 @@ public class ElectronicRecordTests extends BaseRMRestTest
* And an error is reported * And an error is reported
* </pre> * </pre>
* @param container The parent container * @param container The parent container
* @throws Exception if record can't be created
*/ */
@Test @Test
( (
@@ -116,13 +114,12 @@ public class ElectronicRecordTests extends BaseRMRestTest
* Then nothing happens * Then nothing happens
* And an error is reported * And an error is reported
* </pre> * </pre>
* @throws Exception if record can't be created
*/ */
@Test @Test
( (
description = "Electronic record can't be created in closed record folder" description = "Electronic record can't be created in closed record folder"
) )
public void cantCreateElectronicRecordInClosedFolder() throws Exception public void cantCreateElectronicRecordInClosedFolder()
{ {
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
@@ -334,7 +331,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
*/ */
@Test @Test
@Bug (id = "RM-4568") @Bug (id = "RM-4568")
public void createElectronicRecordWithRelativePath() throws Exception public void createElectronicRecordWithRelativePath()
{ {
// The containers specified on the relativePath parameter don't exist on server // The containers specified on the relativePath parameter don't exist on server
String parentUbnfiledRecordFolderName = "ParentUnfiledRecordFolder" + getRandomAlphanumeric(); String parentUbnfiledRecordFolderName = "ParentUnfiledRecordFolder" + getRandomAlphanumeric();
@@ -364,7 +361,7 @@ public class ElectronicRecordTests extends BaseRMRestTest
Record record = recordsAPI.getRecord(recordCreated.getId()); Record record = recordsAPI.getRecord(recordCreated.getId());
assertTrue(record.getName().startsWith(ELECTRONIC_RECORD_NAME)); assertTrue(record.getName().startsWith(ELECTRONIC_RECORD_NAME));
assertTrue(unfiledRecordFoldersAPI.getUnfiledRecordFolder(record.getParentId()).getName().equals(unfiledRecordFolderPathEl3)); assertEquals(unfiledRecordFoldersAPI.getUnfiledRecordFolder(record.getParentId()).getName(), unfiledRecordFolderPathEl3);
// The first relative path element exists and the second one does not exist // The first relative path element exists and the second one does not exist
String unfiledRecordFolderPathEl4 = "UnfiledRecordFolderPathEl4" + getRandomAlphanumeric(); String unfiledRecordFolderPathEl4 = "UnfiledRecordFolderPathEl4" + getRandomAlphanumeric();
@@ -399,9 +396,6 @@ public class ElectronicRecordTests extends BaseRMRestTest
* When I try to create a record with name1 and create another one with the same given name * When I try to create a record with name1 and create another one with the same given name
* Then the second record is created with success * Then the second record is created with success
* </pre> * </pre>
*
* @throws Exception
* if record can't be created
*/ */
@Test(description = "Electronic records can be created in record folder with duplicate name") @Test(description = "Electronic records can be created in record folder with duplicate name")
@Bug(id ="RM-5116, RM-5012") @Bug(id ="RM-5116, RM-5012")

View File

@@ -28,6 +28,7 @@ package org.alfresco.rest.rm.community.recordfolders;
import static java.lang.Integer.MAX_VALUE; import static java.lang.Integer.MAX_VALUE;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE;
@@ -57,7 +58,6 @@ import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
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;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -166,10 +166,9 @@ public class NonElectronicRecordTests extends BaseRMRestTest
* Then nothing happens * Then nothing happens
* And an error is reported * And an error is reported
* </pre> * </pre>
* @throws Exception if record can't be created
*/ */
@Test(description = "Non-electronic record can't be created in closed record folder") @Test(description = "Non-electronic record can't be created in closed record folder")
public void cantCreateInClosedFolder() throws Exception public void cantCreateInClosedFolder()
{ {
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
@@ -204,14 +203,13 @@ public class NonElectronicRecordTests extends BaseRMRestTest
* Then nothing happens * Then nothing happens
* And an error is reported * And an error is reported
* </pre> * </pre>
* @throws Exception if record can't be created
*/ */
@Test @Test
( (
dataProvider = "validRootContainers", dataProvider = "validRootContainers",
description = "Non-electronic record can only be created if all mandatory properties are given" description = "Non-electronic record can only be created if all mandatory properties are given"
) )
public void allMandatoryPropertiesRequired(String folderId, String type) throws Exception public void allMandatoryPropertiesRequired(String folderId, String type)
{ {
logger.info("Root container:\n" + toJson(folderId)); logger.info("Root container:\n" + toJson(folderId));
@@ -232,25 +230,11 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.build(); .build();
// Try to create invalid components // Try to create invalid components
asList(noNameOrTitle, titleOnly).stream().forEach(c -> asList(noNameOrTitle, titleOnly).forEach(c ->
{ {
try logger.info("Creating non-electronic record with body:\n" + toJson(c));
{
logger.info("Creating non-electronic record with body:\n" + toJson(c));
}
catch (Exception error)
{
}
// This should fail and throw an exception
try
{
getRestAPIFactory().getRecordFolderAPI().createRecord(c, folderId);
}
catch (Exception e)
{
}
getRestAPIFactory().getRecordFolderAPI().createRecord(c, folderId);
// Verify the status code is BAD_REQUEST // Verify the status code is BAD_REQUEST
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
}); });
@@ -269,25 +253,11 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.build(); .build();
// Try to create invalid components // Try to create invalid components
asList(noNameOrTitle, titleOnly).stream().forEach(c -> asList(noNameOrTitle, titleOnly).forEach(c ->
{ {
try logger.info("Creating non-electronic record with body:\n" + toJson(c));
{
logger.info("Creating non-electronic record with body:\n" + toJson(c));
}
catch (Exception error)
{
}
// This should fail and throw an exception
try
{
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(c, folderId);
}
catch (Exception e)
{
}
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(c, folderId);
// Verify the status code is BAD_REQUEST // Verify the status code is BAD_REQUEST
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
}); });
@@ -307,24 +277,11 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.build(); .build();
// Try to create invalid components // Try to create invalid components
asList(noNameOrTitle, titleOnly).stream().forEach(c -> asList(noNameOrTitle, titleOnly).forEach(c ->
{ {
try logger.info("Creating non-electronic record with body:\n" + toJson(c));
{
logger.info("Creating non-electronic record with body:\n" + toJson(c));
}
catch (Exception error)
{
}
// This should fail and throw an exception getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(c, folderId);
try
{
getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(c, folderId);
}
catch (Exception e)
{
}
// Verify the status code is BAD_REQUEST // Verify the status code is BAD_REQUEST
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
@@ -339,16 +296,15 @@ public class NonElectronicRecordTests extends BaseRMRestTest
* Then nothing happens * Then nothing happens
* And an error is reported * And an error is reported
* </pre> * </pre>
* @throws Exception if record can't be created
*/ */
@Test @Test
( (
dataProvider = "validRootContainers", dataProvider = "validRootContainers",
description = "Non-electronic record can't be created if user doesn't have RM privileges" description = "Non-electronic record can't be created if user doesn't have RM privileges"
) )
public void cantCreateIfNoRmPrivileges(String folderId, String type) throws Exception public void cantCreateIfNoRmPrivileges(String folderId, String type)
{ {
UserModel user = createUserWithRole("zzzuser", SiteManager); UserModel user = createSiteManager("zzzuser");
if (type.equals(RECORD_FOLDER_TYPE)) if (type.equals(RECORD_FOLDER_TYPE))
{ {
@@ -362,14 +318,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
// This should fail and throw an exception getRestAPIFactory().getRecordFolderAPI(user).createRecord(recordModel, folderId);
try
{
getRestAPIFactory().getRecordFolderAPI(user).createRecord(recordModel, folderId);
}
catch (Exception e)
{
}
} }
else if(UNFILED_CONTAINER_TYPE.equalsIgnoreCase(type)) else if(UNFILED_CONTAINER_TYPE.equalsIgnoreCase(type))
{ {
@@ -383,14 +332,7 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
// This should fail and throw an exception getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(recordModel, folderId);
try
{
getRestAPIFactory().getUnfiledContainersAPI(user).createUnfiledContainerChild(recordModel, folderId);
}
catch (Exception e)
{
}
} }
else else
{ {
@@ -404,21 +346,14 @@ public class NonElectronicRecordTests extends BaseRMRestTest
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
// This should fail and throw an exception getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(recordModel, folderId);
try
{
getRestAPIFactory().getUnfiledRecordFoldersAPI(user).createUnfiledRecordFolderChild(recordModel, folderId);
}
catch (Exception e)
{
}
} }
// User who isn't an RM site member can't access the container path // User who isn't an RM site member can't access the container path
assertStatusCode(FORBIDDEN); assertStatusCode(FORBIDDEN);
} }
/** /**
* Create user with given role and add it to RM site * Create user with site manager role and add it to RM site
* <br> * <br>
* Checks whether the user exists in RM site and creates it if required, with password identical * Checks whether the user exists in RM site and creates it if required, with password identical
* to user name. Note the role is a Core API role, not an RM role. * to user name. Note the role is a Core API role, not an RM role.
@@ -426,23 +361,19 @@ public class NonElectronicRecordTests extends BaseRMRestTest
* For already existing users, no site membership or role verification is performed. * For already existing users, no site membership or role verification is performed.
* <p> * <p>
* @param userName user name to add * @param userName user name to add
* @param userRole user's role
* @throws Exception
*/ */
private UserModel createUserWithRole(String userName, UserRole userRole) throws Exception private UserModel createSiteManager(String userName)
{ {
String siteId = getRestAPIFactory().getRMSiteAPI().getSite().getId(); String siteId = getRestAPIFactory().getRMSiteAPI().getSite().getId();
// Check if user exists // Check if user exists
UserModel user = new UserModel(); UserModel user = new UserModel(userName, userName);
user.setUsername(userName);
user.setPassword(userName);
if (!getDataUser().isUserInRepo(userName)) if (!getDataUser().isUserInRepo(userName))
{ {
// User doesn't exist, create it // User doesn't exist, create it
user = getDataUser().createUser(userName, userName); user = getDataUser().createUser(userName, userName);
getDataUser().addUserToSite(user, new SiteModel(siteId), userRole); getDataUser().addUserToSite(user, new SiteModel(siteId), SiteManager);
} }
return user; return user;

View File

@@ -26,7 +26,6 @@
*/ */
package org.alfresco.rest.rm.community.recordfolders; package org.alfresco.rest.rm.community.recordfolders;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME; import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
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.TRANSFERS_ALIAS;
@@ -45,6 +44,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.TITLE_PREFIX;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NOT_FOUND;
import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.NO_CONTENT;
@@ -56,7 +56,6 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail; import static org.testng.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -69,13 +68,11 @@ import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder; import org.alfresco.rest.rm.community.model.recordfolder.RecordFolder;
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection; import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderCollection;
import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties; import org.alfresco.rest.rm.community.model.recordfolder.RecordFolderProperties;
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.utility.report.Bug; import org.alfresco.utility.report.Bug;
import org.testng.AssertJUnit; import org.testng.AssertJUnit;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -89,7 +86,14 @@ public class RecordFolderTests extends BaseRMRestTest
{ {
public static final String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric(); public static final String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric();
public static final String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric(); public static final String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
public static final String RECORD_CATEGORY_NAME = "CATEGORY NAME" + getRandomAlphanumeric();
private RecordCategory rootCategory;
@BeforeClass (alwaysRun = true)
public void preconditionRecordFolderTests()
{
rootCategory = createRootCategory(RECORD_CATEGORY_NAME);
}
/** /**
* Data Provider with: * Data Provider with:
@@ -115,14 +119,14 @@ public class RecordFolderTests extends BaseRMRestTest
* Invalid containers that cannot be updated/deleted with record folder endpoint * Invalid containers that cannot be updated/deleted with record folder endpoint
*/ */
@DataProvider @DataProvider
public Object[][] getInvalidNodesForRecordFolders() throws Exception public Object[][] getInvalidNodesForRecordFolders()
{ {
return new String[][] { return new String[][] {
{ getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId()}, { getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId()},
{ getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() }, { getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
{ getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() }, { getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
// an arbitrary record category // an arbitrary record category
{ createRootCategory(RECORD_CATEGORY_NAME+getRandomAlphanumeric()).getId()}, { rootCategory.getId()},
// an arbitrary unfiled records folder // an arbitrary unfiled records folder
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId() }, { createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId() },
{ createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Record " + getRandomAlphanumeric(), CONTENT_TYPE).getId()} { createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Record " + getRandomAlphanumeric(), CONTENT_TYPE).getId()}
@@ -133,7 +137,7 @@ public class RecordFolderTests extends BaseRMRestTest
/** /**
* <pre> * <pre>
* Given that RM site is created * Given that RM site is created
* When I use the API to create a children of wrong type inside a record folder * When I use the API to create a children of wrong type inside a record folder
* Then the operation fails * Then the operation fails
* </pre> * </pre>
*/ */
@@ -144,16 +148,15 @@ public class RecordFolderTests extends BaseRMRestTest
description = "Create invalid types as children for a record folder", description = "Create invalid types as children for a record folder",
dataProvider = "childrenNotAllowedForFolder" dataProvider = "childrenNotAllowedForFolder"
) )
public void createInvalidChildrenForFolder(String nodeType)
public void createInvalidChildrenForFolder(String nodeType) throws Exception
{ {
//create a record folder //create a record folder
RecordCategoryChild folder = createCategoryFolderInFilePlan(); RecordCategoryChild folder = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
Record record = Record.builder() Record record = Record.builder()
.name(ELECTRONIC_RECORD_NAME) .name(ELECTRONIC_RECORD_NAME)
.nodeType(nodeType) .nodeType(nodeType)
.build(); .build();
//create invalid child typefor the record folder //create invalid child type for the record folder
getRestAPIFactory().getRecordFolderAPI().createRecord(record,folder.getId()); getRestAPIFactory().getRecordFolderAPI().createRecord(record,folder.getId());
// Check the API Response code // Check the API Response code
assertStatusCode(UNPROCESSABLE_ENTITY); assertStatusCode(UNPROCESSABLE_ENTITY);
@@ -170,20 +173,16 @@ public class RecordFolderTests extends BaseRMRestTest
( (
description = "Check the details of a record folder" description = "Check the details of a record folder"
) )
public void checkRecordFolderDetails() throws Exception public void checkRecordFolderDetails()
{ {
// Create a category
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
// Create a folder // Create a folder
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME); RecordCategoryChild recordCategoryChild = createRecordFolder(rootCategory.getId(), RECORD_FOLDER_NAME);
// Get the folder including extra information // Get the folder including extra information
RecordFolder recordFolder = getRestAPIFactory().getRecordFolderAPI().getRecordFolder(recordCategoryChild.getId(), "include=" + IS_CLOSED); RecordFolder recordFolder = getRestAPIFactory().getRecordFolderAPI().getRecordFolder(recordCategoryChild.getId(), "include=" + IS_CLOSED);
// Verify the returned record folder details // Verify the returned record folder details
assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE); assertEquals(recordFolder.getNodeType(), RECORD_FOLDER_TYPE);
assertTrue(RECORD_FOLDER_TYPE.equals(recordFolder.getNodeType()));
assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME); assertEquals(recordFolder.getName(), RECORD_FOLDER_NAME);
assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(recordFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
assertEquals(recordFolder.getModifiedByUser().getId(), getAdminUser().getUsername()); assertEquals(recordFolder.getModifiedByUser().getId(), getAdminUser().getUsername());
@@ -206,13 +205,10 @@ public class RecordFolderTests extends BaseRMRestTest
( (
description = "Update the details of a record folder" description = "Update the details of a record folder"
) )
public void updateRecordFolderDetails() throws Exception public void updateRecordFolderDetails()
{ {
// Create a record category
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
// Create a record folder // Create a record folder
RecordCategoryChild recordCategoryChild = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME); RecordCategoryChild recordCategoryChild = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
// Create record category first // Create record category first
String folderDescription = "The folder description is updated" + getRandomAlphanumeric(); String folderDescription = "The folder description is updated" + getRandomAlphanumeric();
@@ -261,7 +257,7 @@ public class RecordFolderTests extends BaseRMRestTest
description = "Update the details for other nodes than record folder with the request used for record-folders ", description = "Update the details for other nodes than record folder with the request used for record-folders ",
dataProvider = "getInvalidNodesForRecordFolders" dataProvider = "getInvalidNodesForRecordFolders"
) )
public void updateOtherNodeTypesDetails(String nodeId) throws Exception public void updateOtherNodeTypesDetails(String nodeId)
{ {
// Create record category first // Create record category first
String nodeDescription = "The folder description is updated" + getRandomAlphanumeric(); String nodeDescription = "The folder description is updated" + getRandomAlphanumeric();
@@ -299,7 +295,7 @@ public class RecordFolderTests extends BaseRMRestTest
description = "Delete invalid nodes type with the DELETE record folders request", description = "Delete invalid nodes type with the DELETE record folders request",
dataProvider = "getInvalidNodesForRecordFolders" dataProvider = "getInvalidNodesForRecordFolders"
) )
public void deleteInvalidNodesRecordFolder(String nodeId) throws Exception public void deleteInvalidNodesRecordFolder(String nodeId)
{ {
// Delete the nodes with record-folders end-point // Delete the nodes with record-folders end-point
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
@@ -320,13 +316,10 @@ public class RecordFolderTests extends BaseRMRestTest
( (
description = "Delete record folder" description = "Delete record folder"
) )
public void deleteRecordFolder() throws Exception public void deleteRecordFolder()
{ {
// Create the record category
RecordCategory rootRecordCategory = createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric());
// Create the record folder // Create the record folder
RecordCategoryChild recordFolder = createRecordFolder(rootRecordCategory.getId(), RECORD_FOLDER_NAME); RecordCategoryChild recordFolder = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
// Delete the record folder // Delete the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
@@ -353,10 +346,10 @@ public class RecordFolderTests extends BaseRMRestTest
description = "A closed record folder can be reopened" description = "A closed record folder can be reopened"
) )
@Bug(id="RM-4808") @Bug(id="RM-4808")
public void openClosedRecordFolder() throws Exception public void openClosedRecordFolder()
{ {
// Create a record folder // Create a record folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolder = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
// Assert that the record folder is not closed // Assert that the record folder is not closed
assertFalse(recordFolder.getProperties().getIsClosed()); assertFalse(recordFolder.getProperties().getIsClosed());
@@ -366,10 +359,10 @@ public class RecordFolderTests extends BaseRMRestTest
// Create a record folder model to close it // Create a record folder model to close it
RecordFolder recordFolderModel = RecordFolder.builder() RecordFolder recordFolderModel = RecordFolder.builder()
.properties(RecordFolderProperties.builder() .properties(RecordFolderProperties.builder()
.isClosed(true) .isClosed(true)
.build()) .build())
.build(); .build();
// Make a request to close the record folder // Make a request to close the record folder
RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId()); RecordFolder updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
@@ -379,10 +372,10 @@ public class RecordFolderTests extends BaseRMRestTest
// Create a record folder model to reopen it // Create a record folder model to reopen it
recordFolderModel = RecordFolder.builder() recordFolderModel = RecordFolder.builder()
.properties(RecordFolderProperties.builder() .properties(RecordFolderProperties.builder()
.isClosed(false) .isClosed(false)
.build()) .build())
.build(); .build();
// Make a request to reopen the record folder // Make a request to reopen the record folder
updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId()); updatedRecordFolder = recordFolderAPI.updateRecordFolder(recordFolderModel, recordFolder.getId());
@@ -397,13 +390,13 @@ public class RecordFolderTests extends BaseRMRestTest
* Then I receive a list of all the records contained within the record folder * Then I receive a list of all the records contained within the record folder
*/ */
@Test @Test
public void listRecordsFromRecordFolder() throws Exception public void listRecordsFromRecordFolder()
{ {
final int NUMBER_OF_RECORDS = 5; final int NUMBER_OF_RECORDS = 5;
String containerId = createCategoryFolderInFilePlan().getId(); String containerId = createRecordFolder(rootCategory.getId(), getRandomName("recFolder")).getId();
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
// Create Electronic Records // Create Electronic Records
ArrayList<Record> children = new ArrayList<Record>(); ArrayList<Record> children = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_RECORDS; i++) for (int i = 0; i < NUMBER_OF_RECORDS; i++)
{ {
//build the electronic record //build the electronic record
@@ -453,7 +446,7 @@ public class RecordFolderTests extends BaseRMRestTest
Record createdComponent = children.stream() Record createdComponent = children.stream()
.filter(child -> child.getId().equals(record.getId())) .filter(child -> child.getId().equals(record.getId()))
.findFirst() .findFirst()
.get(); .orElseThrow();
// Created by // Created by
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -462,8 +455,8 @@ public class RecordFolderTests extends BaseRMRestTest
assertEquals(record.getParentId(), containerId); assertEquals(record.getParentId(), containerId);
//check the record name //check the record name
assertTrue(record.getName().equals(createdComponent.getName()), assertEquals(createdComponent.getName(), record.getName(),
"Record Name"+ record.getName()+" doesn't match the one returned on create"); "Record Name" + record.getName() + " doesn't match the one returned on create");
assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()), assertTrue(createdComponent.getName().contains(createdComponent.getProperties().getIdentifier()),
"Record Name"+ createdComponent.getName()+" doesn't contain the record identifier in response when creating"); "Record Name"+ createdComponent.getName()+" doesn't contain the record identifier in response when creating");
assertEquals(createdComponent.getNodeType(), record.getNodeType()); assertEquals(createdComponent.getNodeType(), record.getNodeType());
@@ -475,16 +468,9 @@ public class RecordFolderTests extends BaseRMRestTest
}); });
} }
@AfterTest
@AfterClass (alwaysRun = true) @AfterClass (alwaysRun = true)
public void tearDown() throws Exception public void tearDown()
{ {
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI(); deleteRecordCategory(rootCategory.getId());
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
filePlansAPI.getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry ->
{
recordCategoryAPI.deleteRecordCategory(recordCategoryEntry.getEntry().getId());
});
} }
} }

View File

@@ -31,15 +31,11 @@ import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.create
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel; import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel;
import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
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.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record; import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
@@ -65,7 +61,7 @@ public class CompleteRecordTests extends BaseRMRestTest
* Incomplete records with mandatory meta-data missing * Incomplete records with mandatory meta-data missing
*/ */
@DataProvider (name = "IncompleteRecordsMandatoryMetadataMissing") @DataProvider (name = "IncompleteRecordsMandatoryMetadataMissing")
public Object[][] getIncompleteRecordsMandatoryMetadataMissing() throws Exception public Object[][] getIncompleteRecordsMandatoryMetadataMissing()
{ {
//create RM site //create RM site
createRMSite(createDOD5015RMSiteModel()); createRMSite(createDOD5015RMSiteModel());
@@ -78,26 +74,12 @@ public class CompleteRecordTests extends BaseRMRestTest
* Incomplete records with mandatory meta-data present * Incomplete records with mandatory meta-data present
*/ */
@DataProvider (name = "IncompleteRecordsMandatoryMetadataPresent") @DataProvider (name = "IncompleteRecordsMandatoryMetadataPresent")
public Object[][] getIncompleteRecordsMandatoryMetadataPresent() throws Exception public Object[][] getIncompleteRecordsMandatoryMetadataPresent()
{ {
// create electronic and non-electronic records // create electronic and non-electronic records
return createAndVerifyRecordsInFolder(); return createAndVerifyRecordsInFolder();
} }
/**
* Document to be completed is not a record
*/
@DataProvider (name = "Supplied node is not a record")
public Object[][] getNodesWhichAreNotRecords() throws Exception
{
createRMSite(createStandardRMSiteModel());
return new String[][]
{
{ createCategoryFolderInFilePlan().getId() },
};
}
/** /**
* <pre> * <pre>
* Given the repository is configured to check mandatory data before completing a record * Given the repository is configured to check mandatory data before completing a record
@@ -114,21 +96,15 @@ public class CompleteRecordTests extends BaseRMRestTest
priority = 1 priority = 1
) )
@AlfrescoTest (jira = "RM-4431") @AlfrescoTest (jira = "RM-4431")
public void completeRecordWithMandatoryMetadataMissing(String electronicRecordId, String nonElectronicRecordId) public void completeRecordWithMandatoryMetadataMissing(Record record)
throws Exception
{ {
List<Record> records = getRecordsList(electronicRecordId, nonElectronicRecordId); verifyRecordCompletionStatus(record, INCOMPLETE);
for (Record record : records) // Complete record
{ completeRecord(record);
verifyRecordCompletionStatus(record, INCOMPLETE); assertStatusCode(UNPROCESSABLE_ENTITY);
// Complete record verifyRecordCompletionStatus(record, INCOMPLETE);
completeRecord(record);
assertStatusCode(UNPROCESSABLE_ENTITY);
verifyRecordCompletionStatus(record, INCOMPLETE);
}
} }
/** /**
@@ -145,21 +121,15 @@ public class CompleteRecordTests extends BaseRMRestTest
description = "Can complete electronic and non-electronic records with mandatory metadata present" description = "Can complete electronic and non-electronic records with mandatory metadata present"
) )
@AlfrescoTest (jira = "RM-4431") @AlfrescoTest (jira = "RM-4431")
public void completeRecordWithMandatoryMetadataPresent(String electronicRecordId, String nonElectronicRecordId) public void completeRecordWithMandatoryMetadataPresent(Record record)
throws Exception
{ {
List<Record> records = getRecordsList(electronicRecordId, nonElectronicRecordId); verifyRecordCompletionStatus(record, INCOMPLETE);
for (Record record : records) // Complete record
{ completeRecord(record);
verifyRecordCompletionStatus(record, INCOMPLETE); assertStatusCode(CREATED);
// Complete record verifyRecordCompletionStatus(record, COMPLETE);
completeRecord(record);
assertStatusCode(CREATED);
verifyRecordCompletionStatus(record, COMPLETE);
}
} }
/** /**
@@ -169,18 +139,13 @@ public class CompleteRecordTests extends BaseRMRestTest
* Then I receive an unsupported operation error * Then I receive an unsupported operation error
* </pre> * </pre>
*/ */
@Test @Test (description = "Cannot complete a document that is not a record")
(
dataProvider = "Supplied node is not a record",
description = "Cannot complete a document that is not a record",
priority = 2
)
@AlfrescoTest (jira = "RM-4431") @AlfrescoTest (jira = "RM-4431")
public void completeNonRecord(String nonRecordId) throws Exception public void completeNonRecord()
{ {
// Get the recordsAPI // Get the recordsAPI
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); getRestAPIFactory().getRecordsAPI()
recordsAPI.completeRecord(nonRecordId, PARAMETERS); .completeRecord(createCategoryFolderInFilePlan().getId(), PARAMETERS);
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
} }
@@ -194,35 +159,28 @@ public class CompleteRecordTests extends BaseRMRestTest
@Test @Test
( (
dataProvider = "IncompleteRecordsMandatoryMetadataPresent", dataProvider = "IncompleteRecordsMandatoryMetadataPresent",
description = "Cannot complete a record that is already completed", description = "Cannot complete a record that is already completed"
priority = 3
) )
@AlfrescoTest (jira = "RM-4431") @AlfrescoTest (jira = "RM-4431")
public void completeAlreadyCompletedRecord(String electronicRecordId, String nonElectronicRecordId) public void completeAlreadyCompletedRecord(Record record)
throws Exception
{ {
List<Record> records = getRecordsList(electronicRecordId, nonElectronicRecordId); verifyRecordCompletionStatus(record, INCOMPLETE);
for (Record record : records) // Complete record
{ completeRecord(record);
verifyRecordCompletionStatus(record, INCOMPLETE); assertStatusCode(CREATED);
// Complete record verifyRecordCompletionStatus(record, COMPLETE);
completeRecord(record);
assertStatusCode(CREATED);
verifyRecordCompletionStatus(record, COMPLETE); // Complete record
completeRecord(record);
// Complete record assertStatusCode(UNPROCESSABLE_ENTITY);
completeRecord(record);
assertStatusCode(UNPROCESSABLE_ENTITY);
}
} }
/** /**
* Helper method to create records and and assert successful creation * Helper method to create records and and assert successful creation
*/ */
private String[][] createAndVerifyRecordsInFolder() throws Exception private Record[][] createAndVerifyRecordsInFolder()
{ {
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
@@ -230,32 +188,18 @@ public class CompleteRecordTests extends BaseRMRestTest
String recordFolderId = createCategoryFolderInFilePlan().getId(); String recordFolderId = createCategoryFolderInFilePlan().getId();
// create electronic record in record folder // create electronic record in record folder
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE));
getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
// create non-electronic record in record folder // create non-electronic record in record folder
Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(), recordFolderId); Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(), recordFolderId);
assertStatusCode(CREATED); assertStatusCode(CREATED);
return new String[][] return new Record[][]
{ {
{ electronicRecord.getId(), nonElectronicRecord.getId() }, { electronicRecord },
}; { nonElectronicRecord }
} };
/**
* Helper method to provide list of records from record Ids
*/
private List<Record> getRecordsList(String electronicRecordId, String nonElectronicRecordId)
{
// Get the recordsAPI
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
Record electronicRecord = recordsAPI.getRecord(electronicRecordId);
Record nonElectronicRecord = recordsAPI.getRecord(nonElectronicRecordId);
return Arrays.asList(electronicRecord,nonElectronicRecord);
} }
/** /**
@@ -271,7 +215,7 @@ public class CompleteRecordTests extends BaseRMRestTest
/** /**
* Helper method to complete a record * Helper method to complete a record
*/ */
private void completeRecord(Record record) throws Exception private void completeRecord(Record record)
{ {
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
recordsAPI.completeRecord(record.getId(), PARAMETERS); recordsAPI.completeRecord(record.getId(), PARAMETERS);

View File

@@ -28,10 +28,9 @@ package org.alfresco.rest.rm.community.records;
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.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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_CONTAINER_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;
import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_MANAGER;
import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_POWER_USER; import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_POWER_USER;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel;
@@ -39,7 +38,6 @@ import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.create
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicUnfiledContainerChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicUnfiledContainerChildModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
import static org.alfresco.utility.constants.UserRole.SiteCollaborator;
import static org.alfresco.utility.data.RandomData.getRandomName; import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.alfresco.utility.report.log.Step.STEP; import static org.alfresco.utility.report.log.Step.STEP;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
@@ -71,9 +69,11 @@ import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.FileModel; import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.RepoTestModel; import org.alfresco.utility.model.RepoTestModel;
import org.alfresco.utility.model.SiteModel;
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;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@@ -92,6 +92,35 @@ public class DeleteRecordTests extends BaseRMRestTest
private org.alfresco.rest.v0.RecordsAPI recordsAPI; private org.alfresco.rest.v0.RecordsAPI recordsAPI;
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
private RecordCategoryChild recordFolder;
private UnfiledContainerChild unfiledRecordFolder;
@BeforeClass (alwaysRun = true)
public void setupDeleteRecordTests()
{
testSite = dataSite.usingAdmin().createPublicRandomSite();
recordFolder = createCategoryFolderInFilePlan();
unfiledRecordFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, getRandomName("Unfiled Folder "),
UNFILED_RECORD_FOLDER_TYPE);
}
/** Data provider with electronic and non-electronic records to be deleted */
@DataProvider (name = "recordsToBeDeleted")
public Object[][] getRecordsToBeDeleted()
{
return new String[][]
{
// records created in an arbitrary record folder
{getRestAPIFactory().getRecordFolderAPI().createRecord(createElectronicRecordModel(), recordFolder.getId(), getFile(IMAGE_FILE)).getId()},
{getRestAPIFactory().getRecordFolderAPI().createRecord(createNonElectronicRecordModel(), recordFolder.getId()).getId()},
// records created in unfiled records root
{getRestAPIFactory().getUnfiledContainersAPI().uploadRecord(createElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS, getFile(IMAGE_FILE)).getId()},
{getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS).getId()},
// records created in an arbitrary unfiled records folder
{getRestAPIFactory().getUnfiledRecordFoldersAPI().uploadRecord(createElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId(), getFile(IMAGE_FILE)).getId()},
{getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId()).getId()}
};
}
/** /**
* <pre> * <pre>
@@ -104,83 +133,16 @@ public class DeleteRecordTests extends BaseRMRestTest
*/ */
@Test @Test
( (
dataProvider = "validRootContainers", dataProvider = "recordsToBeDeleted",
description = "Admin user can delete an electronic record" description = "Admin user can delete records"
) )
@AlfrescoTest(jira="RM-4363") @AlfrescoTest(jira="RM-4363")
public void adminCanDeleteElectronicRecord(String folderId, String type) throws Exception public void adminCanDeleteRecords(String recordId)
{ {
// Create record
String recordId;
if(RECORD_FOLDER_TYPE.equalsIgnoreCase(type))
{
recordId = getRestAPIFactory().getRecordFolderAPI().createRecord(createElectronicRecordModel(), folderId, getFile(IMAGE_FILE)).getId();
}
else if(UNFILED_CONTAINER_TYPE.equalsIgnoreCase(type))
{
recordId = getRestAPIFactory().getUnfiledContainersAPI().uploadRecord(createElectronicUnfiledContainerChildModel(), folderId, getFile(IMAGE_FILE)).getId();
}
else if(UNFILED_RECORD_FOLDER_TYPE.equalsIgnoreCase(type))
{
recordId = getRestAPIFactory().getUnfiledRecordFoldersAPI().uploadRecord(createElectronicUnfiledContainerChildModel(), folderId, getFile(IMAGE_FILE)).getId();
}
else
{
throw new Exception("Unsuported type = " + type);
}
// Assert status
assertStatusCode(CREATED);
// Delete record and verify successful deletion // Delete record and verify successful deletion
deleteAndVerify(recordId); deleteAndVerify(recordId);
} }
/**
* <pre>
* Given a non-electronic record
* And that I have the "Delete Record" capability
* And write permissions
* When I delete the record
* Then it is deleted from the file plan
* </pre>
*/
@Test
(
dataProvider = "validRootContainers",
description = "Admin user can delete a non-electronic record"
)
@AlfrescoTest(jira="RM-4363")
public void adminCanDeleteNonElectronicRecord(String folderId, String type) throws Exception
{
// Create record
String nonElectronicRecordId;
if(RECORD_FOLDER_TYPE.equalsIgnoreCase(type))
{
nonElectronicRecordId = getRestAPIFactory().getRecordFolderAPI().createRecord(createNonElectronicRecordModel(), folderId).getId();
}
else if(UNFILED_CONTAINER_TYPE.equalsIgnoreCase(type))
{
nonElectronicRecordId = getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), folderId).getId();
}
else if(UNFILED_RECORD_FOLDER_TYPE.equalsIgnoreCase(type))
{
nonElectronicRecordId = getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), folderId).getId();
}
else
{
throw new Exception("Unsuported type = " + type);
}
// Assert status
assertStatusCode(CREATED);
// Delete record and verify successful deletion
deleteAndVerify(nonElectronicRecordId);
}
/** /**
* <pre> * <pre>
* Given a non-electronic record * Given a non-electronic record
@@ -195,7 +157,7 @@ public class DeleteRecordTests extends BaseRMRestTest
description = "User without write permissions can't delete a record" description = "User without write permissions can't delete a record"
) )
@AlfrescoTest(jira="RM-4363") @AlfrescoTest(jira="RM-4363")
public void userWithoutWritePermissionsCantDeleteRecord() throws Exception public void userWithoutWritePermissionsCantDeleteRecord()
{ {
// Create a non-electronic record in unfiled records // Create a non-electronic record in unfiled records
UnfiledContainerChild nonElectronicRecord = UnfiledContainerChild.builder() UnfiledContainerChild nonElectronicRecord = UnfiledContainerChild.builder()
@@ -206,15 +168,8 @@ public class DeleteRecordTests extends BaseRMRestTest
assertStatusCode(CREATED); assertStatusCode(CREATED);
// Create test user and add it with collaboration privileges // Create test user with RM Manager role
UserModel deleteUser = getDataUser().createRandomTestUser("delnoperm"); UserModel deleteUser = roleService.createUserWithRMRole(ROLE_RM_MANAGER.roleId);
String username = deleteUser.getUsername();
logger.info("Test user: " + username);
getDataUser().addUserToSite(deleteUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), SiteCollaborator);
// Add RM role to user
getRestAPIFactory().getRMUserAPI().assignRoleToUser(username, ROLE_RM_POWER_USER.roleId);
assertStatusCode(OK);
// Try to delete newRecord // Try to delete newRecord
getRestAPIFactory().getRecordsAPI(deleteUser).deleteRecord(newRecord.getId()); getRestAPIFactory().getRecordsAPI(deleteUser).deleteRecord(newRecord.getId());
@@ -235,18 +190,11 @@ public class DeleteRecordTests extends BaseRMRestTest
description = "User without delete records capability can't delete a record" description = "User without delete records capability can't delete a record"
) )
@AlfrescoTest(jira="RM-4363") @AlfrescoTest(jira="RM-4363")
public void userWithoutDeleteRecordsCapabilityCantDeleteRecord() throws Exception public void userWithoutDeleteRecordsCapabilityCantDeleteRecord()
{ {
// Create test user and add it with collaboration privileges // Create test user and add it with collaboration privileges
// Add RM role to user, RM Power User doesn't have the "Delete Record" capabilities // Add RM role to user, RM Power User doesn't have the "Delete Record" capabilities
UserModel deleteUser = roleService.createUserWithRMRole(ROLE_RM_POWER_USER.roleId); UserModel deleteUser = roleService.createUserWithRMRole(ROLE_RM_POWER_USER.roleId);
getDataUser().addUserToSite(deleteUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), SiteCollaborator);
String username = deleteUser.getUsername();
logger.info("Test user: " + username);
// Create random folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan();
logger.info("Random folder:" + recordFolder.getName());
// Grant "deleteUser" filing permissions on "randomFolder" parent, this will be inherited to randomFolder // Grant "deleteUser" filing permissions on "randomFolder" parent, this will be inherited to randomFolder
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI(); RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
@@ -280,13 +228,12 @@ public class DeleteRecordTests extends BaseRMRestTest
@AlfrescoTest(jira="MNT-18806") @AlfrescoTest(jira="MNT-18806")
public void deleteCopyOfRecord() public void deleteCopyOfRecord()
{ {
STEP("Create two record categories and folders."); STEP("Create another record category with a folder.");
RecordCategoryChild recordFolderA = createCategoryFolderInFilePlan();
RecordCategoryChild recordFolderB = createCategoryFolderInFilePlan(); RecordCategoryChild recordFolderB = createCategoryFolderInFilePlan();
STEP("Create a record in folder A and copy it into folder B."); STEP("Create a record in first folder and copy it into second folder.");
String recordId = getRestAPIFactory().getRecordFolderAPI() String recordId = getRestAPIFactory().getRecordFolderAPI()
.createRecord(createElectronicRecordModel(), recordFolderA.getId(), getFile(IMAGE_FILE)).getId(); .createRecord(createElectronicRecordModel(), recordFolder.getId(), getFile(IMAGE_FILE)).getId();
String copyId = copyNode(recordId, recordFolderB.getId()).getId(); String copyId = copyNode(recordId, recordFolderB.getId()).getId();
assertStatusCode(CREATED); assertStatusCode(CREATED);
@@ -313,10 +260,9 @@ public class DeleteRecordTests extends BaseRMRestTest
*/ */
@Test (description = "Deleting record doesn't delete the content for the copies") @Test (description = "Deleting record doesn't delete the content for the copies")
@AlfrescoTest (jira = "MNT-20145") @AlfrescoTest (jira = "MNT-20145")
public void deleteOriginOfRecord() throws Exception public void deleteOriginOfRecord()
{ {
STEP("Create a file."); STEP("Create a file.");
testSite = dataSite.usingAdmin().createPublicRandomSite();
FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Create a copy of the file."); STEP("Create a copy of the file.");
@@ -332,9 +278,6 @@ public class DeleteRecordTests extends BaseRMRestTest
STEP("Check that it's possible to load the copy content."); STEP("Check that it's possible to load the copy content.");
getNodeContent(copyOfTestFile.getId()); getNodeContent(copyOfTestFile.getId());
assertStatusCode(OK); assertStatusCode(OK);
STEP("Clean up.");
dataSite.deleteSite(testSite);
} }
/** /**
@@ -348,10 +291,9 @@ public class DeleteRecordTests extends BaseRMRestTest
*/ */
@Test (description = "Destroying record doesn't delete the content for the associated copy") @Test (description = "Destroying record doesn't delete the content for the associated copy")
@AlfrescoTest (jira = "MNT-20145") @AlfrescoTest (jira = "MNT-20145")
public void destroyOfRecord() throws Exception public void destroyOfRecord()
{ {
STEP("Create a file."); STEP("Create a file.");
testSite = dataSite.usingAdmin().createPublicRandomSite();
FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
FolderModel folderModel = dataContent.usingAdmin().usingSite(testSite).createFolder(); FolderModel folderModel = dataContent.usingAdmin().usingSite(testSite).createFolder();
@@ -387,10 +329,6 @@ public class DeleteRecordTests extends BaseRMRestTest
STEP("Check that it's possible to load the copy content."); STEP("Check that it's possible to load the copy content.");
getNodeContent(copy.getId()); getNodeContent(copy.getId());
assertStatusCode(OK); assertStatusCode(OK);
STEP("Clean up.");
dataSite.deleteSite(testSite);
} }
/** /**
@@ -402,10 +340,9 @@ public class DeleteRecordTests extends BaseRMRestTest
*/ */
@Test (description = "Deleting record made from version doesn't delete the content for the file") @Test (description = "Deleting record made from version doesn't delete the content for the file")
@AlfrescoTest (jira = "MNT-20145") @AlfrescoTest (jira = "MNT-20145")
public void deleteVersionDeclaredAsRecord() throws Exception public void deleteVersionDeclaredAsRecord()
{ {
STEP("Create a file."); STEP("Create a file.");
testSite = dataSite.usingAdmin().createPublicRandomSite();
FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN); FileModel testFile = dataContent.usingAdmin().usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
STEP("Declare file version as record."); STEP("Declare file version as record.");
@@ -425,10 +362,6 @@ public class DeleteRecordTests extends BaseRMRestTest
STEP("Check that it's possible to load the file declared version as record."); STEP("Check that it's possible to load the file declared version as record.");
getNodeContent(testFile.getNodeRefWithoutVersion()); getNodeContent(testFile.getNodeRefWithoutVersion());
assertStatusCode(OK); assertStatusCode(OK);
STEP("Clean up.");
dataSite.deleteSite(testSite);
} }
@@ -519,4 +452,12 @@ public class DeleteRecordTests extends BaseRMRestTest
repoTestModel.setNodeRef(recordId); repoTestModel.setNodeRef(recordId);
return getRestAPIFactory().getNodeAPI(repoTestModel); return getRestAPIFactory().getNodeAPI(repoTestModel);
} }
@AfterClass(alwaysRun = true)
public void cleanupDeleteRecordTests()
{
dataSite.deleteSite(testSite);
deleteRecordCategory(recordFolder.getParentId());
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledRecordFolder.getId());
}
} }

View File

@@ -86,7 +86,7 @@ public class FileRecordsTests extends BaseRMRestTest
private String targetFolderId, folderToLink, closedFolderId, unfiledRecordFolderId; private String targetFolderId, folderToLink, closedFolderId, unfiledRecordFolderId;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void setupFileRecordsTests() throws Exception public void setupFileRecordsTests()
{ {
// create 3 record folders and close one of them // create 3 record folders and close one of them
targetFolderId = createCategoryFolderInFilePlan().getId(); targetFolderId = createCategoryFolderInFilePlan().getId();
@@ -103,7 +103,7 @@ public class FileRecordsTests extends BaseRMRestTest
* Invalid containers where electronic and non-electronic records can be filed * Invalid containers where electronic and non-electronic records can be filed
*/ */
@DataProvider (name = "invalidContainersToFile") @DataProvider (name = "invalidContainersToFile")
public Object[][] getFolderContainers() throws Exception public Object[][] getFolderContainers()
{ {
return new String[][] { return new String[][] {
{ FILE_PLAN_ALIAS}, { FILE_PLAN_ALIAS},
@@ -123,13 +123,10 @@ public class FileRecordsTests extends BaseRMRestTest
public Object[][] getRecordsFromUnfiledRecordsContainer() public Object[][] getRecordsFromUnfiledRecordsContainer()
{ {
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild recordElectronic = unfiledContainersAPI.uploadRecord(electronicRecord,
UNFILED_RECORDS_CONTAINER_ALIAS, createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS);
return new String[][] { return new String[][] {
{ recordElectronic.getId()}, { unfiledContainersAPI.uploadRecord(electronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS,
{ recordNonElect.getId()} createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)).getId()},
{ unfiledContainersAPI.createUnfiledContainerChild(nonelectronicRecord, UNFILED_RECORDS_CONTAINER_ALIAS).getId()}
}; };
} }
@@ -140,13 +137,11 @@ public class FileRecordsTests extends BaseRMRestTest
public Object[][] getRecordsFromUnfiledRecordFolder() public Object[][] getRecordsFromUnfiledRecordFolder()
{ {
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
UnfiledContainerChild recordElectronic = unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId,
createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME));
UnfiledContainerChild recordNonElect = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId);
return new String[][] { return new String[][] {
{ recordElectronic.getId()}, { unfiledRecordFoldersAPI.uploadRecord(electronicRecord, unfiledRecordFolderId,
{ recordNonElect.getId()} createTempFile(ELECTRONIC_RECORD_NAME, ELECTRONIC_RECORD_NAME)).getId()},
{ unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, unfiledRecordFolderId).getId()}
}; };
} }
@@ -264,7 +259,7 @@ public class FileRecordsTests extends BaseRMRestTest
// link the record to the second folder // link the record to the second folder
Record recordLink = fileRecordToFolder(unfiledRecordId, folderToLink); Record recordLink = fileRecordToFolder(unfiledRecordId, folderToLink);
assertStatusCode(CREATED); assertStatusCode(CREATED);
assertTrue(recordLink.getParentId().equals(targetFolderId)); assertEquals(recordLink.getParentId(), targetFolderId);
// check the record is added into the record folder // check the record is added into the record folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();

View File

@@ -40,11 +40,13 @@ import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.create
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.OK;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import java.io.FileInputStream; import java.io.FileInputStream;
@@ -57,11 +59,14 @@ import org.alfresco.rest.rm.community.model.record.RecordContent;
import org.alfresco.rest.rm.community.model.record.RecordProperties; import org.alfresco.rest.rm.community.model.record.RecordProperties;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChildCollection;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.test.AlfrescoTest; import org.alfresco.test.AlfrescoTest;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -92,27 +97,36 @@ public class ReadRecordTests extends BaseRMRestTest
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
private RecordCategory rootCategory;
private RecordCategoryChild recordFolder;
@BeforeClass(alwaysRun = true)
public void setupReadRecordTests()
{
rootCategory = createRootCategory(getRandomName("rootCategory"));
recordFolder = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
}
/** /**
* Given a record category or a container which can't contain records * Given a record category or a container which can't contain records
* When I try to read the children filtering the results to records * When I try to read the children filtering the results to records
* Then I receive an empty list * Then I receive an empty list
*/ */
@DataProvider(name="invalidContainersForRecords") @DataProvider (name = "invalidContainersForRecords")
public Object[][] getInvalidContainersForRecords() throws Exception public Object[][] getInvalidContainersForRecords()
{ {
return new String[][] { return new String[][] {
{ FILE_PLAN_ALIAS }, { FILE_PLAN_ALIAS },
{ TRANSFERS_ALIAS }, { TRANSFERS_ALIAS },
{ createCategoryFolderInFilePlan().getParentId()} { rootCategory.getId()}
}; };
} }
@Test @Test
( (
dataProvider ="invalidContainersForRecords", dataProvider = "invalidContainersForRecords",
description ="Reading records from invalid containers" description = "Reading records from invalid containers"
) )
@AlfrescoTest(jira="RM-4361") @AlfrescoTest(jira="RM-4361")
public void readRecordsFromInvalidContainers(String container) throws Exception public void readRecordsFromInvalidContainers(String container)
{ {
Record electronicRecord = Record.builder() Record electronicRecord = Record.builder()
.name(ELECTRONIC_RECORD_NAME) .name(ELECTRONIC_RECORD_NAME)
@@ -137,34 +151,30 @@ public class ReadRecordTests extends BaseRMRestTest
if(FILE_PLAN_ALIAS.equals(container)) if(FILE_PLAN_ALIAS.equals(container))
{ {
getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(container, "") getRestAPIFactory().getFilePlansAPI().getRootRecordCategories(container, "")
.assertThat()//check the list returned is not empty .assertThat()//check the list returned is not empty
.entriesListIsNotEmpty().assertThat().paginationExist(); .entriesListIsNotEmpty().assertThat().paginationExist();
//check response status code //check response status code
assertStatusCode(OK); assertStatusCode(OK);
} }
else if(TRANSFERS_ALIAS.equals(container)) else if(TRANSFERS_ALIAS.equals(container))
{ {
getRestAPIFactory().getTransferContainerAPI().getTransfers(container, "where=(isRecord=true)") getRestAPIFactory().getTransferContainerAPI().getTransfers(container, "where=(isRecord=true)")
.assertThat()//check the list returned is empty .assertThat()//check the list returned is empty
.entriesListIsEmpty().assertThat().paginationExist(); .entriesListIsEmpty().assertThat().paginationExist();
//check response status code //check response status code
assertStatusCode(OK); assertStatusCode(OK);
} }
else else
{ {
String recordCategoryId = getRestAPIFactory().getRecordCategoryAPI().getRecordCategory(container).getId(); RecordCategoryChildCollection children = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(container);
assertStatusCode(OK);
getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(recordCategoryId)
.assertThat()//check the list returned is empty
.entriesListCountIs(1).assertThat().paginationExist();
String nodeType = getRestAPIFactory().getRecordCategoryAPI().getRecordCategoryChildren(recordCategoryId).getEntries().get(0).getEntry().getNodeType();
assertEquals(nodeType, RECORD_FOLDER_TYPE);
//check response status code //check response status code
assertStatusCode(OK); assertStatusCode(OK);
children.assertThat() //check the list returned is not empty because there is a record folder created inside
.entriesListCountIs(1).assertThat().paginationExist();
assertEquals(children.getEntries().get(0).getEntry().getNodeType(), RECORD_FOLDER_TYPE);
} }
} }
/** /**
* Given a record * Given a record
* When I try to read the meta-data * When I try to read the meta-data
@@ -172,7 +182,7 @@ public class ReadRecordTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest (jira = "RM-4361") @AlfrescoTest (jira = "RM-4361")
public void readRecordMetadata() throws Exception public void readRecordMetadata()
{ {
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder"; String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
@@ -201,7 +211,7 @@ public class ReadRecordTests extends BaseRMRestTest
assertNotNull(recordWithContent.getContent().getEncoding()); assertNotNull(recordWithContent.getContent().getEncoding());
assertNotNull(recordWithContent.getContent().getMimeType()); assertNotNull(recordWithContent.getContent().getMimeType());
assertNotNull(recordWithContent.getAspectNames()); assertNotNull(recordWithContent.getAspectNames());
assertFalse(recordWithContent.getName().equals(ELECTRONIC_RECORD_NAME)); assertNotEquals(ELECTRONIC_RECORD_NAME, recordWithContent.getName());
assertTrue(recordWithContent.getName().contains(recordWithContent.getProperties().getIdentifier())); assertTrue(recordWithContent.getName().contains(recordWithContent.getProperties().getIdentifier()));
assertStatusCode(OK); assertStatusCode(OK);
@@ -212,11 +222,11 @@ public class ReadRecordTests extends BaseRMRestTest
//Check the metadata returned //Check the metadata returned
assertTrue(nonElectronicRecord.getName().startsWith(NONELECTRONIC_RECORD_NAME)); assertTrue(nonElectronicRecord.getName().startsWith(NONELECTRONIC_RECORD_NAME));
assertEquals(nonElectronicRecord.getContent(), null); assertNull(nonElectronicRecord.getContent());
assertEquals(nonElectronicRecord.getNodeType(), NON_ELECTRONIC_RECORD_TYPE); assertEquals(nonElectronicRecord.getNodeType(), NON_ELECTRONIC_RECORD_TYPE);
assertNotNull(nonElectronicRecord.getAspectNames()); assertNotNull(nonElectronicRecord.getAspectNames());
assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME); assertEquals(nonElectronicRecord.getProperties().getDescription(), NONELECTRONIC_RECORD_NAME);
assertFalse(nonElectronicRecord.getName().equals(NONELECTRONIC_RECORD_NAME)); assertNotEquals(NONELECTRONIC_RECORD_NAME, nonElectronicRecord.getName());
assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getIdentifier())); assertTrue(nonElectronicRecord.getName().contains(nonElectronicRecord.getProperties().getIdentifier()));
assertStatusCode(OK); assertStatusCode(OK);
} }
@@ -234,7 +244,7 @@ public class ReadRecordTests extends BaseRMRestTest
String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric(); String RECORD_ELECTRONIC = "Record " + getRandomAlphanumeric();
String RECORD_ELECTRONIC_BINARY = "Binary Record" + getRandomAlphanumeric(); String RECORD_ELECTRONIC_BINARY = "Binary Record" + getRandomAlphanumeric();
String existentRecordCategoryId = createCategoryFolderInFilePlan().getParentId(); String existentRecordCategoryId = createRootCategory(getRandomName("rootCategory2")).getId();
String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder"; String RELATIVE_PATH = "/" + CATEGORY_NAME + getRandomAlphanumeric() + "/folder";
@@ -292,18 +302,15 @@ public class ReadRecordTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest (jira = "RM-4361") @AlfrescoTest (jira = "RM-4361")
public void readNonElectronicRecordContent() throws Exception public void readNonElectronicRecordContent()
{ {
String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric();
String folderId = createCategoryFolderInFilePlan().getId();
Record record = Record.builder() Record record = Record.builder()
.name(NONELECTRONIC_RECORD_NAME) .name(getRandomName("Record nonelectronic"))
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
String nonElectronicRecord = recordFolderAPI.createRecord(record, folderId).getId(); String nonElectronicRecord = recordFolderAPI.createRecord(record, recordFolder.getId()).getId();
getRestAPIFactory().getRecordsAPI().getRecordContent(nonElectronicRecord); getRestAPIFactory().getRecordsAPI().getRecordContent(nonElectronicRecord);
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
@@ -315,12 +322,12 @@ public class ReadRecordTests extends BaseRMRestTest
* Then I receive an error * Then I receive an error
*/ */
@DataProvider(name="noContentNodes") @DataProvider(name="noContentNodes")
public Object[][] getNonRecordTypes() throws Exception public Object[][] getNonRecordTypes()
{ {
return new String[][] { return new String[][] {
{ getFilePlan(FILE_PLAN_ALIAS).getId() }, { getFilePlan(FILE_PLAN_ALIAS).getId() },
{ getTransferContainer(TRANSFERS_ALIAS).getId() }, { getTransferContainer(TRANSFERS_ALIAS).getId() },
{ createCategoryFolderInFilePlan().getParentId()} { rootCategory.getId()}
}; };
} }
@Test @Test
@@ -329,11 +336,16 @@ public class ReadRecordTests extends BaseRMRestTest
description = "Reading records from invalid containers" description = "Reading records from invalid containers"
) )
@AlfrescoTest (jira = "RM-4361") @AlfrescoTest (jira = "RM-4361")
public void readContentFromInvalidContainers(String container) throws Exception public void readContentFromInvalidContainers(String container)
{ {
getRestAPIFactory().getRecordsAPI().getRecordContent(container).asString(); getRestAPIFactory().getRecordsAPI().getRecordContent(container).asString();
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
} }
@AfterClass(alwaysRun = true)
public void cleanupReadRecordTests()
{
deleteRecordCategory(rootCategory.getId());
}
} }

View File

@@ -73,7 +73,7 @@ public class RejectRecordTests extends BaseRMRestTest
private RulesAPI rulesAPI; private RulesAPI rulesAPI;
@BeforeClass (alwaysRun = true) @BeforeClass (alwaysRun = true)
public void setUp() throws Exception public void setUp()
{ {
publicSite = dataSite.usingAdmin().createPublicRandomSite(); publicSite = dataSite.usingAdmin().createPublicRandomSite();
recordCategory = createRootCategory(getRandomName("recordCategory")); recordCategory = createRootCategory(getRandomName("recordCategory"));
@@ -121,7 +121,7 @@ public class RejectRecordTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest(jira = "RM-6881") @AlfrescoTest(jira = "RM-6881")
public void rejectCompletedRecord() throws Exception public void rejectCompletedRecord()
{ {
STEP("Create a document in the collaboration site"); STEP("Create a document in the collaboration site");
FileModel testFile = dataContent.usingSite(publicSite) FileModel testFile = dataContent.usingSite(publicSite)

View File

@@ -26,9 +26,9 @@
*/ */
package org.alfresco.rest.rm.community.records; package org.alfresco.rest.rm.community.records;
import static java.util.Arrays.asList;
import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME; import static org.alfresco.rest.rm.community.base.TestData.NONELECTRONIC_RECORD_NAME;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_FOLDER_NAME;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_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.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_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;
@@ -40,7 +40,7 @@ import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.create
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicUnfiledContainerChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicUnfiledContainerChildModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordModel;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.getFile;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.FORBIDDEN;
import static org.springframework.http.HttpStatus.OK; import static org.springframework.http.HttpStatus.OK;
@@ -49,30 +49,26 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record; import org.alfresco.rest.rm.community.model.record.Record;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
import org.alfresco.rest.rm.community.model.user.UserPermissions; import org.alfresco.rest.rm.community.model.user.UserPermissions;
import org.alfresco.rest.rm.community.requests.gscore.api.FilePlanAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RMUserAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordCategoryAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordFolderAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI; import org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
import org.alfresco.rest.v0.service.RoleService; import org.alfresco.rest.v0.service.RoleService;
import org.alfresco.test.AlfrescoTest; import org.alfresco.test.AlfrescoTest;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel; import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -86,18 +82,32 @@ import org.testng.annotations.Test;
*/ */
public class UpdateRecordsTests extends BaseRMRestTest public class UpdateRecordsTests extends BaseRMRestTest
{ {
/* to be used to append to modifications */
private final String MODIFIED_PREFIX = "modified_";
@Autowired @Autowired
private RoleService roleService; private RoleService roleService;
private RecordCategory rootCategory;
private UnfiledContainerChild unfiledRecordFolder;
private final List<UnfiledContainerChild> unfiledRecords = new ArrayList<>();
private UserModel updateUser;
@BeforeClass (alwaysRun = true)
public void preconditionUpdateRecordsTests()
{
rootCategory = createRootCategory(getRandomName("CATEGORY NAME"));
unfiledRecordFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
getRandomName("UnfiledRecordFolder"), UNFILED_RECORD_FOLDER_TYPE);
// RM Security Officer is the lowest role with Edit Record Metadata capabilities
// Grant updateUser Filing privileges on root category, this will be inherited to record folders
updateUser = roleService.createUserWithRMRoleAndCategoryPermission(ROLE_RM_SECURITY_OFFICER.roleId,
rootCategory, UserPermissions.PERMISSION_FILING);
}
/** Incomplete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */ /** Incomplete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
@DataProvider(name = "incompleteRecords") @DataProvider(name = "incompleteRecords")
public Object[][] getIncompleteRecords() throws Exception public Object[][] getIncompleteRecords()
{ {
//create electronic and nonElectronic record in record folder //create electronic and nonElectronic record in record folder
String recordFolderId = createCategoryFolderInFilePlan().getId(); String recordFolderId = createRecordFolder(rootCategory.getId(), getRandomName("recFolder1")).getId();
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE)); Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE));
@@ -110,36 +120,40 @@ public class UpdateRecordsTests extends BaseRMRestTest
UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI(); UnfiledContainerAPI unfiledContainersAPI = getRestAPIFactory().getUnfiledContainersAPI();
UnfiledContainerChild electronicRecord1 = unfiledContainersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS, getFile(IMAGE_FILE)); UnfiledContainerChild electronicRecord1 = unfiledContainersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS, getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
unfiledRecords.add(electronicRecord1);
UnfiledContainerChild nonElectronicRecord1 = unfiledContainersAPI.createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS); UnfiledContainerChild nonElectronicRecord1 = unfiledContainersAPI.createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS);
assertStatusCode(CREATED); assertStatusCode(CREATED);
unfiledRecords.add(nonElectronicRecord1);
//create electronic record and nonElectronic record in unfiled record folder //create electronic record and nonElectronic record in unfiled record folder
String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
UnfiledContainerChild electronicRecord2 = unfiledRecordFoldersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), unfiledRecordFolderId, getFile(IMAGE_FILE)); UnfiledContainerChild electronicRecord2 = unfiledRecordFoldersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId(), getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
UnfiledContainerChild nonElectronicRecord2 = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), unfiledRecordFolderId); UnfiledContainerChild nonElectronicRecord2 = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId());
assertStatusCode(CREATED); assertStatusCode(CREATED);
return new String[][] return new String[][]
{ {
// an arbitrary record folder // an arbitrary record folder
{ electronicRecord.getId(), nonElectronicRecord.getId()}, { electronicRecord.getId() },
// unfiled records root { nonElectronicRecord.getId() },
{ electronicRecord1.getId(), nonElectronicRecord1.getId()}, // unfiled records root
// an arbitrary unfiled records folder { electronicRecord1.getId() },
{ electronicRecord2.getId(), nonElectronicRecord2.getId()} { nonElectronicRecord1.getId() },
// an arbitrary unfiled records folder
{ electronicRecord2.getId() },
{ nonElectronicRecord2.getId() }
}; };
} }
/** Complete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */ /** Complete electronic and non electronic records created in one record folder, unfiled records container and one unfiled record folder */
@DataProvider(name = "completeRecords") @DataProvider(name = "completeRecords")
public Object[][] getCompleteRecords() throws Exception public Object[][] getCompleteRecords()
{ {
//create electronic and nonElectronic record in record folder //create electronic and nonElectronic record in record folder
String recordFolderId = createCategoryFolderInFilePlan().getId(); String recordFolderId = createRecordFolder(rootCategory.getId(), getRandomName("recFolder2")).getId();
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE)); Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE));
@@ -155,19 +169,20 @@ public class UpdateRecordsTests extends BaseRMRestTest
UnfiledContainerChild electronicRecord1 = unfiledContainersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS, getFile(IMAGE_FILE)); UnfiledContainerChild electronicRecord1 = unfiledContainersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS, getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
completeRecord(electronicRecord1.getId()); completeRecord(electronicRecord1.getId());
unfiledRecords.add(electronicRecord1);
UnfiledContainerChild nonElectronicRecord1 = unfiledContainersAPI.createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS); UnfiledContainerChild nonElectronicRecord1 = unfiledContainersAPI.createUnfiledContainerChild(createNonElectronicUnfiledContainerChildModel(), UNFILED_RECORDS_CONTAINER_ALIAS);
assertStatusCode(CREATED); assertStatusCode(CREATED);
completeRecord(nonElectronicRecord1.getId()); completeRecord(nonElectronicRecord1.getId());
unfiledRecords.add(nonElectronicRecord1);
//create electronic record and nonElectronic record in unfiled record folder //create electronic record and nonElectronic record in unfiled record folder
String unfiledRecordFolderId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId();
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
UnfiledContainerChild electronicRecord2 = unfiledRecordFoldersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), unfiledRecordFolderId, getFile(IMAGE_FILE)); UnfiledContainerChild electronicRecord2 = unfiledRecordFoldersAPI.uploadRecord(createElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId(), getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
completeRecord(electronicRecord2.getId()); completeRecord(electronicRecord2.getId());
UnfiledContainerChild nonElectronicRecord2 = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), unfiledRecordFolderId); UnfiledContainerChild nonElectronicRecord2 = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(createNonElectronicUnfiledContainerChildModel(), unfiledRecordFolder.getId());
assertStatusCode(CREATED); assertStatusCode(CREATED);
completeRecord(nonElectronicRecord2.getId()); completeRecord(nonElectronicRecord2.getId());
@@ -188,7 +203,6 @@ public class UpdateRecordsTests extends BaseRMRestTest
* When I try to update the records meta-data * When I try to update the records meta-data
* Then the record is successfully updated * Then the record is successfully updated
* </pre> * </pre>
* @throws Exception
*/ */
@Test @Test
( (
@@ -196,30 +210,26 @@ public class UpdateRecordsTests extends BaseRMRestTest
description = "Incomplete records can be updated" description = "Incomplete records can be updated"
) )
@AlfrescoTest(jira="RM-4362") @AlfrescoTest(jira="RM-4362")
public void incompleteRecordsCanBeUpdated(String electronicRecordId, String nonElectronicRecordId) throws Exception public void incompleteRecordsCanBeUpdated(String recordId)
{ {
// Get the recordsAPI // Get the recordsAPI
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
Record electronicRecord = recordsAPI.getRecord(electronicRecordId); Record record = recordsAPI.getRecord(recordId);
Record nonElectronicRecord = recordsAPI.getRecord(nonElectronicRecordId);
for (Record record: Arrays.asList(electronicRecord, nonElectronicRecord)) { // Generate update metadata
// Generate update metadata String newName = getModifiedPropertyValue(record.getName());
String newName = getModifiedPropertyValue(record.getName()); String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle()); String newDescription = getModifiedPropertyValue(record.getProperties().getDescription());
String newDescription = getModifiedPropertyValue(record.getProperties().getDescription());
Record recordModel = createRecordModel(newName, newDescription, newTitle);
// Update record // Update record
recordsAPI.updateRecord(recordModel, record.getId()); recordsAPI.updateRecord(createRecordModel(newName, newDescription, newTitle), record.getId());
assertStatusCode(OK); assertStatusCode(OK);
// Verify the original record meta data has been retained // Verify the original record meta data has been retained
Record updatedRecord = recordsAPI.getRecord(record.getId()); Record updatedRecord = recordsAPI.getRecord(record.getId());
assertEquals(updatedRecord.getName(), newName); assertEquals(updatedRecord.getName(), newName);
assertEquals(updatedRecord.getProperties().getTitle(), newTitle); assertEquals(updatedRecord.getProperties().getTitle(), newTitle);
assertEquals(updatedRecord.getProperties().getDescription(), newDescription); assertEquals(updatedRecord.getProperties().getDescription(), newDescription);
}
} }
/** /**
@@ -229,44 +239,25 @@ public class UpdateRecordsTests extends BaseRMRestTest
* When I try to update the records meta-data * When I try to update the records meta-data
* Then the record is successfully updated * Then the record is successfully updated
* </pre> * </pre>
* @throws Exception
*/ */
@Test @Test (description = "User with Edit Metadata capabilities can update incomplete record's metadata")
(
description = "User with Edit Metadata capabilities can update incomplete record's metadata"
)
@AlfrescoTest(jira="RM-4362") @AlfrescoTest(jira="RM-4362")
public void userWithEditMetadataCapsCanUpdateMetadata() throws Exception public void userWithEditMetadataCapsCanUpdateMetadata()
{ {
RMUserAPI rmUserAPI = getRestAPIFactory().getRMUserAPI();
// Create test user and add it with collab. privileges.
// RM Security Officer is the lowest role with Edit Record Metadata capabilities
UserModel updateUser = roleService.createUserWithRMRole(ROLE_RM_SECURITY_OFFICER.roleId);
updateUser.setUserRole(UserRole.SiteCollaborator);
getDataUser().addUserToSite(updateUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator);
// Create random folder // Create random folder
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); RecordCategoryChild recFolder = createRecordFolder(rootCategory.getId(), getRandomName("recFolder"));
logger.info("random folder:" + recordFolder.getName());
// Grant updateUser Filing privileges on randomFolder category, this will be
// Inherited to randomFolder
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI();
rmUserAPI.addUserPermission(recordCategoryAPI.getRecordCategory(recordFolder.getParentId()).getId(),
updateUser, UserPermissions.PERMISSION_FILING);
assertStatusCode(OK);
// Create electronic and non-electronic records in a folder // Create electronic and non-electronic records in a folder
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI(); RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recordFolder.getId(), getFile(IMAGE_FILE)); Record electronicRecord = recordFolderAPI.createRecord(createElectronicRecordModel(), recFolder.getId(), getFile(IMAGE_FILE));
assertStatusCode(CREATED); assertStatusCode(CREATED);
Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(), recordFolder.getId()); Record nonElectronicRecord = recordFolderAPI.createRecord(createNonElectronicRecordModel(), recFolder.getId());
assertStatusCode(CREATED); assertStatusCode(CREATED);
// Get recordsAPI instance initialised to updateUser // Get recordsAPI instance initialised to updateUser
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(updateUser); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(updateUser);
for (Record record: Arrays.asList(electronicRecord, nonElectronicRecord)) for (Record record: asList(electronicRecord, nonElectronicRecord))
{ {
recordsAPI.getRecord(record.getId()); recordsAPI.getRecord(record.getId());
assertStatusCode(OK); assertStatusCode(OK);
@@ -275,10 +266,9 @@ public class UpdateRecordsTests extends BaseRMRestTest
String newName = getModifiedPropertyValue(record.getName()); String newName = getModifiedPropertyValue(record.getName());
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle()); String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
String newDescription = getModifiedPropertyValue(record.getProperties().getDescription()); String newDescription = getModifiedPropertyValue(record.getProperties().getDescription());
Record recordModel = createRecordModel(newName, newDescription, newTitle);
// Update record // Update record
recordsAPI.updateRecord(recordModel, record.getId()); recordsAPI.updateRecord(createRecordModel(newName, newDescription, newTitle), record.getId());
assertStatusCode(OK); assertStatusCode(OK);
// Verify the update got applied // Verify the update got applied
@@ -295,9 +285,8 @@ public class UpdateRecordsTests extends BaseRMRestTest
* Given a complete record * Given a complete record
* When I try to update the records meta-data * When I try to update the records meta-data
* Then it fails * Then it fails
* And and the records meta-data is unchanged * And the records meta-data is unchanged
* </pre> * </pre>
* @throws Exception
*/ */
@Test @Test
( (
@@ -305,14 +294,16 @@ public class UpdateRecordsTests extends BaseRMRestTest
description = "Complete records can't be updated" description = "Complete records can't be updated"
) )
@AlfrescoTest(jira="RM-4362") @AlfrescoTest(jira="RM-4362")
public void completeRecordsCantBeUpdated(String electronicRecordId, String nonElectronicRecordId) throws Exception @Bug (id = "APPS-132")
public void completeRecordsCantBeUpdated(String electronicRecordId, String nonElectronicRecordId)
{ {
// Get the recordsAPI // Get the recordsAPI
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
Record electronicRecord = recordsAPI.getRecord(electronicRecordId); Record electronicRecord = recordsAPI.getRecord(electronicRecordId);
Record nonElectronicRecord = recordsAPI.getRecord(nonElectronicRecordId); Record nonElectronicRecord = recordsAPI.getRecord(nonElectronicRecordId);
for (Record record: Arrays.asList(electronicRecord, nonElectronicRecord)) { for (Record record: asList(electronicRecord, nonElectronicRecord))
{
// Generate update metadata // Generate update metadata
String newName = getModifiedPropertyValue(record.getName()); String newName = getModifiedPropertyValue(record.getName());
String newTitle = getModifiedPropertyValue(record.getProperties().getTitle()); String newTitle = getModifiedPropertyValue(record.getProperties().getTitle());
@@ -338,6 +329,8 @@ public class UpdateRecordsTests extends BaseRMRestTest
*/ */
private String getModifiedPropertyValue(String originalValue) private String getModifiedPropertyValue(String originalValue)
{ {
/* to be used to append to modifications */
String MODIFIED_PREFIX = "modified_";
return MODIFIED_PREFIX + originalValue; return MODIFIED_PREFIX + originalValue;
} }
/** /**
@@ -346,89 +339,49 @@ public class UpdateRecordsTests extends BaseRMRestTest
* When I try to update the record aspects with an empty list * When I try to update the record aspects with an empty list
* Then it fails * Then it fails
* </pre> * </pre>
* @throws Exception
*/ */
@Test(description = "Cannot remove mandatory aspects from record") @Test(description = "Cannot remove mandatory aspects from record")
@AlfrescoTest(jira = "RM-4926") @AlfrescoTest(jira = "RM-4926")
public void electronicRecordMandatoryAspectsCannotBeRemoved() throws Exception public void electronicRecordMandatoryAspectsCannotBeRemoved()
{ {
final List<String> expectedAspects = asList("rma:record", "rma:filePlanComponent",
"rma:recordComponentIdentifier", "rma:commonRecordDetails");
final List<String> emptyAspectList = new ArrayList<>();
Record recordModelToUpdate = Record.builder().aspectNames(emptyAspectList).build();
// Get the recordsAPI // Get the recordsAPI
RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI(); RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
RecordFolderAPI recordFolderAPI = getRestAPIFactory().getRecordFolderAPI();
RecordCategoryChild recordFolder = createCategoryFolderInFilePlan(); // Create random folder
String recordFolderId = createRecordFolder(rootCategory.getId(), getRandomName("recordFolder")).getId();
// Create an electronic record // Create an electronic record and check it has all the records aspects
Record recordModel = createElectronicRecordModel(); Record electronicRecord = getRestAPIFactory().getRecordFolderAPI()
String recordId = recordFolderAPI.createRecord(recordModel, recordFolder.getId(), getFile(IMAGE_FILE)).getId(); .createRecord(createElectronicRecordModel(), recordFolderId, getFile(IMAGE_FILE));
assertTrue( electronicRecord.getAspectNames().containsAll(expectedAspects));
Record electronicRecord = recordsAPI.getRecord(recordId);
List<String> aspects = electronicRecord.getAspectNames();
// this operation is only valid for records
assertTrue(aspects.contains("rma:record"));
assertTrue(aspects.contains("rma:filePlanComponent"));
assertTrue(aspects.contains("rma:recordComponentIdentifier"));
assertTrue(aspects.contains("rma:commonRecordDetails"));
List<String> emptyAspectList = new ArrayList<String>();
Record recordModelToUpdate = Record.builder().aspectNames(emptyAspectList).build();
// Update record // Update record
recordsAPI.updateRecord(recordModelToUpdate, electronicRecord.getId()); recordsAPI.updateRecord(recordModelToUpdate, electronicRecord.getId());
assertStatusCode(UNPROCESSABLE_ENTITY); assertStatusCode(UNPROCESSABLE_ENTITY);
// Get the recordsAPI // Create an electronic record in the unfiled record folder and check it has all the records aspects
UnfiledRecordFolderAPI unfiledRecordFolderAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
// Create root unfiled record folder
UnfiledContainerChild unfiledFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, RECORD_FOLDER_NAME,
UNFILED_RECORD_FOLDER_TYPE);
// Create an electronic record
UnfiledContainerChild unfiledRecordModel = UnfiledContainerChild.builder() UnfiledContainerChild unfiledRecordModel = UnfiledContainerChild.builder()
.properties(UnfiledContainerChildProperties.builder().description(NONELECTRONIC_RECORD_NAME).title("Title").build()) .properties(UnfiledContainerChildProperties.builder().description(NONELECTRONIC_RECORD_NAME).title("Title").build())
.name(NONELECTRONIC_RECORD_NAME).nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()).build(); .name(NONELECTRONIC_RECORD_NAME).nodeType(NON_ELECTRONIC_RECORD_TYPE).build();
UnfiledContainerChild unfiledRecord = unfiledRecordFolderAPI.createUnfiledRecordFolderChild(unfiledRecordModel, UnfiledContainerChild unfiledRecord = getRestAPIFactory().getUnfiledRecordFoldersAPI()
unfiledFolder.getId()); .createUnfiledRecordFolderChild(unfiledRecordModel, unfiledRecordFolder.getId());
assertTrue(unfiledRecord.getAspectNames().containsAll(expectedAspects));
aspects = unfiledRecord.getAspectNames();
assertTrue(aspects.contains("rma:record"));
assertTrue(aspects.contains("rma:filePlanComponent"));
assertTrue(aspects.contains("rma:recordComponentIdentifier"));
assertTrue(aspects.contains("rma:commonRecordDetails"));
Record recordModelToUpdateToUnfiled = Record.builder().aspectNames(emptyAspectList).build();
// Update record // Update record
recordsAPI.updateRecord(recordModelToUpdateToUnfiled, unfiledRecord.getId()); recordsAPI.updateRecord(recordModelToUpdate, unfiledRecord.getId());
assertStatusCode(UNPROCESSABLE_ENTITY); assertStatusCode(UNPROCESSABLE_ENTITY);
} }
@AfterClass (alwaysRun = true) @AfterClass (alwaysRun = true)
public void tearDown() throws Exception public void tearDown()
{ {
FilePlanAPI filePlansAPI = getRestAPIFactory().getFilePlansAPI(); deleteRecordCategory(rootCategory.getId());
RecordCategoryAPI recordCategoryAPI = getRestAPIFactory().getRecordCategoryAPI(); getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledRecordFolder.getId());
unfiledRecords.forEach(unfiledRecord -> getRestAPIFactory().getRecordsAPI().deleteRecord(unfiledRecord.getId()));
filePlansAPI.getRootRecordCategories(FILE_PLAN_ALIAS).getEntries().forEach(recordCategoryEntry -> getDataUser().deleteUser(updateUser);
{
recordCategoryAPI.deleteRecordCategory(recordCategoryEntry.getEntry().getId());
});
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS);
listedChildren.getEntries().forEach(UnfiledContainerChildEntry ->
{
if (UnfiledContainerChildEntry.getEntry().getIsRecord())
{
getRestAPIFactory().getRecordsAPI().deleteRecord(UnfiledContainerChildEntry.getEntry().getId());
}
else
{
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(UnfiledContainerChildEntry.getEntry().getId());
}
});
} }
} }

View File

@@ -36,7 +36,6 @@ import static org.testng.AssertJUnit.assertTrue;
import org.alfresco.dataprep.ContentActions; import org.alfresco.dataprep.ContentActions;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild;
import org.alfresco.rest.rm.community.model.user.UserPermissions; import org.alfresco.rest.rm.community.model.user.UserPermissions;
@@ -173,7 +172,7 @@ public class CmisQueryTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest (jira = "MNT-19442") @AlfrescoTest (jira = "MNT-19442")
public void getDocumentsWithSpecificNamesCmisQuery() throws Exception public void getDocumentsWithSpecificNamesCmisQuery()
{ {
// execute the cmis query // execute the cmis query
ItemIterable<QueryResult> results = ItemIterable<QueryResult> results =
@@ -196,7 +195,7 @@ public class CmisQueryTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest (jira = "MNT-19442") @AlfrescoTest (jira = "MNT-19442")
public void getDocumentsCmisQueryWithPagination() throws Exception public void getDocumentsCmisQueryWithPagination()
{ {
OperationContext oc = new OperationContextImpl(); OperationContext oc = new OperationContextImpl();
oc.setMaxItemsPerPage(10); oc.setMaxItemsPerPage(10);
@@ -216,7 +215,7 @@ public class CmisQueryTests extends BaseRMRestTest
private void clearCmisQueryTests() private void clearCmisQueryTests()
{ {
dataSite.usingAdmin().deleteSite(collaborationSite); dataSite.usingAdmin().deleteSite(collaborationSite);
getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordFolder.getParentId()); deleteRecordCategory(recordFolder.getParentId());
getDataUser().usingAdmin().deleteUser(rmUser); getDataUser().usingAdmin().deleteUser(rmUser);
getDataUser().usingAdmin().deleteUser(nonRMUser); getDataUser().usingAdmin().deleteUser(nonRMUser);
} }

View File

@@ -45,7 +45,6 @@ import org.alfresco.utility.model.FileType;
import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.SiteModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;

View File

@@ -49,11 +49,11 @@ public class ShareLiveSearchTests extends BaseRMRestTest
*/ */
@Test @Test
@AlfrescoTest(jira = "RM-5882") @AlfrescoTest(jira = "RM-5882")
public void liveSearchForVitalWord() throws Exception public void liveSearchForVitalWord()
{ {
createRMSiteIfNotExists(); createRMSiteIfNotExists();
List<String> results = searchApi.liveSearchForDocumentsAsUser(getAdminUser().getUsername(), getAdminUser().getPassword(), "vital"); List<String> results = searchApi.liveSearchForDocumentsAsUser(getAdminUser().getUsername(), getAdminUser().getPassword(), "vital");
assertTrue(results.isEmpty() || !results.stream().anyMatch("Vital Records due for Review"::equalsIgnoreCase), assertTrue(results.isEmpty() || results.stream().noneMatch("Vital Records due for Review"::equalsIgnoreCase),
"Share Live Search should return 0 results when searching for RM Saved Search filter words, but it returned:" "Share Live Search should return 0 results when searching for RM Saved Search filter words, but it returned:"
+ Arrays.toString(results.toArray())); + Arrays.toString(results.toArray()));
} }

View File

@@ -71,11 +71,8 @@ public class RMSiteTests extends BaseRMRestTest
* When I want to create the RM site with specific title, description and compliance * When I want to create the RM site with specific title, description and compliance
* Then the RM site is created * Then the RM site is created
*/ */
@Test @Test (description = "Create RM site with Standard Compliance as admin user", priority = 2)
( public void createRMSiteAsAdminUser()
description = "Create RM site with Standard Compliance as admin user"
)
public void createRMSiteAsAdminUser() throws Exception
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
@@ -106,11 +103,8 @@ public class RMSiteTests extends BaseRMRestTest
* When I want to create the RM site * When I want to create the RM site
* Then the response code 409 (Site with the given identifier already exists) is return * Then the response code 409 (Site with the given identifier already exists) is return
*/ */
@Test @Test (description = "Create RM site when site already exist with admin user", priority = 3)
( public void createRMSiteWhenSiteExists()
description = "Create RM site when site already exist with admin user"
)
public void createRMSiteWhenSiteExists() throws Exception
{ {
// Create the RM site if it does not exist // Create the RM site if it does not exist
createRMSiteIfNotExists(); createRMSiteIfNotExists();
@@ -132,11 +126,8 @@ public class RMSiteTests extends BaseRMRestTest
* When I want to delete the RM site * When I want to delete the RM site
* Then RM site is successfully deleted * Then RM site is successfully deleted
*/ */
@Test @Test (description = "Delete RM site as admin user")
( public void deleteRMSite()
description = "Delete RM site as admin user"
)
public void deleteRMSite() throws Exception
{ {
// Create the RM site if it does not exist // Create the RM site if it does not exist
createRMSiteIfNotExists(); createRMSiteIfNotExists();
@@ -153,11 +144,8 @@ public class RMSiteTests extends BaseRMRestTest
* When I GET the retrieve the RM site details * When I GET the retrieve the RM site details
* Then RM site details are returned * Then RM site details are returned
*/ */
@Test @Test (description = "GET the RM site as admin user", priority = 3)
( public void getRMSite()
description = "GET the RM site as admin user"
)
public void getRMSite() throws Exception
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
@@ -187,12 +175,9 @@ public class RMSiteTests extends BaseRMRestTest
* When the user wants to create a RM site with DOD compliance * When the user wants to create a RM site with DOD compliance
* Then RM site is created * Then RM site is created
*/ */
@Test @Test (description = "Create RM site with DOD compliance as an another admin user", priority = 1)
(
description = "Create RM site with DOD compliance as an another admin user"
)
@Bug (id="RM-4289") @Bug (id="RM-4289")
public void createRMSiteAsAnotherAdminUser() throws Exception public void createRMSiteAsAnotherAdminUser()
{ {
RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
@@ -228,8 +213,8 @@ public class RMSiteTests extends BaseRMRestTest
* When the admin user wants to update the RM site details (title or description) * When the admin user wants to update the RM site details (title or description)
* Then RM site details are updated * Then RM site details are updated
*/ */
@Test @Test(priority = 3)
public void updateRMSiteDetails() throws Exception public void updateRMSiteDetails()
{ {
String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric(); String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric();
String NEW_DESCRIPTION = RM_DESCRIPTION + RandomData.getRandomAlphanumeric(); String NEW_DESCRIPTION = RM_DESCRIPTION + RandomData.getRandomAlphanumeric();
@@ -265,8 +250,8 @@ public class RMSiteTests extends BaseRMRestTest
* When the admin user wants to update the RM site compliance * When the admin user wants to update the RM site compliance
* Then RM site compliance is not updated * Then RM site compliance is not updated
*/ */
@Test @Test(priority = 3)
public void updateRMSiteComplianceAsAdmin() throws Exception public void updateRMSiteComplianceAsAdmin()
{ {
// Create the RM site if it does not exist // Create the RM site if it does not exist
createRMSiteIfNotExists(); createRMSiteIfNotExists();

View File

@@ -37,6 +37,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.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CONFLICT;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
@@ -48,6 +49,7 @@ import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
@@ -55,13 +57,11 @@ import java.util.NoSuchElementException;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.base.DataProviderClass; import org.alfresco.rest.rm.community.base.DataProviderClass;
import org.alfresco.rest.rm.community.model.fileplan.FilePlan; import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
import org.alfresco.rest.rm.community.model.record.RecordProperties;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainer;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder;
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledContainerAPI;
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil; import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
import org.alfresco.utility.report.Bug; import org.alfresco.utility.report.Bug;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
@@ -79,6 +79,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
{ {
/** Number of children (for children creation test) */ /** Number of children (for children creation test) */
private static final int NUMBER_OF_CHILDREN = 10; private static final int NUMBER_OF_CHILDREN = 10;
private final List<UnfiledContainerChild> unfiledChildren = new ArrayList<>();
/** /**
* Data Provider with: * Data Provider with:
@@ -101,13 +102,13 @@ public class UnfiledContainerTests extends BaseRMRestTest
* Given the RM site exists * Given the RM site exists
* When I retrieve the unfiled record conteiner by placeholder * When I retrieve the unfiled record conteiner by placeholder
* Then the details of the unfiled record container is returned * Then the details of the unfiled record container is returned
* </pre> * </pre>
*/ */
@Test @Test
( (
description = "Get the unfiled records container" description = "Get the unfiled records container"
) )
public void getUnfiledRecordsContainer() throws Exception public void getUnfiledRecordsContainer()
{ {
// Get the unfiled records container // Get the unfiled records container
UnfiledContainer container = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS); UnfiledContainer container = getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS);
@@ -130,7 +131,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
( (
description = "Rename unfiled container" description = "Rename unfiled container"
) )
public void renameUnfiledContainer() throws Exception public void renameUnfiledContainer()
{ {
String newContainerName = "RenamedUnfiledContainer (" + getRandomAlphanumeric() + ")"; String newContainerName = "RenamedUnfiledContainer (" + getRandomAlphanumeric() + ")";
@@ -165,10 +166,11 @@ public class UnfiledContainerTests extends BaseRMRestTest
description = "Create unfiled record folder child in unfiled root container", description = "Create unfiled record folder child in unfiled root container",
dataProvider = "unfiledFolderTypes" dataProvider = "unfiledFolderTypes"
) )
public void createUnfiledRecordFolderChild(String folderType) throws Exception public void createUnfiledRecordFolderChild(String folderType)
{ {
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric(); String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType); UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, folderType);
unfiledChildren.add(unfiledRecordFolderChild);
assertNotNull(unfiledRecordFolderChild.getId()); assertNotNull(unfiledRecordFolderChild.getId());
@@ -195,7 +197,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
dataProvider = "unfiledFolderTypes" dataProvider = "unfiledFolderTypes"
) )
@Bug(id ="RM-5116, RM-5148") @Bug(id ="RM-5116, RM-5148")
public void createDuplicateUnfiledFolderChild(String folderType) throws Exception public void createDuplicateUnfiledFolderChild(String folderType)
{ {
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric(); String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
@@ -203,26 +205,29 @@ public class UnfiledContainerTests extends BaseRMRestTest
// Verify the status code // Verify the status code
assertStatusCode(CREATED); assertStatusCode(CREATED);
unfiledChildren.add(unfiledRecordFolderChild);
assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName); assertEquals(unfiledRecordFolderChild.getName(), unfiledRecordFolderName);
// create the same unfiled folder // create the same unfiled folder
UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI() UnfiledContainerChild unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType), .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
UNFILED_RECORDS_CONTAINER_ALIAS); UNFILED_RECORDS_CONTAINER_ALIAS);
// Verify the status code // Verify the status code
assertStatusCode(CONFLICT); assertStatusCode(CONFLICT);
// create the same unfiled folder with the autoRename parameter on true // create the same unfiled folder with the autoRename parameter on true
unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI() unfiledRecordFolderDuplicate = getRestAPIFactory().getUnfiledContainersAPI()
.createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),UNFILED_RECORDS_CONTAINER_ALIAS,"autoRename=true"); .createUnfiledContainerChild(createUnfiledContainerChildModel(unfiledRecordFolderName, folderType),
UNFILED_RECORDS_CONTAINER_ALIAS, "autoRename=true");
//verify the response status code //verify the response status code
assertStatusCode(CREATED); assertStatusCode(CREATED);
unfiledChildren.add(unfiledRecordFolderDuplicate);
assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName); assertNotEquals(unfiledRecordFolderDuplicate.getName(), unfiledRecordFolderName);
assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName)); assertTrue(unfiledRecordFolderDuplicate.getName().startsWith(unfiledRecordFolderName));
} }
/** /**
* <pre> * <pre>
* Given that an unfiled records container exists * Given that an unfiled records container exists
@@ -234,21 +239,18 @@ public class UnfiledContainerTests extends BaseRMRestTest
( (
description = "Create unfiled record folder child in unfiled root container" description = "Create unfiled record folder child in unfiled root container"
) )
public void createUnfiledRecordFolderChildWithRelativePathNotSuported() throws Exception public void createUnfiledRecordFolderChildWithRelativePathNotSuported()
{ {
UnfiledContainerAPI unfiledContainerAPI = getRestAPIFactory().getUnfiledContainersAPI();
// relativePath specify the container structure to create relative to // relativePath specify the container structure to create relative to
// the record folder to be created // the record folder to be created
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth(); String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledFolderModel = UnfiledContainerChild.builder() UnfiledContainerChild unfiledFolderModel = UnfiledContainerChild.builder()
.name(unfiledRecordFolderName) .name(getRandomName("UnfiledRecordFolder"))
.nodeType(UNFILED_RECORD_FOLDER_TYPE) .nodeType(UNFILED_RECORD_FOLDER_TYPE)
.relativePath(relativePath) .relativePath(relativePath)
.build(); .build();
unfiledContainerAPI.createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS); getRestAPIFactory().getUnfiledContainersAPI()
.createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
// Check the API response code // Check the API response code
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
@@ -265,10 +267,11 @@ public class UnfiledContainerTests extends BaseRMRestTest
( (
description = "Create non-electronic record child in unfiled root container" description = "Create non-electronic record child in unfiled root container"
) )
public void createNonElectronicRecordChild() throws Exception public void createNonElectronicRecordChild()
{ {
String recordName = "NERecord-" + getRandomAlphanumeric(); String recordName = "NERecord-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecord = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, recordName, NON_ELECTRONIC_RECORD_TYPE); UnfiledContainerChild unfiledRecord = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, recordName, NON_ELECTRONIC_RECORD_TYPE);
unfiledChildren.add(unfiledRecord);
assertNotNull(unfiledRecord.getId()); assertNotNull(unfiledRecord.getId());
assertTrue(unfiledRecord.getIsRecord()); assertTrue(unfiledRecord.getIsRecord());
@@ -293,10 +296,11 @@ public class UnfiledContainerTests extends BaseRMRestTest
( (
description = "Create electronic record child in unfiled root container" description = "Create electronic record child in unfiled root container"
) )
public void createElectronicRecordChild() throws Exception public void createElectronicRecordChild()
{ {
String recordName = "ERecord-" + getRandomAlphanumeric(); String recordName = "ERecord-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecord = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, recordName, CONTENT_TYPE); UnfiledContainerChild unfiledRecord = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, recordName, CONTENT_TYPE);
unfiledChildren.add(unfiledRecord);
assertNotNull(unfiledRecord.getId()); assertNotNull(unfiledRecord.getId());
assertTrue(unfiledRecord.getIsRecord()); assertTrue(unfiledRecord.getIsRecord());
@@ -322,11 +326,11 @@ public class UnfiledContainerTests extends BaseRMRestTest
( (
description = "Get children of the root unfiled root container" description = "Get children of the root unfiled root container"
) )
public void getUnfiledRootContainerChildren() throws Exception public void getUnfiledRootContainerChildren()
{ {
// Add unfiled root container children // Add unfiled root container children
List<UnfiledContainerChild> createdChildren = new LinkedList<>(); List<UnfiledContainerChild> createdChildren = new LinkedList<>();
for (int i=0; i < NUMBER_OF_CHILDREN; i++) for (int i = 0; i < NUMBER_OF_CHILDREN; i++)
{ {
String childType; String childType;
if (i % 3 == 0) if (i % 3 == 0)
@@ -367,9 +371,8 @@ public class UnfiledContainerTests extends BaseRMRestTest
{ {
// Get the element from the created children list // Get the element from the created children list
UnfiledContainerChild createdComponent = createdChildren.stream() UnfiledContainerChild createdComponent = createdChildren.stream()
.filter(child -> child.getId().equals(childId)) .filter(child -> child.getId().equals(childId))
.findFirst() .findFirst().orElseThrow();
.get();
// Created by // Created by
assertEquals(containerChild.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(containerChild.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -408,6 +411,7 @@ public class UnfiledContainerTests extends BaseRMRestTest
// check all the created elements have been returned // check all the created elements have been returned
assertTrue(verifiedChildren.containsAll(createdChildren)); assertTrue(verifiedChildren.containsAll(createdChildren));
assertTrue(createdChildren.containsAll(verifiedChildren)); assertTrue(createdChildren.containsAll(verifiedChildren));
unfiledChildren.addAll(createdChildren);
} }
/** /**
@@ -429,35 +433,28 @@ public class UnfiledContainerTests extends BaseRMRestTest
// Build unfiled records folder properties // Build unfiled records folder properties
UnfiledContainerChild unfiledFolderModel = createUnfiledContainerChildModel(unfiledRecordFolderName, filePlanComponentType); UnfiledContainerChild unfiledFolderModel = createUnfiledContainerChildModel(unfiledRecordFolderName, filePlanComponentType);
try getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
{
getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(unfiledFolderModel, UNFILED_RECORDS_CONTAINER_ALIAS);
}
catch (Exception error)
{
}
// Verify the status code // Verify the status code
assertStatusCode(UNPROCESSABLE_ENTITY); assertStatusCode(UNPROCESSABLE_ENTITY);
} }
@Test(description = "Create a record with custom record identifier in unfiled container") @Test(description = "Create a record with custom record identifier in unfiled container")
public void createRecordWithCustomIdentifier() throws Exception public void createRecordWithCustomIdentifier()
{ {
String recordName = "customIdRecord-" + getRandomAlphanumeric(); String recordName = "customIdRecord-" + getRandomAlphanumeric();
String customIdentifier = "customId"; String customIdentifier = "customId";
RecordProperties propertiesModel = RecordProperties.builder().identifier(customIdentifier).build(); UnfiledContainerChildProperties propertiesModel = UnfiledContainerChildProperties.builder().identifier(customIdentifier).build();
UnfiledContainerChild childModel = UnfiledContainerChild.builder() UnfiledContainerChild childModel = UnfiledContainerChild.builder()
.name(recordName) .name(recordName)
.nodeType(CONTENT_TYPE) .nodeType(CONTENT_TYPE)
.properties(UnfiledContainerChildProperties.builder() .properties(propertiesModel)
.identifier(customIdentifier) .build();
.build())
.build();
UnfiledContainerChild child = getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(childModel, UNFILED_RECORDS_CONTAINER_ALIAS); UnfiledContainerChild child = getRestAPIFactory().getUnfiledContainersAPI().createUnfiledContainerChild(childModel, UNFILED_RECORDS_CONTAINER_ALIAS);
assertStatusCode(HttpStatus.CREATED); assertStatusCode(HttpStatus.CREATED);
unfiledChildren.add(child);
assertEquals(child.getProperties().getIdentifier(), customIdentifier); assertEquals(child.getProperties().getIdentifier(), customIdentifier);
assertEquals(child.getName(), recordName + " (" + customIdentifier + ")"); assertEquals(child.getName(), recordName + " (" + customIdentifier + ")");
} }
@@ -465,18 +462,15 @@ public class UnfiledContainerTests extends BaseRMRestTest
@AfterClass (alwaysRun = true) @AfterClass (alwaysRun = true)
public void tearDown() public void tearDown()
{ {
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI() unfiledChildren.forEach(unfiledChild ->
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS);
listedChildren.getEntries().forEach(UnfiledContainerChildEntry ->
{ {
if (UnfiledContainerChildEntry.getEntry().getIsRecord()) if (unfiledChild.getIsRecord())
{ {
getRestAPIFactory().getRecordsAPI().deleteRecord(UnfiledContainerChildEntry.getEntry().getId()); getRestAPIFactory().getRecordsAPI().deleteRecord(unfiledChild.getId());
} }
else else
{ {
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(UnfiledContainerChildEntry.getEntry().getId()); getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledChild.getId());
} }
}); });
} }

View File

@@ -28,11 +28,9 @@ package org.alfresco.rest.rm.community.unfiledrecordfolders;
import static java.time.LocalDateTime.now; import static java.time.LocalDateTime.now;
import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_NAME;
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.TRANSFERS_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS;
.UNFILED_RECORDS_CONTAINER_ALIAS;
import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PATH;
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.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
@@ -40,6 +38,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile;
import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createUnfiledContainerChildModel;
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
import static org.alfresco.utility.data.RandomData.getRandomName;
import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.CREATED;
import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NOT_FOUND;
@@ -59,6 +58,7 @@ import java.util.stream.Collectors;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.base.DataProviderClass; import org.alfresco.rest.rm.community.base.DataProviderClass;
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChild;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildCollection;
import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties; import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledContainerChildProperties;
@@ -66,7 +66,7 @@ import org.alfresco.rest.rm.community.model.unfiledcontainer.UnfiledRecordFolder
import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI; import org.alfresco.rest.rm.community.requests.gscore.api.UnfiledRecordFolderAPI;
import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil; import org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterTest; import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider; import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@@ -78,13 +78,24 @@ import org.testng.annotations.Test;
*/ */
public class UnfiledRecordsFolderTests extends BaseRMRestTest public class UnfiledRecordsFolderTests extends BaseRMRestTest
{ {
public static final String ELECTRONIC_RECORD_NAME = "Record electronic" + getRandomAlphanumeric(); public static final String ELECTRONIC_RECORD_NAME = getRandomName("Record electronic");
public static final String NONELECTRONIC_RECORD_NAME = "Record nonelectronic" + getRandomAlphanumeric(); public static final String NONELECTRONIC_RECORD_NAME = getRandomName("Record nonelectronic");
private RecordCategory rootCategory;
private UnfiledContainerChild unfiledRecordFolder, rootUnfiledRecordFolder, unfiledRecord;
@BeforeClass(alwaysRun = true)
public void preconditionUnfiledRecordsFolderTests()
{
rootCategory = createRootCategory(getRandomName("CATEGORY NAME"));
rootUnfiledRecordFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
getRandomName("RootUnfiledRecFolder"), UNFILED_RECORD_FOLDER_TYPE);
unfiledRecord = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,
getRandomName("Unfiled Record"), CONTENT_TYPE);
}
/** /**
* valid root level types, at unfiled record folder level these possible to create * valid root level types, at unfiled record folder level these possible to create
*/ */
@DataProvider (name = "validChildren") @DataProvider (name = "validChildren")
public Object[][] childrenForUnfiledRecord() public Object[][] childrenForUnfiledRecord()
{ {
@@ -100,20 +111,20 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
* Invalid containers that cannot be updated/deleted with record folder endpoint * Invalid containers that cannot be updated/deleted with record folder endpoint
*/ */
@DataProvider (name = "invalidNodesForDelete") @DataProvider (name = "invalidNodesForDelete")
public Object[][] getInvalidNodes() throws Exception public Object[][] getInvalidNodes()
{ {
return new String[][] { return new String[][] {
{ getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId() }, { getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS).getId() },
{ getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() }, { getRestAPIFactory().getUnfiledContainersAPI().getUnfiledContainer(UNFILED_RECORDS_CONTAINER_ALIAS).getId() },
{ getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() }, { getRestAPIFactory().getTransferContainerAPI().getTransferContainer(TRANSFERS_ALIAS).getId() },
// an arbitrary record category // an arbitrary record category
{ createRootCategory(RECORD_CATEGORY_NAME + getRandomAlphanumeric()).getId() }, { rootCategory.getId() },
// an arbitrary unfiled records folder // an arbitrary unfiled records folder
{createCategoryFolderInFilePlan().getId()}, {createRecordFolder(rootCategory.getId(), getRandomName("recFolder")).getId()},
{createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Record " + getRandomAlphanumeric(), CONTENT_TYPE).getId() } {unfiledRecord.getId() }
}; };
} }
/** /**
* <pre> * <pre>
* Given that I want to create an unfiled record folder * Given that I want to create an unfiled record folder
@@ -127,49 +138,46 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
"Containers in the relativePath that do not exist are created before the node is created", "Containers in the relativePath that do not exist are created before the node is created",
dataProvider = "validChildren" dataProvider = "validChildren"
) )
public void createUnfiledRecordFolderWithRelativePath(String nodeType) throws Exception public void createUnfiledRecordFolderWithRelativePath(String nodeType)
{ {
String unfiledRecordFolderName1 = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild1 = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName1, UNFILED_RECORD_FOLDER_TYPE);
String unfiledRecordFolderName2 = "UnfiledRecordFolder-" + getRandomAlphanumeric();
// relativePath specify the container structure to create relative to the record folder to be created // relativePath specify the container structure to create relative to the record folder to be created
String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth(); String relativePath = now().getYear() + "/" + now().getMonth() + "/" + now().getDayOfMonth();
// The record folder to be created // The record folder to be created
UnfiledContainerChild unfiledChildModel =UnfiledContainerChild.builder() UnfiledContainerChild unfiledChildModel = UnfiledContainerChild.builder()
.name(unfiledRecordFolderName2) .name(getRandomName("UnfiledRecordFolder"))
.nodeType(nodeType) .nodeType(nodeType)
.relativePath(relativePath) .relativePath(relativePath)
.build(); .build();
UnfiledContainerChild unfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledChildModel, unfiledRecordFolderChild1.getId(), "include=" + PATH); UnfiledContainerChild unfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI()
.createUnfiledRecordFolderChild(unfiledChildModel, rootUnfiledRecordFolder.getId(), "include=" + PATH);
// Check the API response code // Check the API response code
assertStatusCode(CREATED); assertStatusCode(CREATED);
// Verify the returned node type // Verify the returned node type
assertTrue(nodeType.equals(unfiledRecordFolderChild.getNodeType())); assertEquals(unfiledRecordFolderChild.getNodeType(), nodeType);
// Check the path return contains the relativePath // Check the path return contains the relativePath
assertTrue(unfiledRecordFolderChild.getPath().getName().contains(relativePath)); assertTrue(unfiledRecordFolderChild.getPath().getName().contains(relativePath));
// Check the parent is a folder, not a record // Check the parent is a folder, not a record
assertTrue(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getParentId()).getNodeType().equals(UNFILED_RECORD_FOLDER_TYPE)); assertEquals(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(unfiledRecordFolderChild.getParentId()).getNodeType(),
UNFILED_RECORD_FOLDER_TYPE);
// New relative path only a part of containers need to be created before the record folder // New relative path only a part of containers need to be created before the record folder
String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1); String newRelativePath = now().getYear() + "/" + now().getMonth() + "/" + (now().getDayOfMonth() + 1);
String unfiledRecordFolderName3 = "UnfiledRecordFolder-" + getRandomAlphanumeric();
// The record folder to be created // The record folder to be created
UnfiledContainerChild newUnfiledFolderModel =UnfiledContainerChild.builder() UnfiledContainerChild newUnfiledFolderModel = UnfiledContainerChild.builder()
.name(unfiledRecordFolderName3) .name(getRandomName("UnfiledRecordFolder"))
.nodeType(nodeType) .nodeType(nodeType)
.relativePath(newRelativePath) .relativePath(newRelativePath)
.build(); .build();
UnfiledContainerChild newUnfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(newUnfiledFolderModel, unfiledRecordFolderChild1.getId(), "include=" + PATH); UnfiledContainerChild newUnfiledRecordFolderChild = getRestAPIFactory().getUnfiledRecordFoldersAPI()
.createUnfiledRecordFolderChild(newUnfiledFolderModel, rootUnfiledRecordFolder.getId(), "include=" + PATH);
// Check the API response code // Check the API response code
assertStatusCode(CREATED); assertStatusCode(CREATED);
@@ -180,8 +188,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
// Check the parent is a folder, not a record // Check the parent is a folder, not a record
assertFalse(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(newUnfiledRecordFolderChild.getParentId()).equals(UNFILED_RECORD_FOLDER_TYPE)); assertFalse(getRestAPIFactory().getUnfiledRecordFoldersAPI().getUnfiledRecordFolder(newUnfiledRecordFolderChild.getParentId()).equals(UNFILED_RECORD_FOLDER_TYPE));
// Verify the returned node type // Verify the returned node type
assertTrue(nodeType.equals(newUnfiledRecordFolderChild.getNodeType())); assertEquals(newUnfiledRecordFolderChild.getNodeType(), nodeType);
} }
/** /**
@@ -194,22 +201,13 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
dataProviderClass = DataProviderClass.class, dataProviderClass = DataProviderClass.class,
description = "Only unfiled records folders and records can be created as children for unfiled container root" description = "Only unfiled records folders and records can be created as children for unfiled container root"
) )
public void createInvalidUnfiledChildren(String filePlanComponentType) throws Exception public void createInvalidUnfiledChildren(String filePlanComponentType)
{ {
String unfiledRecordFolderName = "UnfiledRecordFolder-" + getRandomAlphanumeric();
UnfiledContainerChild unfiledRecordFolderChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, unfiledRecordFolderName, UNFILED_RECORD_FOLDER_TYPE);
logger.info("creating " + filePlanComponentType);
// Build unfiled records folder properties // Build unfiled records folder properties
UnfiledContainerChild unfiledFolderModel = createUnfiledContainerChildModel(unfiledRecordFolderName, filePlanComponentType); UnfiledContainerChild unfiledFolderModel = createUnfiledContainerChildModel(getRandomName("UnfiledRecFolder"), filePlanComponentType);
getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledFolderModel, rootUnfiledRecordFolder.getId());
try
{
getRestAPIFactory().getUnfiledRecordFoldersAPI().createUnfiledRecordFolderChild(unfiledFolderModel, unfiledRecordFolderChild.getId());
}
catch (Exception error)
{
}
// Verify the status code // Verify the status code
assertStatusCode(UNPROCESSABLE_ENTITY); assertStatusCode(UNPROCESSABLE_ENTITY);
} }
@@ -218,20 +216,15 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
* Given an unfiled record folder * Given an unfiled record folder
* When I create an unfiled record folder via the ReST API * When I create an unfiled record folder via the ReST API
* Then an unfiled record folder is created within the unfiled record folder * Then an unfiled record folder is created within the unfiled record folder
*
* @throws Exception for failed actions
*/ */
@Test(description = "Child unfiled records folder can be created in a parent unfiled records folder") @Test(description = "Child unfiled records folder can be created in a parent unfiled records folder")
public void childUnfiledRecordsFolderCanBeCreated() throws Exception public void childUnfiledRecordsFolderCanBeCreated()
{ {
String unfiledParentFolderName = "UnfiledParentFolder" + getRandomAlphanumeric(); String unfiledParentFolderName = "UnfiledParentFolder" + getRandomAlphanumeric();
String unfiledChildFolderName = "UnfiledChildFolder " + getRandomAlphanumeric(); String unfiledChildFolderName = "UnfiledChildFolder " + getRandomAlphanumeric();
String rootUnfiledFolderName = "RootUnfiledFolder" + getRandomAlphanumeric();
//create root unfiled record folder
UnfiledContainerChild createUnfiledContainerChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, rootUnfiledFolderName, UNFILED_RECORD_FOLDER_TYPE);
// No need for fine control, create it using utility function // No need for fine control, create it using utility function
UnfiledContainerChild unfiledParentFolder = createUnfiledRecordsFolderChild(createUnfiledContainerChild.getId(), UnfiledContainerChild unfiledParentFolder = createUnfiledRecordsFolderChild(rootUnfiledRecordFolder.getId(),
unfiledParentFolderName, UNFILED_RECORD_FOLDER_TYPE); unfiledParentFolderName, UNFILED_RECORD_FOLDER_TYPE);
assertEquals(unfiledParentFolderName, unfiledParentFolder.getName()); assertEquals(unfiledParentFolderName, unfiledParentFolder.getName());
@@ -291,20 +284,15 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
* Given an unfiled record folder * Given an unfiled record folder
* When I modify the unfiled record folder details via the ReST API * When I modify the unfiled record folder details via the ReST API
* Then the details of the unfiled record folder are modified * Then the details of the unfiled record folder are modified
*
* @throws Exception for failed actions
*/ */
@Test(description = "Unfiled record folder") @Test(description = "Unfiled record folder")
public void editUnfiledRecordsFolder() throws Exception public void editUnfiledRecordsFolder()
{ {
String modified = "Modified "; String modified = "Modified ";
String unfiledFolderName = "UnfiledFolderToModify" + getRandomAlphanumeric(); String unfiledFolderName = "UnfiledFolderToModify" + getRandomAlphanumeric();
String rootUnfiledFolderName = "RootUnfiledFolder" + getRandomAlphanumeric();
//create root unfiledRecordFolder
UnfiledContainerChild createUnfiledContainerChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS,rootUnfiledFolderName, UNFILED_RECORD_FOLDER_TYPE);
// No need for fine control, create it using utility function // No need for fine control, create it using utility function
UnfiledContainerChild unfiledFolderToModify = createUnfiledRecordsFolderChild(createUnfiledContainerChild.getId(), UnfiledContainerChild unfiledFolderToModify = createUnfiledRecordsFolderChild(rootUnfiledRecordFolder.getId(),
unfiledFolderName, UNFILED_RECORD_FOLDER_TYPE); unfiledFolderName, UNFILED_RECORD_FOLDER_TYPE);
assertEquals(unfiledFolderName, unfiledFolderToModify.getName()); assertEquals(unfiledFolderName, unfiledFolderToModify.getName());
@@ -348,33 +336,28 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
* Given an unfiled record folder and some records inside * Given an unfiled record folder and some records inside
* When I delete the unfiled record folder via the ReST API * When I delete the unfiled record folder via the ReST API
* Then the unfiled record folder is deleted and its content too * Then the unfiled record folder is deleted and its content too
*
* @throws Exception for failed actions
*/ */
@Test(description = "Delete unfiled record folder") @Test(description = "Delete unfiled record folder")
public void deleteUnfiledRecordsFolder() throws Exception public void deleteUnfiledRecordsFolder()
{ {
String unfiledFolderName = "UnfiledFolderToDelete" + getRandomAlphanumeric(); String unfiledFolderName = "UnfiledFolderToDelete" + getRandomAlphanumeric();
String nonElectronicRecordName = "NonElectronicRecord" + getRandomAlphanumeric(); String nonElectronicRecordName = "NonElectronicRecord" + getRandomAlphanumeric();
String electronicRecordName = "ElectronicRecord" + getRandomAlphanumeric(); String electronicRecordName = "ElectronicRecord" + getRandomAlphanumeric();
String rootUnfiledFolderName = "RootUnfiledFolder" + getRandomAlphanumeric();
//create root unfiled record folder
UnfiledContainerChild createUnfiledContainerChild = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, rootUnfiledFolderName, UNFILED_RECORD_FOLDER_TYPE);
// Create unfiledFolderToDelete // Create unfiledFolderToDelete
UnfiledContainerChild unfiledFolderToDelete = createUnfiledRecordsFolderChild(createUnfiledContainerChild.getId(), UnfiledContainerChild unfiledFolderToDelete = createUnfiledRecordsFolderChild(rootUnfiledRecordFolder.getId(),
unfiledFolderName, UNFILED_RECORD_FOLDER_TYPE); unfiledFolderName, UNFILED_RECORD_FOLDER_TYPE);
assertEquals(unfiledFolderName, unfiledFolderToDelete.getName()); assertEquals(unfiledFolderName, unfiledFolderToDelete.getName());
// Create a non electronic record under unfiledFolderToDelete // Create a non electronic record under unfiledFolderToDelete
UnfiledContainerChild nonElectronicRecord = createUnfiledRecordsFolderChild(unfiledFolderToDelete.getId(), UnfiledContainerChild nonElectronicRecord = createUnfiledRecordsFolderChild(unfiledFolderToDelete.getId(),
nonElectronicRecordName, NON_ELECTRONIC_RECORD_TYPE); nonElectronicRecordName, NON_ELECTRONIC_RECORD_TYPE);
assertTrue(nonElectronicRecord.getParentId().equals(unfiledFolderToDelete.getId())); assertEquals(nonElectronicRecord.getParentId(), unfiledFolderToDelete.getId());
// Create an electronic record under unfiledFolderToDelete // Create an electronic record under unfiledFolderToDelete
UnfiledContainerChild electronicRecord = createUnfiledRecordsFolderChild(unfiledFolderToDelete.getId(), UnfiledContainerChild electronicRecord = createUnfiledRecordsFolderChild(unfiledFolderToDelete.getId(),
electronicRecordName, CONTENT_TYPE); electronicRecordName, CONTENT_TYPE);
assertTrue(electronicRecord.getParentId().equals(unfiledFolderToDelete.getId())); assertEquals(electronicRecord.getParentId(), unfiledFolderToDelete.getId());
// Delete folderToDelete // Delete folderToDelete
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledFolderToDelete.getId()); getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledFolderToDelete.getId());
@@ -399,11 +382,10 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
description = "Delete invalid nodes type with the DELETE unfiled record folders request", description = "Delete invalid nodes type with the DELETE unfiled record folders request",
dataProvider = "invalidNodesForDelete" dataProvider = "invalidNodesForDelete"
) )
public void deleteInvalidNodesUnfiled(String nodeId) throws Exception public void deleteInvalidNodesUnfiled(String nodeId)
{ {
// Delete the nodes with record-folders end-point // Delete the nodes with record-folders end-point
UnfiledRecordFolderAPI unfiledFolderAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(nodeId);
unfiledFolderAPI.deleteUnfiledRecordFolder(nodeId);
// Check the response status code // Check the response status code
assertStatusCode(BAD_REQUEST); assertStatusCode(BAD_REQUEST);
@@ -415,29 +397,26 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
* Then I receive a list of all the records contained within the unfiled record folder * Then I receive a list of all the records contained within the unfiled record folder
*/ */
@Test @Test
public void readRecordsFromUnfiledRecordFolder() throws Exception public void readRecordsFromUnfiledRecordFolder()
{ {
final int NUMBER_OF_RECORDS = 5; unfiledRecordFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, getRandomName("UnfiledRecordFolder"), UNFILED_RECORD_FOLDER_TYPE);
String containerId = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE).getId(); String containerId = unfiledRecordFolder.getId();
//we have unfiled record folder //we have unfiled record folder
UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI(); UnfiledRecordFolderAPI unfiledRecordFoldersAPI = getRestAPIFactory().getUnfiledRecordFoldersAPI();
// Create Electronic Records
ArrayList<UnfiledContainerChild> children = new ArrayList<UnfiledContainerChild>(); ArrayList<UnfiledContainerChild> children = new ArrayList<>();
for (int i = 0; i < NUMBER_OF_RECORDS; i++) for (int i = 0; i < 5; i++)
{ {
//build the electronic record // Create Electronic Records
UnfiledContainerChild record = UnfiledContainerChild.builder() UnfiledContainerChild record = UnfiledContainerChild.builder()
.name(ELECTRONIC_RECORD_NAME + i) .name(ELECTRONIC_RECORD_NAME + i)
.nodeType(CONTENT_TYPE) .nodeType(CONTENT_TYPE)
.build(); .build();
//create a child
UnfiledContainerChild child = unfiledRecordFoldersAPI.uploadRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i)); UnfiledContainerChild child = unfiledRecordFoldersAPI.uploadRecord(record, containerId, createTempFile(ELECTRONIC_RECORD_NAME + i, ELECTRONIC_RECORD_NAME + i));
children.add(child); children.add(child);
}
//Create NonElectronicRecords //Create NonElectronicRecords
for (int i = 0; i < NUMBER_OF_RECORDS; i++)
{
UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder() UnfiledContainerChild nonelectronicRecord = UnfiledContainerChild.builder()
.properties(UnfiledContainerChildProperties.builder() .properties(UnfiledContainerChildProperties.builder()
.description("Description") .description("Description")
@@ -446,9 +425,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
.name(NONELECTRONIC_RECORD_NAME + i) .name(NONELECTRONIC_RECORD_NAME + i)
.nodeType(NON_ELECTRONIC_RECORD_TYPE) .nodeType(NON_ELECTRONIC_RECORD_TYPE)
.build(); .build();
//create records child = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, containerId);
UnfiledContainerChild child = unfiledRecordFoldersAPI.createUnfiledRecordFolderChild(nonelectronicRecord, containerId);
children.add(child); children.add(child);
} }
@@ -472,7 +449,7 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
UnfiledContainerChild createdComponent = children.stream() UnfiledContainerChild createdComponent = children.stream()
.filter(child -> child.getId().equals(record.getId())) .filter(child -> child.getId().equals(record.getId()))
.findFirst() .findFirst()
.get(); .orElseThrow();
// Created by // Created by
assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername()); assertEquals(record.getCreatedByUser().getId(), getAdminUser().getUsername());
@@ -485,9 +462,8 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
assertFalse(record.getIsUnfiledRecordFolder()); assertFalse(record.getIsUnfiledRecordFolder());
//check the record name //check the record name
assertTrue(record.getName().equals(createdComponent.getName()), assertEquals(createdComponent.getName(), record.getName(),
"The record name "+ record.getName()+" is not equal with the record name returned when creating the record " + createdComponent "The record name " + record.getName() + " is not equal with the record name returned when creating the record " + createdComponent.getName());
.getName());
String identifier = " \\(" + record.getProperties().getIdentifier() + "\\)"; String identifier = " \\(" + record.getProperties().getIdentifier() + "\\)";
String regex= "(" + NONELECTRONIC_RECORD_NAME + "|" + ELECTRONIC_RECORD_NAME + ")" + "[0-9]+" + identifier; String regex= "(" + NONELECTRONIC_RECORD_NAME + "|" + ELECTRONIC_RECORD_NAME + ")" + "[0-9]+" + identifier;
assertTrue(record.getName().matches(regex), assertTrue(record.getName().matches(regex),
@@ -502,24 +478,13 @@ public class UnfiledRecordsFolderTests extends BaseRMRestTest
} }
}); });
} }
@AfterTest
@AfterClass (alwaysRun = true)
public void tearDown() throws Exception
{
UnfiledContainerChildCollection listedChildren = getRestAPIFactory().getUnfiledContainersAPI()
.getUnfiledContainerChildren(UNFILED_RECORDS_CONTAINER_ALIAS);
listedChildren.getEntries().forEach(UnfiledContainerChildEntry -> @AfterClass (alwaysRun = true)
{ public void tearDown()
if (UnfiledContainerChildEntry.getEntry().getIsRecord()) {
{ deleteRecordCategory(rootCategory.getId());
getRestAPIFactory().getRecordsAPI().deleteRecord(UnfiledContainerChildEntry.getEntry().getId()); getRestAPIFactory().getRecordsAPI().deleteRecord(unfiledRecord.getId());
} getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(rootUnfiledRecordFolder.getId());
else getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledRecordFolder.getId());
{
getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(UnfiledContainerChildEntry.getEntry().getId());
}
});
} }
} }

View File

@@ -63,7 +63,6 @@ public class CoreUtil
* Helper method to create a Content Model * Helper method to create a Content Model
* *
* @return ContentModel * @return ContentModel
* @throws Exception
*/ */
public static ContentModel toContentModel(String nodeId) public static ContentModel toContentModel(String nodeId)
{ {
@@ -74,7 +73,6 @@ public class CoreUtil
* Helper method to create a File Model * Helper method to create a File Model
* *
* @return ContentModel * @return ContentModel
* @throws Exception
*/ */
public static FileModel toFileModel(String nodeId) public static FileModel toFileModel(String nodeId)
{ {

View File

@@ -70,7 +70,7 @@ public class RMSiteUtil
* @param compliance The RM site compliance * @param compliance The RM site compliance
* @return The {@link RMSite} with the given details * @return The {@link RMSite} with the given details
*/ */
private static RMSite createRMSiteModel(RMSiteCompliance compliance) public static RMSite createRMSiteModel(RMSiteCompliance compliance)
{ {
return createRMSiteModel(compliance, RM_TITLE, RM_DESCRIPTION); return createRMSiteModel(compliance, RM_TITLE, RM_DESCRIPTION);
} }

View File

@@ -1,9 +1,121 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="300000"> <suite name="TestNG AllTestSuite" configfailurepolicy="continue" verbose="1" time-out="600000">
<test name="restapi"> <test name="Before suite" >
<!-- These tests are meant to run first, because they all clear the audit log and can't run in parallel. -->
<packages> <packages>
<package name="org.alfresco.rest.rm.community.*"/> <package name="org.alfresco.rest.rm.community.audit.*"/>
</packages> </packages>
<classes>
<!-- This test fails intermittently when is run in parallel. see APPS-132 -->
<class name="org.alfresco.rest.rm.community.records.UpdateRecordsTests" >
<methods>
<include name="completeRecordsCantBeUpdated" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.records.ReadRecordTests" >
<methods>
<include name="readRecordContent" />
</methods>
</class>
<!-- These tests fail intermittently when are run in parallel because they interact a lot with Unfiled Records
container -->
<class name="org.alfresco.rest.rm.community.unfiledrecordfolders.UnfiledRecordsFolderTests" />
<class name="org.alfresco.rest.rm.community.records.FileRecordsTests" />
<!-- These tests are meant to run first, because they interact with alfresco logs and can't run in parallel -->
<class name="org.alfresco.rest.rm.community.files.DeclareAndFileDocumentAsRecordTests" />
<class name="org.alfresco.rest.rm.community.files.FileVersionAsRecordTests">
<methods>
<include name="declareVersionAndFileToInvalidLocationUsingActionsAPI"/>
</methods>
</class>
<!-- This test is meant to run first, because it needs a static number of categories in the fileplan and can't
run in parallel -->
<class name="org.alfresco.rest.rm.community.recordcategories.RecordCategoryTests">
<methods>
<include name="deleteCategory" />
</methods>
</class>
</classes>
</test> </test>
</suite> <!-- These tests can run in parallel -->
<test name="Parallel Tests Suite" parallel="classes" thread-count="2">
<packages>
<package name="org.alfresco.rest.rm.community.*">
<exclude name="org.alfresco.rest.rm.community.audit.*"/>
</package>
</packages>
<classes>
<class name="org.alfresco.rest.rm.community.files.DeclareAndFileDocumentAsRecordTests">
<methods>
<exclude name=".*" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.files.FileVersionAsRecordTests">
<methods>
<exclude name="declareVersionAndFileToInvalidLocationUsingActionsAPI"/>
</methods>
</class>
<class name="org.alfresco.rest.rm.community.recordcategories.RecordCategoryTests">
<methods>
<exclude name="deleteCategory" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.unfiledrecordfolders.UnfiledRecordsFolderTests">
<methods>
<exclude name=".*" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.records.FileRecordsTests">
<methods>
<exclude name=".*" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.records.UpdateRecordsTests" >
<methods>
<exclude name="completeRecordsCantBeUpdated" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.records.ReadRecordTests" >
<methods>
<exclude name="readRecordContent" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.records.CompleteRecordTests">
<methods>
<exclude name="completeRecordWithMandatoryMetadataMissing" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.site.RMSiteTests">
<methods>
<exclude name=".*" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.fileplans.FilePlanTests">
<methods>
<!-- deletes all categories -->
<exclude name="listFilePlanChildren" />
<exclude name="getFilePlanWhenRMIsNotCreated" />
</methods>
</class>
</classes>
</test>
<!-- These tests are meant to run last, because they delete rm site and can't run in parallel -->
<test name="After suite">
<classes>
<class name="org.alfresco.rest.rm.community.records.CompleteRecordTests">
<methods>
<include name="completeRecordWithMandatoryMetadataMissing" />
</methods>
</class>
<class name="org.alfresco.rest.rm.community.site.RMSiteTests"/>
<class name="org.alfresco.rest.rm.community.fileplans.FilePlanTests" >
<methods>
<include name="listFilePlanChildren" />
<include name="getFilePlanWhenRMIsNotCreated"/>
</methods>
</class>
</classes>
</test>
</suite>