From 47d3f91abc0edcfc9651ecf38dc370631a75c512 Mon Sep 17 00:00:00 2001 From: cagache Date: Thu, 27 Sep 2018 12:40:04 +0300 Subject: [PATCH 1/8] MNT-19967 Get record disposition schedule from first parent category which has one --- .../disposition/DispositionServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java index 8b5774bf07..95e3e9825c 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/disposition/DispositionServiceImpl.java @@ -348,9 +348,6 @@ public class DispositionServiceImpl extends ServiceBaseImpl return ds; } - - - /** * This method returns a NodeRef * Gets the disposition instructions @@ -383,7 +380,7 @@ public class DispositionServiceImpl extends ServiceBaseImpl NodeRef result = getAssociatedDispositionScheduleImpl(parent); if (result == null) { - return null; + return getOriginDispositionSchedule(parent); } return new DispositionScheduleImpl(serviceRegistry, nodeService, result); } From c5cffb8cda0884e6eef8d2570f26e8380d0f527e Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 28 Sep 2018 08:23:11 +0300 Subject: [PATCH 2/8] Automated test for disposition schedule inheritance --- .../alfresco/rest/v0/RecordCategoriesAPI.java | 16 +++ .../service/DispositionScheduleService.java | 108 ++++++++++++++++++ .../DispositionScheduleInheritanceTests.java | 78 +++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java create mode 100644 rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index 34ff344f92..6d9a6007fb 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -51,6 +51,7 @@ public class RecordCategoriesAPI extends BaseAPI private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class); private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue"; private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions"; + private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule"; /** * Creates a retention schedule for the category given as parameter @@ -71,6 +72,21 @@ public class RecordCategoriesAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); } + /** + * Get the disposition schedule nodeRef + * + * @param user + * @param password + * @param categoryName + * @return the disposition schedule nodeRef + */ + public String getDispositionScheduleNodeRef(String user, String password, String categoryName) + { + String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); + JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef)); + return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), ""); + } + /** * Sets retention schedule authority and instructions, also if it is applied to records or folders * diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java new file mode 100644 index 0000000000..cc7130ce67 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -0,0 +1,108 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 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.v0.service; + + +import java.util.HashMap; + +import org.alfresco.rest.core.v0.BaseAPI; +import org.alfresco.rest.v0.RecordCategoriesAPI; +import org.alfresco.utility.data.DataUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Service for different disposition schedule actions + * + * @author jcule, cagache + * @since 2.6.2 + */ +@Service +public class DispositionScheduleService extends BaseAPI +{ + @Autowired + private RecordCategoriesAPI recordCategoriesAPI; + + @Autowired + private DataUser dataUser; + + /** + * Helper method for adding a cut off after period step + * + * @param categoryName the category in whose schedule the step will be added + * @param period + * @return + */ + public void addCutOffAfterPeriodStep(String categoryName, String period) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step"); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method for adding a retain after period step + * + * @param categoryName the category in whose schedule the step will be added + * @param period + * @return + */ + public void addRetainAfterPeriodStep(String categoryName, String period) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "retain"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step"); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method to create retention schedule with general fields for the given category as admin + * and apply it to the records + * + * @param categoryName + * @param appliedToRecords + */ + public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords) + { + recordCategoriesAPI.createRetentionSchedule(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName); + String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef( + dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName); + + HashMap retentionScheduleGeneralFields = new HashMap<>(); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority"); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions"); + recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields, + appliedToRecords); + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java new file mode 100644 index 0000000000..9a0b428d34 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java @@ -0,0 +1,78 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 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.recordcategories; + +import static org.alfresco.utility.data.RandomData.getRandomName; +import static org.alfresco.utility.report.log.Step.STEP; + +import org.alfresco.rest.rm.community.base.BaseRMRestTest; +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.v0.service.DispositionScheduleService; +import org.alfresco.test.AlfrescoTest; +import org.springframework.beans.factory.annotation.Autowired; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class DispositionScheduleInheritanceTests extends BaseRMRestTest +{ + @Autowired + private DispositionScheduleService dispositionScheduleService; + + @AlfrescoTest (jira = "MNT-19967") + @Test ( + description = "Folders and records under a child record category should inherit the retention schedule of the parent record category." + ) + public void testDispositionScheduleInheritance() throws Exception + { + STEP("Create record category with retention schedule and apply it to records."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), true); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Add retention schedule retain step with immediate period."); + dispositionScheduleService.addRetainAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Create a subcategory with a record folder"); + RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder")); + + STEP("Create 2 records in the record folder. Complete one of them."); + Record elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord")); + Record nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord")); + getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId()); + + STEP("Check that both records inherit root category retention schedule"); + Assert.assertTrue(elRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true"); + Assert.assertTrue(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true"); + } +} From 31a69c208515562beced72434d001f77d5867a95 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 28 Sep 2018 09:29:07 +0300 Subject: [PATCH 3/8] Corrected variable name --- .../rest/v0/service/DispositionScheduleService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java index cc7130ce67..22520994ce 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -76,12 +76,12 @@ public class DispositionScheduleService extends BaseAPI */ public void addRetainAfterPeriodStep(String categoryName, String period) { - HashMap cutOffStep = new HashMap<>(); - cutOffStep.put(RETENTION_SCHEDULE.NAME, "retain"); - cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); - cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step"); + HashMap retainStep = new HashMap<>(); + retainStep.put(RETENTION_SCHEDULE.NAME, "retain"); + retainStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + retainStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step"); recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), - dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + dataUser.getAdminUser().getPassword(), categoryName, retainStep); } /** From b9e6b79dd21698bce47e2ba4efdbb6a25ed7cb48 Mon Sep 17 00:00:00 2001 From: cagache Date: Fri, 28 Sep 2018 11:40:32 +0300 Subject: [PATCH 4/8] Added 3 more tests to check Retention schedule inheritance for records and record folders --- .../model/record/RecordProperties.java | 29 ++++ .../DispositionScheduleInheritanceTests.java | 135 +++++++++++++++++- 2 files changed, 160 insertions(+), 4 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java index b325c5641f..2586352ed4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/RecordProperties.java @@ -52,6 +52,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_CREATION_DATE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_LOCATION; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_ORIGINATING_USER_ID; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RECORD_SEARCH_HAS_DISPOSITION_SCHEDULE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_RESOLUTION_UNIT; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_ROOT_NODE_REF; @@ -64,6 +71,7 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_X_RESOLUTION; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_Y_RESOLUTION; +import java.util.Date; import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -208,4 +216,25 @@ public class RecordProperties extends TestModel @JsonProperty(PROPERTIES_AUTHOR) private String author; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD_EXPRESSION) + private String recordSearchDispositionPeriodExpression; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_AUTHORITY) + private String recordSearchDispositionAuthority; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_AS_OF) + private Date recordSearchDispositionActionAsOf; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_PERIOD) + private String recordSearchDispositionPeriod; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_ACTION_NAME) + private String recordSearchDispositionActionName; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_EVENTS_ELIGIBLE) + private Boolean recordSearchDispositionEventsEligible; + + @JsonProperty (PROPERTIES_RECORD_SEARCH_DISPOSITION_INSTRUCTIONS) + private String recordSearchDispositionInstructions; } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java index 9a0b428d34..7a7bb32960 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java @@ -41,14 +41,24 @@ import org.testng.annotations.Test; public class DispositionScheduleInheritanceTests extends BaseRMRestTest { + private static final String RETAIN_STEP = "retain"; + private static final String CUTOFF_STEP = "cutoff"; + @Autowired private DispositionScheduleService dispositionScheduleService; + /** + * Given following structure is created: + * rootCategory with RS applied on records level + * - subCategory without RS + * - recFolder + * - incomplete electronic record + * - complete non-electronic record + * Then both records should inherit the RS from rootCategory + */ @AlfrescoTest (jira = "MNT-19967") - @Test ( - description = "Folders and records under a child record category should inherit the retention schedule of the parent record category." - ) - public void testDispositionScheduleInheritance() throws Exception + @Test + public void testRSInheritanceOnRecordsWhenOnlyACategoryHasRS() throws Exception { STEP("Create record category with retention schedule and apply it to records."); RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); @@ -75,4 +85,121 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest Assert.assertTrue(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), "rma:recordSearchHasDispositionSchedule property should be true"); } + + /** + * Given following structure is created: + * rootCategory with RS applied on records folder level + * - subCategory without RS + * - recFolder + * Then recFolder should inherit the RS from rootCategory + */ + @Test + public void testRSInheritanceOnRecordFoldersWhenOnlyACategoryHasRS() throws Exception + { + STEP("Create record category with retention schedule and apply it to record folders."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), false); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Add retention schedule retain step with immediate period."); + dispositionScheduleService.addRetainAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Create a subcategory with a record folder"); + RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder")); + + STEP("Check that recFolder inherit root category retention schedule"); + Assert.assertTrue(recFolder.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true"); + } + + /** + * Given following structure is created: + * rootCategory with RS applied on records level + * - subCategory1 with another RS applied on records level + * - subCategory2 without RS + * - recFolder + * - incomplete electronic record + * - complete non-electronic record + * Then both records should inherit the RS from subCategory1 + */ + @Test + public void testRSInheritanceOnRecordsWhen2CategoriesHaveRS() throws Exception + { + STEP("Create record category with retention schedule and apply it to records."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), true); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Create a subcategory with retention schedule and apply it to records."); + RecordCategoryChild subCategory1 = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + String subcategory1Path = rootCategory.getName() + "/" + subCategory1.getName(); + dispositionScheduleService.createCategoryRetentionSchedule(subcategory1Path, true); + + STEP("Add retention schedule retain step with 1 day after created date."); + dispositionScheduleService.addRetainAfterPeriodStep(subcategory1Path, "day|1"); + + STEP("Create a subcategory2 in subcategory1"); + RecordCategoryChild subCategory2 = createRecordCategory(subCategory1.getId(), getRandomName("subCategory")); + + STEP("Create a record folder with 2 records. Complete one of them."); + RecordCategoryChild recFolder = createFolder(subCategory2.getId(), getRandomName("recFolder")); + Record elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord")); + Record nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord")); + getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId()); + + STEP("Check that both records inherit subCategory1 retention schedule"); + Assert.assertTrue(elRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true for incomplete record"); + Assert.assertTrue(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true for complete record"); + Assert.assertEquals(elRecord.getProperties().getRecordSearchDispositionActionName(), + RETAIN_STEP, + "Disposition action should be retain and not cutoff for incomplete record"); + Assert.assertEquals(nonElRecord.getProperties().getRecordSearchDispositionActionName(), + RETAIN_STEP, + "Disposition action should be retain and not cutoff for complete record"); + } + + /** + * Given following structure is created: + * rootCategory with RS applied on records folder level + * - subCategory1 with another RS applied on records folder level + * - subCategory2 without RS + * - recFolder + * Then recFolder should inherit the RS from subCategory1 + */ + @Test + public void testRSInheritanceOnRecordFoldersWhen2CategoriesHaveRS() throws Exception + { + STEP("Create record category with retention schedule and apply it to record folders."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), false); + + STEP("Add retention schedule retain step with 2 days after created date."); + dispositionScheduleService.addRetainAfterPeriodStep(rootCategory.getName(), "day|2"); + + STEP("Create a subcategory with retention schedule and apply it to record folders."); + RecordCategoryChild subCategory1 = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + String subcategory1Path = rootCategory.getName() + "/" + subCategory1.getName(); + dispositionScheduleService.createCategoryRetentionSchedule(subcategory1Path, false); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(subcategory1Path, "immediately"); + + STEP("Create a subcategory2 with a record folder in subcategory1"); + RecordCategoryChild subCategory2 = createRecordCategory(subCategory1.getId(), getRandomName("subCategory")); + RecordCategoryChild recFolder = createFolder(subCategory2.getId(), getRandomName("recFolder")); + + STEP("Check that recFolder inherits subCategory1 retention schedule"); + Assert.assertTrue(recFolder.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true"); + Assert.assertEquals(recFolder.getProperties().getRecordSearchDispositionActionName(), + CUTOFF_STEP, + "Disposition action should be retain and not cutoff for complete record"); + } } From a69d1ddaa3df701f3a843f37ff3d08040e8941a4 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 1 Oct 2018 11:57:11 +0300 Subject: [PATCH 5/8] reverted changes because they are already on the V2.7 branch and can be picked from there --- .../alfresco/rest/v0/RecordCategoriesAPI.java | 16 --- .../service/DispositionScheduleService.java | 108 ------------------ 2 files changed, 124 deletions(-) delete mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index 6d9a6007fb..34ff344f92 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -51,7 +51,6 @@ public class RecordCategoriesAPI extends BaseAPI private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class); private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue"; private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions"; - private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule"; /** * Creates a retention schedule for the category given as parameter @@ -72,21 +71,6 @@ public class RecordCategoriesAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); } - /** - * Get the disposition schedule nodeRef - * - * @param user - * @param password - * @param categoryName - * @return the disposition schedule nodeRef - */ - public String getDispositionScheduleNodeRef(String user, String password, String categoryName) - { - String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); - JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef)); - return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), ""); - } - /** * Sets retention schedule authority and instructions, also if it is applied to records or folders * diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java deleted file mode 100644 index 22520994ce..0000000000 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2018 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.v0.service; - - -import java.util.HashMap; - -import org.alfresco.rest.core.v0.BaseAPI; -import org.alfresco.rest.v0.RecordCategoriesAPI; -import org.alfresco.utility.data.DataUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -/** - * Service for different disposition schedule actions - * - * @author jcule, cagache - * @since 2.6.2 - */ -@Service -public class DispositionScheduleService extends BaseAPI -{ - @Autowired - private RecordCategoriesAPI recordCategoriesAPI; - - @Autowired - private DataUser dataUser; - - /** - * Helper method for adding a cut off after period step - * - * @param categoryName the category in whose schedule the step will be added - * @param period - * @return - */ - public void addCutOffAfterPeriodStep(String categoryName, String period) - { - HashMap cutOffStep = new HashMap<>(); - cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); - cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); - cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step"); - recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), - dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); - } - - /** - * Helper method for adding a retain after period step - * - * @param categoryName the category in whose schedule the step will be added - * @param period - * @return - */ - public void addRetainAfterPeriodStep(String categoryName, String period) - { - HashMap retainStep = new HashMap<>(); - retainStep.put(RETENTION_SCHEDULE.NAME, "retain"); - retainStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); - retainStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step"); - recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), - dataUser.getAdminUser().getPassword(), categoryName, retainStep); - } - - /** - * Helper method to create retention schedule with general fields for the given category as admin - * and apply it to the records - * - * @param categoryName - * @param appliedToRecords - */ - public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords) - { - recordCategoriesAPI.createRetentionSchedule(dataUser.getAdminUser().getUsername(), - dataUser.getAdminUser().getPassword(), categoryName); - String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef( - dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName); - - HashMap retentionScheduleGeneralFields = new HashMap<>(); - retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority"); - retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions"); - recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(), - dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields, - appliedToRecords); - } -} From d5958eaf7bf0a4b0f450ecae93d743169ef85fd0 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 1 Oct 2018 12:22:58 +0300 Subject: [PATCH 6/8] cherry pick changes from V2.7 branch --- .../alfresco/rest/v0/RecordCategoriesAPI.java | 23 +++- .../service/DispositionScheduleService.java | 128 ++++++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java index 34ff344f92..39d29f4bdb 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordCategoriesAPI.java @@ -51,6 +51,8 @@ public class RecordCategoriesAPI extends BaseAPI private static final Logger LOGGER = LoggerFactory.getLogger(RecordCategoriesAPI.class); private static final String RM_ACTIONS_API = "{0}rma/actions/ExecutionQueue"; private static final String DISPOSITION_ACTIONS_API = "{0}node/{1}/dispositionschedule/dispositionactiondefinitions"; + private static final String DISPOSITION_SCHEDULE_API = "{0}node/{1}/dispositionschedule"; + /** * Creates a retention schedule for the category given as parameter @@ -71,6 +73,21 @@ public class RecordCategoriesAPI extends BaseAPI return doPostJsonRequest(user, password, SC_OK, requestParams, RM_ACTIONS_API); } + /** + * Get the disposition schedule nodeRef + * + * @param user + * @param password + * @param categoryName + * @return the disposition schedule nodeRef + */ + public String getDispositionScheduleNodeRef(String user, String password, String categoryName) + { + String catNodeRef = NODE_PREFIX + getItemNodeRef(user, password, "/" + categoryName); + JSONObject dispositionSchedule = doGetRequest(user, password, MessageFormat.format(DISPOSITION_SCHEDULE_API, "{0}", catNodeRef)); + return dispositionSchedule.getJSONObject("data").getString("nodeRef").replace(getNodeRefSpacesStore(), ""); + } + /** * Sets retention schedule authority and instructions, also if it is applied to records or folders * @@ -108,7 +125,11 @@ public class RecordCategoriesAPI extends BaseAPI addPropertyToRequest(requestParams, "period", properties, RETENTION_SCHEDULE.RETENTION_PERIOD); addPropertyToRequest(requestParams, "ghostOnDestroy", properties, RETENTION_SCHEDULE.RETENTION_GHOST); addPropertyToRequest(requestParams, "periodProperty", properties, RETENTION_SCHEDULE.RETENTION_PERIOD_PROPERTY); - addPropertyToRequest(requestParams, "events", properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + String events = getPropertyValue(properties, RETENTION_SCHEDULE.RETENTION_EVENTS); + if(!events.equals("")) + { + requestParams.append("events", events); + } addPropertyToRequest(requestParams, "eligibleOnFirstCompleteEvent", properties, RETENTION_SCHEDULE.RETENTION_ELIGIBLE_FIRST_EVENT); return doPostJsonRequest(user, password, SC_OK, requestParams, MessageFormat.format(DISPOSITION_ACTIONS_API, "{0}", catNodeRef)); diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java new file mode 100644 index 0000000000..c2688376e9 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -0,0 +1,128 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2018 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.v0.service; + + +import java.util.HashMap; + +import org.alfresco.rest.core.v0.BaseAPI; +import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory; +import org.alfresco.rest.v0.RecordCategoriesAPI; +import org.alfresco.utility.data.DataUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * Service for different disposition schedule actions + * + * @author jcule + * @since 2.7.0.1 + */ +@Service +public class DispositionScheduleService extends BaseAPI +{ + @Autowired + private RecordCategoriesAPI recordCategoriesAPI; + + @Autowired + private DataUser dataUser; + + /** + * Helper method for adding a retain after period step + * + * @param categoryName the category in whose schedule the step will be added + * @param period + * @return + */ + public void addRetainAfterPeriodStep(String categoryName, String period) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "retain"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Retain after a period step"); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method for adding a cut off after period step + * + * @param categoryName the category in whose schedule the step will be added + * @param period + * @return + */ + public void addCutOffAfterPeriodStep(String categoryName, String period) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_PERIOD, period); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after a period step"); + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + /** + * Helper method for adding a cut off after an event occurs step + * + * @param categoryName the category in whose schedule the step will be added + * @param events + */ + public void addCutOffAfterEventStep(String categoryName, String events) + { + HashMap cutOffStep = new HashMap<>(); + cutOffStep.put(RETENTION_SCHEDULE.NAME, "cutoff"); + cutOffStep.put(RETENTION_SCHEDULE.RETENTION_EVENTS, events); + cutOffStep.put(RETENTION_SCHEDULE.DESCRIPTION, "Cut off after event step"); + + recordCategoriesAPI.addDispositionScheduleSteps(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName, cutOffStep); + } + + + /** + * Helper method to create retention schedule with general fields for the given category as admin + * and apply it to the records + * + * @param categoryName + * @param appliedToRecords + */ + public void createCategoryRetentionSchedule(String categoryName, Boolean appliedToRecords) + { + recordCategoriesAPI.createRetentionSchedule(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), categoryName); + String retentionScheduleNodeRef = recordCategoriesAPI.getDispositionScheduleNodeRef( + dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword(), categoryName); + + HashMap retentionScheduleGeneralFields = new HashMap<>(); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_AUTHORITY, "Authority"); + retentionScheduleGeneralFields.put(RETENTION_SCHEDULE.RETENTION_INSTRUCTIONS, "Instructions"); + recordCategoriesAPI.setRetentionScheduleGeneralFields(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), retentionScheduleNodeRef, retentionScheduleGeneralFields, + appliedToRecords); + + } +} From 06f46af4899b224ac5e99d3801addb9f88b8396d Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 1 Oct 2018 16:38:19 +0300 Subject: [PATCH 7/8] code review changes --- .../service/DispositionScheduleService.java | 4 +- .../DispositionScheduleInheritanceTests.java | 88 ++++++++++++++++++- 2 files changed, 89 insertions(+), 3 deletions(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java index c2688376e9..396d74c2ad 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/service/DispositionScheduleService.java @@ -39,8 +39,8 @@ import org.springframework.stereotype.Service; /** * Service for different disposition schedule actions * - * @author jcule - * @since 2.7.0.1 + * @author jcule, cagache + * @since 2.6.2 */ @Service public class DispositionScheduleService extends BaseAPI diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java index 7a7bb32960..b600736751 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java @@ -110,7 +110,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder")); - STEP("Check that recFolder inherit root category retention schedule"); + STEP("Check that recFolder inherits root category retention schedule"); Assert.assertTrue(recFolder.getProperties().getRecordSearchHasDispositionSchedule(), "rma:recordSearchHasDispositionSchedule property should be true"); } @@ -202,4 +202,90 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest CUTOFF_STEP, "Disposition action should be retain and not cutoff for complete record"); } + + /** + * Given following structure is created: + * rootCategory with RS applied on folder records level + * - subCategory with another RS applied on records level + * - recFolder + * - incomplete electronic record + * - complete non-electronic record + * Then both records should inherit the RS from subCategory + */ + @Test + public void testMixedRSInheritanceWhenFirstParentHasRSOnRecords() throws Exception + { + STEP("Create record category with retention schedule and apply it to folder records."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), false); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Create a subcategory with retention schedule and apply it to records."); + RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + String subcategoryPath = rootCategory.getName() + "/" + subCategory.getName(); + dispositionScheduleService.createCategoryRetentionSchedule(subcategoryPath, true); + + STEP("Add retention schedule retain step with 1 day after created date."); + dispositionScheduleService.addRetainAfterPeriodStep(subcategoryPath, "day|1"); + + STEP("Create a record folder with 2 records. Complete one of them."); + RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder")); + Record elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord")); + Record nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord")); + getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId()); + + STEP("Check that both records inherit subCategory retention schedule"); + Assert.assertTrue(elRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true for incomplete record"); + Assert.assertTrue(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true for complete record"); + Assert.assertEquals(elRecord.getProperties().getRecordSearchDispositionActionName(), + RETAIN_STEP, + "Disposition action should be retain and not cutoff for incomplete record"); + Assert.assertEquals(nonElRecord.getProperties().getRecordSearchDispositionActionName(), + RETAIN_STEP, + "Disposition action should be retain and not cutoff for complete record"); + } + + /** + * Given following structure is created: + * rootCategory with RS applied on records level + * - subCategory with another RS applied on folder records level + * - recFolder + * - incomplete electronic record + * - complete non-electronic record + * Then both records should not have RS (rma:recordSearchHasDispositionSchedule property is set to false) + */ + @Test + public void testMixedRSInheritanceWhenFirstParentHasRSOnFolders() throws Exception + { + STEP("Create record category with retention schedule and apply it to records."); + RecordCategory rootCategory = createRootCategory(getRandomName("rootCategory")); + dispositionScheduleService.createCategoryRetentionSchedule(rootCategory.getName(), true); + + STEP("Add retention schedule cut off step with immediate period."); + dispositionScheduleService.addCutOffAfterPeriodStep(rootCategory.getName(), "immediately"); + + STEP("Create a subcategory with retention schedule and apply it to record folders."); + RecordCategoryChild subCategory = createRecordCategory(rootCategory.getId(), getRandomName("subCategory")); + String subcategoryPath = rootCategory.getName() + "/" + subCategory.getName(); + dispositionScheduleService.createCategoryRetentionSchedule(subcategoryPath, false); + + STEP("Add retention schedule retain step with 1 day after created date."); + dispositionScheduleService.addRetainAfterPeriodStep(subcategoryPath, "day|1"); + + STEP("Create a record folder with 2 records. Complete one of them."); + RecordCategoryChild recFolder = createFolder(subCategory.getId(), getRandomName("recFolder")); + Record elRecord = createElectronicRecord(recFolder.getId(), getRandomName("elRecord")); + Record nonElRecord = createNonElectronicRecord(recFolder.getId(), getRandomName("nonElRecord")); + getRestAPIFactory().getRecordsAPI().completeRecord(nonElRecord.getId()); + + STEP("Check that the records don't have retention schedule"); + Assert.assertFalse(elRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be false for incomplete record"); + Assert.assertFalse(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be false for complete record"); + } } From b35d5e363ab379bfa8e6110524ed5383c4a9e8c7 Mon Sep 17 00:00:00 2001 From: cagache Date: Mon, 1 Oct 2018 18:34:14 +0300 Subject: [PATCH 8/8] code review changes --- .../DispositionScheduleInheritanceTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java index b600736751..5690d85263 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/recordcategories/DispositionScheduleInheritanceTests.java @@ -200,7 +200,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest "rma:recordSearchHasDispositionSchedule property should be true"); Assert.assertEquals(recFolder.getProperties().getRecordSearchDispositionActionName(), CUTOFF_STEP, - "Disposition action should be retain and not cutoff for complete record"); + "Disposition action should be cutoff and not retain for the record folder"); } /** @@ -257,6 +257,7 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest * - incomplete electronic record * - complete non-electronic record * Then both records should not have RS (rma:recordSearchHasDispositionSchedule property is set to false) + * and record folder inherits the RS from subCategory */ @Test public void testMixedRSInheritanceWhenFirstParentHasRSOnFolders() throws Exception @@ -287,5 +288,12 @@ public class DispositionScheduleInheritanceTests extends BaseRMRestTest "rma:recordSearchHasDispositionSchedule property should be false for incomplete record"); Assert.assertFalse(nonElRecord.getProperties().getRecordSearchHasDispositionSchedule(), "rma:recordSearchHasDispositionSchedule property should be false for complete record"); + + STEP("Check that recFolder inherits subCategory retention schedule"); + Assert.assertTrue(recFolder.getProperties().getRecordSearchHasDispositionSchedule(), + "rma:recordSearchHasDispositionSchedule property should be true"); + Assert.assertEquals(recFolder.getProperties().getRecordSearchDispositionActionName(), + RETAIN_STEP, + "Disposition action should be retain and not cutoff for the record folder"); } }