mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
"MoveToRuleOnFoldersTest added metadata update and and copy of records"[ags]
This commit is contained in:
@@ -1,7 +1,34 @@
|
||||
/*
|
||||
* #%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 <http://www.gnu.org/licenses/>.
|
||||
* #L%
|
||||
*/
|
||||
package org.alfresco.rest.rm.community.rules;
|
||||
|
||||
import org.alfresco.rest.model.RestNodeModel;
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.fileplan.FilePlan;
|
||||
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;
|
||||
@@ -16,6 +43,7 @@ import org.alfresco.rest.v0.RulesAPI;
|
||||
import org.alfresco.rest.v0.service.RoleService;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@@ -23,7 +51,9 @@ import java.util.Collections;
|
||||
import java.util.Random;
|
||||
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.NODE_PREFIX;
|
||||
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.util.CommonTestUtils.generateTestPrefix;
|
||||
import static org.alfresco.rest.rm.community.utils.CoreUtil.createBodyForMoveCopy;
|
||||
@@ -32,8 +62,7 @@ import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.*;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
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.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.http.HttpStatus.*;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
|
||||
@@ -48,7 +77,8 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
private UnfiledContainer unfiledContainer;
|
||||
|
||||
private UserModel rmAdmin;
|
||||
private RecordCategory RecordCategoryOne;
|
||||
public RecordCategory RecordCategoryOne;
|
||||
public RestNodeModel RecordCategoryCopy;
|
||||
private RecordCategoryChild recordFolder;
|
||||
public static final String RECORD_FOLDER_ONE = "record-folder-one";
|
||||
private final String TEST_PREFIX = generateTestPrefix(MoveToRuleOnFoldersTest.class);
|
||||
@@ -67,7 +97,7 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private RecordsAPI recordsAPI;
|
||||
public RecordsAPI recordsAPI;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void precondition()
|
||||
@@ -95,15 +125,6 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
STEP("Check the electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// // Generate update metadata
|
||||
// String newName = getModifiedPropertyValue(electronicRecord.getName());
|
||||
// String newTitle = getModifiedPropertyValue(electronicRecord.getProperties().getTitle());
|
||||
// String newDescription = getModifiedPropertyValue(electronicRecord.getProperties().getDescription());
|
||||
//
|
||||
// // Update record:EDIT electronic and non electronic metadata [PENDING]
|
||||
//
|
||||
//// recordsAPI.updateRecord(createRecordModel(newName, newDescription, newTitle), electronicRecord.getId());
|
||||
//// assertStatusCode(OK);
|
||||
|
||||
|
||||
STEP("Create a non-electronic record by completing some of the fields");
|
||||
@@ -126,12 +147,22 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
STEP("Check the non-electronic record has been created");
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
// STEP("Create Copy of RootRecord");
|
||||
// RestNodeModel RootCategoryCopy = getRestAPIFactory()
|
||||
// .getNodeAPI(toContentModel(RecordCategoryOne.getId()))
|
||||
// .copy(createBodyForMoveCopy(RecordCategoryOne.getId()));
|
||||
// assertStatusCode(CREATED);
|
||||
// RestNodeModel RootCategoryCopy= getRestAPIFactory().getNodeAPI(toContentModel(RecordCategoryOne.getId())).copy(createBodyForMoveCopy(RecordCategoryOne.getId()));
|
||||
STEP("Update metadata for Non-Electronic Record");
|
||||
org.alfresco.rest.rm.community.requests.gscore.api.RecordsAPI recordsAPI = getRestAPIFactory().getRecordsAPI();
|
||||
Record nonelecrecord = recordsAPI.getRecord(nonElectronicId);
|
||||
String nonelecnewName = getModifiedPropertyValue(nonElectrinicRecordModel.getName());
|
||||
String nonelecnewTitle = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getTitle());
|
||||
String nonelecnewDescription = getModifiedPropertyValue(nonElectrinicRecordModel.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(nonelecnewName, nonelecnewDescription, nonelecnewTitle),nonelecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
STEP("Update metadata for Electronic Record");
|
||||
Record elecrecord = recordsAPI.getRecord(electronicRecord.getId());
|
||||
String elecnewName = getModifiedPropertyValue(electronicRecord.getName());
|
||||
String elecnewTitle = getModifiedPropertyValue(electronicRecord.getProperties().getTitle());
|
||||
String elecnewDescription = getModifiedPropertyValue(electronicRecord.getProperties().getDescription());
|
||||
recordsAPI.updateRecord(createRecordModel(elecnewName, elecnewDescription, elecnewTitle),elecrecord.getId());
|
||||
assertStatusCode(OK);
|
||||
|
||||
STEP("Create the folder2 inside the rootCategory");
|
||||
recordFolder2 = createFolder(getAdminUser(),RecordCategoryOne.getId(),getRandomName("recFolder"));
|
||||
@@ -160,6 +191,23 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{
|
||||
.move(createBodyForMoveCopy(recordFolder2.getId()));
|
||||
assertStatusCode(OK);
|
||||
|
||||
|
||||
STEP("Create Copy of RootRecord");
|
||||
FilePlan filePlan = getRestAPIFactory().getFilePlansAPI().getFilePlan(FILE_PLAN_ALIAS);
|
||||
RecordCategoryCopy=getRestAPIFactory().getNodeAPI(toContentModel(RecordCategoryOne.getId())).copy(createBodyForMoveCopy(filePlan.getId()));
|
||||
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanMoveToRuleOnFoldersTest()
|
||||
{
|
||||
deleteRecordCategory(RecordCategoryOne.getId());
|
||||
|
||||
// Delete record and verify status
|
||||
System.out.println(RecordCategoryCopy);
|
||||
// recordsAPI.deleteRecord(RecordCategoryCopy.getName(),RecordCategoryCopy.);
|
||||
// assertStatusCode(NO_CONTENT);
|
||||
getDataUser().deleteUser(rmAdmin);
|
||||
}
|
||||
|
||||
private String getModifiedPropertyValue(String originalValue) {
|
||||
|
Reference in New Issue
Block a user