Added 3 more tests to check Retention schedule inheritance for records and record folders

This commit is contained in:
cagache
2018-09-28 11:40:32 +03:00
parent 31a69c2085
commit b9e6b79dd2
2 changed files with 160 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -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");
}
}