mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
[APPS-2838][APPS-2839] POST and GET API implementation for the Retention Schedule Steps (#2721)
* [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API * [APPS-2838][APPS-2839] Fixed Junit Testcases * [APPS-2838][APPS-2839] Retention Schedule Step POST and GET API --------- Co-authored-by: Sathish Kumar <ST28@ford.com> Co-authored-by: suneet-gupta <suneet.gupta@hyland.com>
This commit is contained in:
@@ -46,4 +46,13 @@ public class RetentionSchedule extends TestModel
|
||||
private boolean isRecordLevel;
|
||||
private boolean isUnpublishedUpdates;
|
||||
private List<RetentionScheduleActionDefinition> actions;
|
||||
|
||||
public boolean getIsRecordLevel()
|
||||
{
|
||||
return isRecordLevel;
|
||||
}
|
||||
|
||||
public void setIsRecordLevel(boolean recordLevel) {
|
||||
isRecordLevel = recordLevel;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 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.model.retentionschedule;
|
||||
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
public class RetentionScheduleStepCollection extends RestModels<RetentionScheduleStepEntry, RetentionScheduleStepCollection>
|
||||
{
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 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.model.retentionschedule;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import org.alfresco.rest.core.RestModels;
|
||||
|
||||
@Data
|
||||
public class RetentionScheduleStepEntry extends RestModels<RetentionScheduleActionDefinition, RetentionScheduleStepEntry>
|
||||
{
|
||||
@JsonProperty
|
||||
private RetentionScheduleActionDefinition entry;
|
||||
}
|
@@ -28,7 +28,9 @@ package org.alfresco.rest.rm.community.requests.gscore.api;
|
||||
|
||||
import org.alfresco.rest.core.RMRestWrapper;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionSchedule;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleActionDefinition;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleCollection;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleStepCollection;
|
||||
import org.alfresco.rest.rm.community.requests.RMModelRequest;
|
||||
|
||||
import static org.alfresco.rest.core.RestRequest.requestWithBody;
|
||||
@@ -122,4 +124,75 @@ public class RetentionScheduleAPI extends RMModelRequest
|
||||
{
|
||||
return getRetentionSchedule(recordCategoryId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a step in the retention schedule.
|
||||
*
|
||||
* @param retentionScheduleActionDefinition The retentionScheduleActionDefinition model
|
||||
* @param retentionScheduleId The identifier of a retention schedule id
|
||||
* @param parameters The URL parameters to add
|
||||
* @return The created {@link RetentionScheduleActionDefinition}
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>{@code retentionScheduleId} is not a valid format or {@code retentionScheduleId} is invalid</li>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to add children to {@code retentionScheduleId}</li>
|
||||
* <li>{@code retentionScheduleId} does not exist</li>
|
||||
* <li>new name clashes with an existing node in the current parent container</li>
|
||||
* </ul>
|
||||
*/
|
||||
public RetentionScheduleActionDefinition createRetentionScheduleStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition, String retentionScheduleId, String parameters)
|
||||
{
|
||||
mandatoryString("retentionScheduleId", retentionScheduleId);
|
||||
mandatoryObject("retentionScheduleActionDefinition", retentionScheduleActionDefinition);
|
||||
|
||||
return getRmRestWrapper().processModel(RetentionScheduleActionDefinition.class, requestWithBody(
|
||||
POST,
|
||||
toJson(retentionScheduleActionDefinition),
|
||||
"retention-schedules/{retentionScheduleId}/retention-steps",
|
||||
retentionScheduleId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #createRetentionScheduleStep(RetentionScheduleActionDefinition, String)} (RetentionSchedule, String, String)}
|
||||
*/
|
||||
public RetentionScheduleActionDefinition createRetentionScheduleStep(RetentionScheduleActionDefinition retentionScheduleActionDefinition, String retentionScheduleId)
|
||||
{
|
||||
return createRetentionScheduleStep(retentionScheduleActionDefinition, retentionScheduleId, EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the retentionSchedule of a record category.
|
||||
*
|
||||
* @param retentionScheduleId The identifier of a record category
|
||||
* @param parameters The URL parameters to add
|
||||
* @return The {@link RetentionScheduleActionDefinition} for the given {@code recordCategoryId}
|
||||
* @throws RuntimeException for the following cases:
|
||||
* <ul>
|
||||
* <li>authentication fails</li>
|
||||
* <li>current user does not have permission to read {@code recordCategoryId}</li>
|
||||
* <li>{@code recordCategoryId} does not exist</li>
|
||||
*</ul>
|
||||
*/
|
||||
public RetentionScheduleStepCollection getRetentionScheduleStep(String retentionScheduleId, String parameters)
|
||||
{
|
||||
mandatoryString("retentionScheduleId", retentionScheduleId);
|
||||
|
||||
return getRmRestWrapper().processModels(RetentionScheduleStepCollection.class, simpleRequest(
|
||||
GET,
|
||||
"retention-schedules/{retentionScheduleId}/retention-steps?{parameters}",
|
||||
retentionScheduleId,
|
||||
parameters
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #getRetentionScheduleStep(String, String)}
|
||||
*/
|
||||
public RetentionScheduleStepCollection getRetentionScheduleStep(String recordCategoryId)
|
||||
{
|
||||
return getRetentionScheduleStep(recordCategoryId, EMPTY);
|
||||
}
|
||||
}
|
@@ -0,0 +1,358 @@
|
||||
/*-
|
||||
* #%L
|
||||
* Alfresco Records Management Module
|
||||
* %%
|
||||
* Copyright (C) 2005 - 2024 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.retentionschedule;
|
||||
|
||||
import org.alfresco.rest.rm.community.base.BaseRMRestTest;
|
||||
import org.alfresco.rest.rm.community.model.recordcategory.RecordCategory;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionSchedule;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleActionDefinition;
|
||||
import org.alfresco.rest.rm.community.model.retentionschedule.RetentionScheduleStepCollection;
|
||||
import org.alfresco.rest.v0.RMRolesAndActionsAPI;
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.alfresco.rest.core.v0.BaseAPI.RM_SITE_ID;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
|
||||
import static org.alfresco.utility.data.RandomData.getRandomName;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.CONFLICT;
|
||||
import static org.springframework.http.HttpStatus.CREATED;
|
||||
import static org.springframework.http.HttpStatus.FORBIDDEN;
|
||||
import static org.springframework.http.HttpStatus.NOT_FOUND;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.http.HttpStatus.UNAUTHORIZED;
|
||||
import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.AssertJUnit.assertEquals;
|
||||
|
||||
/**
|
||||
* Retention schedule step test case
|
||||
*/
|
||||
public class RetentionScheduleStepTests extends BaseRMRestTest
|
||||
{
|
||||
private RecordCategory recordCategory;
|
||||
private RetentionSchedule createdRetentionSchedule;
|
||||
private final RetentionScheduleActionDefinition retentionScheduleActionDefinition = new RetentionScheduleActionDefinition();
|
||||
private RetentionScheduleActionDefinition createdRetentionActionDefinition;
|
||||
private UserModel nonRMuser;
|
||||
private final List<String> recordCategories = new ArrayList<>();
|
||||
private static final String TEST_USER = "testUser";
|
||||
private static final String RECORD_CATEGORY = "recordCategory";
|
||||
private static final String PERIOD_PROPERTY = "cm:created";
|
||||
private static final String AUTHORITY = "authority";
|
||||
private static final String INSTRUCTIONS = "instructions";
|
||||
private static final int PERIOD_AMOUNT = 5;
|
||||
private static final String PERIOD = "month";
|
||||
private static final List<String> EVENTS = Arrays.asList("case_closed","abolished");
|
||||
private static final String TRANSFER_STEP = "transfer";
|
||||
private static final String RETAIN_STEP = "retain";
|
||||
private static final String INVALID_PERIOD = "random";
|
||||
private static final String CUTOFF_STEP = "cutoff";
|
||||
private static final String DESTROY_STEP = "destroy";
|
||||
private static final String INVALID_PASSWORD = "wrongPassword";
|
||||
|
||||
@Autowired
|
||||
private RMRolesAndActionsAPI rmRolesAndActionsAPI;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void preconditionForRetentionScheduleStepTests()
|
||||
{
|
||||
createRMSiteIfNotExists();
|
||||
// create a non rm user
|
||||
nonRMuser = dataUser.createRandomTestUser(TEST_USER);
|
||||
//Create record category
|
||||
recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
||||
recordCategories.add(recordCategory.getId());
|
||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
||||
retentionSchedule.setAuthority(AUTHORITY + getRandomAlphanumeric());
|
||||
retentionSchedule.setInstructions(INSTRUCTIONS + getRandomAlphanumeric());
|
||||
retentionSchedule.setIsRecordLevel(false);
|
||||
//Create retention schedule with a valid user
|
||||
createdRetentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
||||
|
||||
retentionScheduleActionDefinition.setName(RETAIN_STEP);
|
||||
retentionScheduleActionDefinition.setDescription(INSTRUCTIONS);
|
||||
retentionScheduleActionDefinition.setPeriodAmount(PERIOD_AMOUNT);
|
||||
retentionScheduleActionDefinition.setPeriodProperty(PERIOD_PROPERTY);
|
||||
retentionScheduleActionDefinition.setPeriod(PERIOD);
|
||||
retentionScheduleActionDefinition.setCombineDispositionStepConditions(false);
|
||||
retentionScheduleActionDefinition.setEligibleOnFirstCompleteEvent(true);
|
||||
retentionScheduleActionDefinition.setEvents(EVENTS);
|
||||
}
|
||||
|
||||
@Test(priority = 1)
|
||||
public void createRetentionScheduleStepFor422()
|
||||
{
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
//Creating the first action "transfer" should give 422
|
||||
actionDefinition.setName(TRANSFER_STEP);
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
@Test(priority = 2)
|
||||
public void createRetentionScheduleStepWithInvalidPeriodValue()
|
||||
{
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
actionDefinition.setName(RETAIN_STEP);
|
||||
//Invalid period value
|
||||
actionDefinition.setPeriod(INVALID_PERIOD);
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test(priority = 3)
|
||||
public void createRetentionScheduleWithInvalidStep()
|
||||
{
|
||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
||||
recordCategories.add(recordCategory.getId());
|
||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
actionDefinition.setName(RETAIN_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition1.setName(TRANSFER_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition2.setName(CUTOFF_STEP);
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2,retentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(CONFLICT);
|
||||
}
|
||||
|
||||
@Test(priority = 4)
|
||||
public void createRetentionScheduleWithInvalidStepAfterDestroy()
|
||||
{
|
||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
||||
recordCategories.add(recordCategory.getId());
|
||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
actionDefinition.setName(RETAIN_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition1.setName(DESTROY_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition2.setName(CUTOFF_STEP);
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2,retentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(CONFLICT);
|
||||
}
|
||||
|
||||
@Test(priority = 5)
|
||||
public void createRetentionScheduleWithSameStep()
|
||||
{
|
||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
||||
recordCategories.add(recordCategory.getId());
|
||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
actionDefinition.setName(RETAIN_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition1.setName(RETAIN_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1,retentionSchedule.getId());
|
||||
|
||||
// Verify the status code
|
||||
assertStatusCode(CONFLICT);
|
||||
}
|
||||
|
||||
@Test(priority = 6)
|
||||
public void createRetentionScheduleWithMultipleTransferStep()
|
||||
{
|
||||
RecordCategory recordCategory = createRootCategory(getRandomName(RECORD_CATEGORY));
|
||||
recordCategories.add(recordCategory.getId());
|
||||
RetentionSchedule retentionSchedule = createRetentionSchedule(recordCategory);
|
||||
RetentionScheduleActionDefinition actionDefinition = getRetentionScheduleActionDefinition();
|
||||
actionDefinition.setName(RETAIN_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition,retentionSchedule.getId());
|
||||
|
||||
assertStatusCode(CREATED);
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition1 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition1.setName(TRANSFER_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition1, retentionSchedule.getId());
|
||||
|
||||
RetentionScheduleActionDefinition actionDefinition2 = getRetentionScheduleActionDefinition();
|
||||
actionDefinition2.setName(TRANSFER_STEP);
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(actionDefinition2, retentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
}
|
||||
|
||||
@Test(priority = 7)
|
||||
public void createRetentionScheduleStepFor201()
|
||||
{
|
||||
//Create retention schedule action definition
|
||||
createdRetentionActionDefinition = getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
// Find this retention schedule is created one or not
|
||||
assertEquals(createdRetentionActionDefinition.getName(), retentionScheduleActionDefinition.getName());
|
||||
assertEquals(createdRetentionActionDefinition.getDescription(), retentionScheduleActionDefinition.getDescription());
|
||||
assertEquals(createdRetentionActionDefinition.getPeriodAmount(), retentionScheduleActionDefinition.getPeriodAmount());
|
||||
assertEquals(createdRetentionActionDefinition.isCombineDispositionStepConditions(), retentionScheduleActionDefinition.isCombineDispositionStepConditions());
|
||||
assertEquals(createdRetentionActionDefinition.isEligibleOnFirstCompleteEvent(), retentionScheduleActionDefinition.isEligibleOnFirstCompleteEvent());
|
||||
}
|
||||
|
||||
@Test(priority = 8)
|
||||
public void createRetentionScheduleStepFor401()
|
||||
{
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), INVALID_PASSWORD)).createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test(priority = 9)
|
||||
public void createRetentionScheduleStepFor403()
|
||||
{
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).createRetentionScheduleStep(retentionScheduleActionDefinition,createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test(priority = 10)
|
||||
public void retentionScheduleStepFor400()
|
||||
{
|
||||
getRestAPIFactory().getRetentionScheduleAPI().getRetentionScheduleStep(recordCategory.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(BAD_REQUEST);
|
||||
}
|
||||
|
||||
@Test(priority = 11)
|
||||
public void createRetentionScheduleStepFor404()
|
||||
{
|
||||
//Create retention schedule action definition
|
||||
getRestAPIFactory().getRetentionScheduleAPI().createRetentionScheduleStep(retentionScheduleActionDefinition,getRandomAlphanumeric());
|
||||
// Verify the status code
|
||||
assertStatusCode(NOT_FOUND);
|
||||
}
|
||||
|
||||
@Test(priority = 12)
|
||||
public void retentionScheduleStepFor403()
|
||||
{
|
||||
// Get retention schedule steps with user having no rights
|
||||
getRestAPIFactory().getRetentionScheduleAPI(nonRMuser).getRetentionScheduleStep(createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(FORBIDDEN);
|
||||
}
|
||||
|
||||
@Test(priority = 13)
|
||||
public void retentionScheduleStepFor401()
|
||||
{
|
||||
getRestAPIFactory().getRetentionScheduleAPI(new UserModel(getAdminUser().getUsername(), INVALID_PASSWORD)).getRetentionScheduleStep(createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@Test(priority = 14)
|
||||
public void retentionScheduleStepWith200()
|
||||
{
|
||||
RetentionScheduleStepCollection receiveRetentionStepCollection = getRestAPIFactory().getRetentionScheduleAPI().getRetentionScheduleStep(createdRetentionSchedule.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(OK);
|
||||
receiveRetentionStepCollection.getEntries().forEach(c ->
|
||||
{
|
||||
RetentionScheduleActionDefinition retentionActionDef = c.getEntry();
|
||||
assertNotNull(retentionActionDef.getId());
|
||||
// Find this retention schedule is created one or not
|
||||
assertEquals(createdRetentionActionDefinition.getId(), retentionActionDef.getId());
|
||||
assertEquals(createdRetentionActionDefinition.getName(), retentionActionDef.getName());
|
||||
assertEquals(createdRetentionActionDefinition.getDescription(), retentionActionDef.getDescription());
|
||||
assertEquals(createdRetentionActionDefinition.getPeriod(), retentionActionDef.getPeriod());
|
||||
assertEquals(createdRetentionActionDefinition.getPeriodAmount(), retentionActionDef.getPeriodAmount());
|
||||
assertEquals(createdRetentionActionDefinition.isCombineDispositionStepConditions(), retentionActionDef.isCombineDispositionStepConditions());
|
||||
assertEquals(createdRetentionActionDefinition.isEligibleOnFirstCompleteEvent(), retentionActionDef.isEligibleOnFirstCompleteEvent());
|
||||
});
|
||||
}
|
||||
|
||||
private RetentionSchedule createRetentionSchedule(RecordCategory recordCategory)
|
||||
{
|
||||
RetentionSchedule retentionSchedule = new RetentionSchedule();
|
||||
retentionSchedule.setAuthority(AUTHORITY + getRandomAlphanumeric());
|
||||
retentionSchedule.setInstructions(INSTRUCTIONS + getRandomAlphanumeric());
|
||||
retentionSchedule.setIsRecordLevel(false);
|
||||
//Create retention schedule with a valid user
|
||||
retentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
||||
.createRetentionSchedule(retentionSchedule, recordCategory.getId());
|
||||
// Verify the status code
|
||||
assertStatusCode(CREATED);
|
||||
return retentionSchedule;
|
||||
}
|
||||
|
||||
private static RetentionScheduleActionDefinition getRetentionScheduleActionDefinition()
|
||||
{
|
||||
RetentionScheduleActionDefinition actionDefinition = new RetentionScheduleActionDefinition();
|
||||
actionDefinition.setDescription(INSTRUCTIONS);
|
||||
actionDefinition.setPeriodAmount(PERIOD_AMOUNT);
|
||||
actionDefinition.setPeriodProperty(PERIOD_PROPERTY);
|
||||
actionDefinition.setPeriod(PERIOD);
|
||||
actionDefinition.setCombineDispositionStepConditions(false);
|
||||
actionDefinition.setEligibleOnFirstCompleteEvent(true);
|
||||
actionDefinition.setEvents(EVENTS);
|
||||
return actionDefinition;
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void cleanUpRetentionScheduleStepTests()
|
||||
{
|
||||
rmRolesAndActionsAPI.deleteAllItemsInContainer(getDataUser().usingAdmin().getAdminUser().getUsername(),
|
||||
getDataUser().usingAdmin().getAdminUser().getPassword(), RM_SITE_ID, recordCategory.getName());
|
||||
recordCategories.forEach(this::deleteRecordCategory);
|
||||
dataUser.deleteUser(nonRMuser);
|
||||
}
|
||||
}
|
@@ -145,7 +145,7 @@ public class RetentionScheduleTests extends BaseRMRestTest
|
||||
boolean isRecordLevel = false;
|
||||
retentionSchedule.setAuthority(authority);
|
||||
retentionSchedule.setInstructions(instructions);
|
||||
retentionSchedule.setRecordLevel(isRecordLevel);
|
||||
retentionSchedule.setIsRecordLevel(isRecordLevel);
|
||||
|
||||
//Create retention schedule with a valid user
|
||||
createdRetentionSchedule = getRestAPIFactory().getRetentionScheduleAPI()
|
||||
@@ -155,7 +155,7 @@ public class RetentionScheduleTests extends BaseRMRestTest
|
||||
assertStatusCode(CREATED);
|
||||
assertEquals(createdRetentionSchedule.getAuthority(), authority);
|
||||
assertEquals(createdRetentionSchedule.getInstructions(), instructions);
|
||||
assertFalse(createdRetentionSchedule.isRecordLevel());
|
||||
assertFalse(createdRetentionSchedule.getIsRecordLevel());
|
||||
assertNotNull(createdRetentionSchedule.getId());
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ public class RetentionScheduleTests extends BaseRMRestTest
|
||||
assertEquals(createdRetentionSchedule.getParentId(),retentionSchedule.getParentId());
|
||||
assertEquals(createdRetentionSchedule.getAuthority(), retentionSchedule.getAuthority());
|
||||
assertEquals(createdRetentionSchedule.getInstructions(), retentionSchedule.getInstructions());
|
||||
assertEquals(createdRetentionSchedule.isRecordLevel(), retentionSchedule.isRecordLevel());
|
||||
assertEquals(createdRetentionSchedule.getIsRecordLevel(), retentionSchedule.getIsRecordLevel());
|
||||
assertEquals(createdRetentionSchedule.isUnpublishedUpdates(), retentionSchedule.isUnpublishedUpdates());
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user