diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 0fc4781ef4..a3a94a7b55 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -15,7 +15,7 @@ 1.8 alfresco-rm-community-share alfresco-rm-community-repo - 5.2.0-9 + 5.2.0-10 2.0.0 diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java index db8973d980..76a80f6ed6 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/common/Owner.java @@ -26,11 +26,12 @@ */ package org.alfresco.rest.rm.community.model.common; -import org.alfresco.utility.model.TestModel; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; +import org.alfresco.utility.model.TestModel; /** * POJO for owner parameter @@ -43,6 +44,7 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) //@NoArgsConstructor //@AllArgsConstructor +@JsonIgnoreProperties (ignoreUnknown = true) public class Owner extends TestModel { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java index 6ebd2bf33a..e3468e86a4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/record/Record.java @@ -30,7 +30,10 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.core.IRestModel; +import org.alfresco.rest.core.assertion.ModelAssertion; import org.alfresco.rest.model.RestByUserModel; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.rm.community.model.common.Path; import org.alfresco.utility.model.TestModel; @@ -51,7 +54,7 @@ import lombok.NoArgsConstructor; @EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor -public class Record extends TestModel +public class Record extends TestModel implements IRestModel { /*************************/ /** Mandatory parameters */ @@ -100,4 +103,25 @@ public class Record extends TestModel @JsonProperty private Path path; + + @Override + public ModelAssertion assertThat() + { + return new ModelAssertion(this); + } + + @Override + public ModelAssertion and() + { + return assertThat(); + } + + @JsonProperty (value = "entry") + RestNodeModel model; + + @Override + public RestNodeModel onModel() + { + return model; + } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java index 4c68f65eef..2888a70adf 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/v0/RecordsAPI.java @@ -114,6 +114,35 @@ public class RecordsAPI extends BaseAPI } + /** + * Reject the record given as parameter + * + * @param user the user declaring the document as record + * @param password the user's password + * @param recordName the record name + * @param reason reject reason + * @return true if the action completed successfully + */ + public boolean rejectRecord(String user, String password, String recordName, String reason) + { + String recNodeRef = getNodeRefSpacesStore() + contentService.getNodeRef(user, password, RM_SITE_ID, recordName); + + try + { + JSONObject requestParams = new JSONObject(); + requestParams.put("name", "reject"); + requestParams.put("nodeRef", recNodeRef); + requestParams.put("params",new JSONObject() + .put("reason",reason)); + + return doPostJsonRequest(user, password, requestParams, RM_ACTIONS_API); + } + catch (JSONException error) + { + LOGGER.error("Unable to extract response parameter", error); + } + return false; + } /** * Declare document version as record * diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java index 124df6907a..43178fdb4d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -27,7 +27,6 @@ package org.alfresco.rest.rm.community.base; import static lombok.AccessLevel.PROTECTED; - import static org.alfresco.rest.rm.community.base.TestData.ELECTRONIC_RECORD_NAME; import static org.alfresco.rest.rm.community.base.TestData.RECORD_CATEGORY_TITLE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; @@ -39,8 +38,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; -import static org.alfresco.rest.rm.community.model.user.UserPermissions.PERMISSION_FILING; -import static org.alfresco.rest.rm.community.model.user.UserRoles.ROLE_RM_USER; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryChildModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createRecordCategoryModel; import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createTempFile; @@ -54,10 +51,12 @@ import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import org.alfresco.dataprep.ContentService; import org.alfresco.rest.RestTest; import org.alfresco.rest.core.RestAPIFactory; +import org.alfresco.rest.model.RestNodeModel; import org.alfresco.rest.rm.community.model.fileplan.FilePlan; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType; import org.alfresco.rest.rm.community.model.record.Record; @@ -77,6 +76,7 @@ import org.alfresco.rest.search.SearchNodeModel; import org.alfresco.rest.search.SearchRequest; import org.alfresco.rest.v0.RMRolesAndActionsAPI; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ContentModel; import org.alfresco.utility.model.FolderModel; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; @@ -615,4 +615,39 @@ public class BaseRMRestTest extends RestTest } return names; } + + /** + * Helper method to return site document library content model + * + * @return ContentModel + * @throws Exception + */ + public ContentModel getDocumentLibrary(UserModel usermodel, SiteModel testSite) throws Exception + { + ContentModel siteModel = new ContentModel(); + siteModel.setNodeRef(testSite.getGuid()); + + restClient.authenticateUser(usermodel); + + List nodes = restClient.withCoreAPI().usingNode(siteModel) + .listChildren().getEntries().stream().collect(Collectors.toList()); + ContentModel documentLibrary = new ContentModel(); + documentLibrary.setName(nodes.get(0).onModel().getName()); + documentLibrary.setNodeRef(nodes.get(0).onModel().getId()); + return documentLibrary; + } + + /** + * Helper method to create a Content Model + * + * @return ContentModel + * @throws Exception + */ + public ContentModel toContentModel(String nodeId) + { + ContentModel node = new ContentModel(); + node.setNodeRef(nodeId); + return node; + } + }