diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java index be0fca0b6d..04b321664b 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordFoldersAPI.java @@ -73,4 +73,5 @@ public class RecordFoldersAPI extends BaseAPI } return null; } + } diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java index d818eca9bb..037476d52f 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java @@ -114,11 +114,11 @@ public class RecordsAPI extends BaseAPI /** * Reject the record given as parameter * - * @param user the user declaring the document as record - * @param password the user's password + * @param user the user declaring the document as record + * @param password the user's password * @param expectedStatusCode The expected return status code. - * @param recordName the record name - * @param reason reject reason + * @param recordName the record name + * @param reason reject reason * @return The HTTP Response. * @throws AssertionError If the expectedStatusCode was not returned. */ @@ -129,8 +129,8 @@ public class RecordsAPI extends BaseAPI JSONObject requestParams = new JSONObject(); requestParams.put("name", "reject"); requestParams.put("nodeRef", recNodeRef); - requestParams.put("params",new JSONObject() - .put("reason",reason)); + requestParams.put("params", new JSONObject() + .put("reason", reason)); return doPostJsonRequest(user, password, expectedStatusCode, requestParams, RM_ACTIONS_API); } @@ -221,6 +221,7 @@ public class RecordsAPI extends BaseAPI * Uploads an electronic record *

* eg. of usage for creating record directly in Unfiled Records : uploadElectronicRecord(getAdminName(), getAdminPassword(), recordPropertiesStringMap, UNFILED_RECORDS_BREADCRUMB, DocumentType.HTML) + * * @param username the username * @param password the password * @param properties a map of record properties and their values @@ -241,6 +242,7 @@ public class RecordsAPI extends BaseAPI *

  • eg. of usage in the case in which the record is inside a folder in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, "unfiled records folder"); *
  • eg. of usage in the case in which the record is created directly in Unfiled Records : deleteRecord(getAdminName(), getAdminPassword(), "f1 (2016-1472716888713)", UNFILED_RECORDS_BREADCRUMB, ""); * + * * @param username user's username * @param password its password * @param recordName the record name @@ -267,7 +269,7 @@ public class RecordsAPI extends BaseAPI * @param recordName the String with which the record name starts * @return the record object in case it exists, null otherwise */ - private CmisObject getRecord(String username, String password, String folderName, String recordName) + public CmisObject getRecord(String username, String password, String folderName, String recordName) { for (CmisObject record : contentService.getFolderObject(contentService.getCMISSession(username, password), RM_SITE_ID, folderName).getChildren()) { @@ -328,9 +330,9 @@ public class RecordsAPI extends BaseAPI /** * Hide in place record * - * @param user the user - * @param password the user's password - * @param nodeId the in place record node id + * @param user the user + * @param password the user's password + * @param nodeId the in place record node id * @return The HTTP Response. */ public HttpResponse hideRecord(String user, String password, String nodeId) @@ -344,6 +346,7 @@ public class RecordsAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, ACTIONS_API); } + /** * Retrieves the record's nodeRef * diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CreateNonElectronicRecordsTests.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CreateNonElectronicRecordsTests.java new file mode 100644 index 0000000000..49e7a3b7f5 --- /dev/null +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/records/CreateNonElectronicRecordsTests.java @@ -0,0 +1,139 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2022 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.rest.rm.community.records; + +import static org.alfresco.rest.rm.community.util.CommonTestUtils.generateTestPrefix; +import static org.alfresco.utility.data.RandomData.getRandomName; +import static org.alfresco.utility.report.log.Step.STEP; +import static org.springframework.http.HttpStatus.CREATED; +import static org.testng.Assert.assertNotNull; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.rest.core.v0.BaseAPI.RMProperty; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategoryChild; +import org.alfresco.rest.v0.RMRolesAndActionsAPI; +import org.alfresco.rest.v0.RecordsAPI; +import org.alfresco.test.AlfrescoTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Contains CreateNonElectronicRecords test which checks creation and basic actions(view details, edit, move, copy, delete) on non-electronic records + *

    + * Precondition: + *

    + * RM site created, contains category 1 with folder 1 and folder 2 inside it + *

    + * RM user has RM admin role + * + * @author Shubham Jain + * @Since 7.2.0 M2 + */ +public class CreateNonElectronicRecordsTests extends BaseRMRestTest +{ + private RecordCategory rootCategory; + + private RecordCategoryChild recordFolder; + + /** + * data prep services + */ + @Autowired + private RMRolesAndActionsAPI rmRolesAndActionsAPI; + + @Autowired + private RecordsAPI recordsAPI; + + private final String TEST_PREFIX = generateTestPrefix(CreateNonElectronicRecordsTests.class); + private final String RM_ADMIN = TEST_PREFIX + "rm_admin"; + private final String recordName = "RM-2777 record"; + private final String recordTitle = recordName + " title"; + private final String recordDescription = recordName + " description"; + + + @BeforeClass (alwaysRun = true) + public void preConditions() + { + STEP("Create RM Site"); + createRMSiteIfNotExists(); + + STEP("Create RM Admin user"); + rmRolesAndActionsAPI.createUserAndAssignToRole(getAdminUser().getUsername(), getAdminUser().getPassword(), RM_ADMIN, + getAdminUser().getPassword(), + "Administrator"); + + STEP("Create root level category"); + rootCategory = createRootCategory(getRandomName("Category")); + + STEP("Create the record folder inside the rootCategory"); + recordFolder = createRecordFolder(rootCategory.getId(), getRandomName("Folder")); + + } + + /** + * Test v0 methods to create and get non-electronic records. + */ + @Test + @AlfrescoTest (jira = "RM-2777") + public void createNonElectronicRecordTest() + { + STEP("Create a non-electronic record by completing some of the fields"); + Map, String> properties = new HashMap, String>(); + properties.put(RMProperty.TITLE, recordTitle); + properties.put(RMProperty.DESCRIPTION, recordDescription); + properties.put(RMProperty.NAME, recordName); + properties.put(RMProperty.PHYSICAL_SIZE, ""); + properties.put(RMProperty.NUMBER_OF_COPIES, ""); + properties.put(RMProperty.SHELF, ""); + properties.put(RMProperty.STORAGE_LOCATION, ""); + properties.put(RMProperty.BOX, ""); + properties.put(RMProperty.FILE, ""); + + recordsAPI.createNonElectronicRecord(getAdminUser().getUsername(), + getAdminUser().getPassword(), properties, rootCategory.getName(), recordFolder.getName()); + + STEP("Check the non-electronic record has been created"); + assertStatusCode(CREATED); + assertNotNull(recordsAPI.getRecord(getAdminUser().getUsername(), getAdminUser().getPassword(), + recordFolder.getName(), recordName)); + + } + + @AfterClass (alwaysRun = true) + public void deletePreConditions() + { + STEP("Delete the created rootCategory along with corresponding record folders/records present in it"); + getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(rootCategory.getId()); + } + +}