From f49b7a393fed00237705e4fb56500c86cb085eba Mon Sep 17 00:00:00 2001 From: ashiva Date: Fri, 4 Nov 2022 08:20:04 +0000 Subject: [PATCH 1/3] "MoveToRuleOnFoldersTest added rule and folder creation" --- .../rules/MoveToRuleOnFoldersTest.java | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java index 49540e65d0..4164ab78cc 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java @@ -41,7 +41,7 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{ private String unfiledRecordsNodeRef; - private String recordFolder2; + private RecordCategoryChild recordFolder2; private String nonElectronicId; private Record electronicRecord; @@ -95,21 +95,19 @@ 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); +// // 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); - - //create non electronic record STEP("Create a non-electronic record by completing some of the fields"); - // Use these properties for non-electronic record to be created + // Use these properties for non-electronic record to be created String title = "Title " + getRandomAlphanumeric(); String description = "Description " + getRandomAlphanumeric(); String box = "Box "+ getRandomAlphanumeric(); @@ -125,34 +123,41 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{ Record nonElectrinicRecordModel = createFullNonElectronicRecordModel(name, title, description, box, file, shelf, storageLocation, numberOfCopies, physicalSize); // Create non-electronic record nonElectronicId = recordFolderAPI.createRecord(nonElectrinicRecordModel, recordFolder1).getId(); -// STEP("Check the non-electronic record has been created"); + STEP("Check the non-electronic record has been created"); assertStatusCode(CREATED); - // move the electronic and nonelectronic record from folder1 to folder2 - STEP("Create the record folder2 inside the rootCategory"); - recordFolder2 = createCategoryFolderInFilePlan().getId(); +// 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())); -// //create a rule for completing record for folder 2 + STEP("Create the folder2 inside the rootCategory"); + recordFolder2 = createFolder(getAdminUser(),RecordCategoryOne.getId(),getRandomName("recFolder")); + + STEP("create a rule MOVE_TO for folder 2"); RuleDefinition ruleDefinition = RuleDefinition.createNewRule().title("name").description("description1") - .applyToChildren(true).title(title) - .actions(Collections.singletonList(ActionsOnRule.COMPLETE_RECORD.getActionValue())); - rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder2, ruleDefinition); - + .runInBackground(true).title(title) + .actions(Collections.singletonList(ActionsOnRule.MOVE_TO.getActionValue())); + rulesAPI.createRule(getAdminUser().getUsername(), getAdminUser().getPassword(), NODE_PREFIX +recordFolder2.getId() , ruleDefinition); } + @Test public void MoveToRuleFoldersTest() - { STEP("Move electronic record from folder1 to folder2"); + { + STEP("Move electronic record from folder1 to folder2"); RestNodeModel electronicDocRestNodeModel = getRestAPIFactory() .getNodeAPI(toContentModel(electronicRecord.getId())) - .move(createBodyForMoveCopy(recordFolder2)); + .move(createBodyForMoveCopy(recordFolder2.getId())); assertStatusCode(OK); STEP("Move non-electronic record from folder1 to folder2"); RestNodeModel nonelectronicDocRestNodeModel = getRestAPIFactory() .getNodeAPI(toContentModel(nonElectronicId)) - .move(createBodyForMoveCopy(recordFolder2)); + .move(createBodyForMoveCopy(recordFolder2.getId())); assertStatusCode(OK); } @@ -162,6 +167,5 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{ String MODIFIED_PREFIX = "modified_"; return MODIFIED_PREFIX + originalValue; } - } - +} From f55602842d7cf15347bfd370a8c729730cdf85dc Mon Sep 17 00:00:00 2001 From: ashiva Date: Fri, 4 Nov 2022 15:32:37 +0000 Subject: [PATCH 2/3] "MoveToRuleOnFoldersTest added metadata update and and copy of records"[ags] --- .../rules/MoveToRuleOnFoldersTest.java | 86 +++++++++++++++---- 1 file changed, 67 insertions(+), 19 deletions(-) diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java index 4164ab78cc..8187b82cb9 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java @@ -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 . + * #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) { From 03ce7e37d4172391f55da63c6210274053dd7a79 Mon Sep 17 00:00:00 2001 From: ashiva Date: Fri, 4 Nov 2022 15:39:08 +0000 Subject: [PATCH 3/3] "MoveToRuleOnFoldersTest added metadata update and and copy of records"[ags] --- .../rest/rm/community/rules/MoveToRuleOnFoldersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java index 8187b82cb9..5ed4228600 100644 --- a/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java +++ b/amps/ags/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/rules/MoveToRuleOnFoldersTest.java @@ -204,7 +204,7 @@ public class MoveToRuleOnFoldersTest extends BaseRMRestTest{ deleteRecordCategory(RecordCategoryOne.getId()); // Delete record and verify status - System.out.println(RecordCategoryCopy); + // recordsAPI.deleteRecord(RecordCategoryCopy.getName(),RecordCategoryCopy.); // assertStatusCode(NO_CONTENT); getDataUser().deleteUser(rmAdmin);