diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 0579d444e2..3a53363b14 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -12,6 +12,7 @@ + 1.8 alfresco-rm-community-share alfresco-rm-community-repo 5.2.0-0 diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java new file mode 100644 index 0000000000..b76699e7c0 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestProperties.java @@ -0,0 +1,88 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.core; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; + +/** + * Extends {@link RestProperties} to be able to change/add properties + * + * @author Tuna Aksoy + * @since 2.6 + */ +@Configuration +@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"}) +@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true) +@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true) +public class RMRestProperties extends RestProperties +{ + @Value ("${alfresco.scheme}") + private String scheme; + + @Value ("${alfresco.server}") + private String server; + + @Value ("${alfresco.port}") + private String port; + + @Value ("${rest.rmPath}") + private String restRmPath; + + /** + * @return the scheme + */ + public String getScheme() + { + return this.scheme; + } + + /** + * @return the server + */ + public String getServer() + { + return this.server; + } + + /** + * @return the port + */ + public String getPort() + { + return this.port; + } + + /** + * @return the restRmPath + */ + public String getRestRmPath() + { + return this.restRmPath; + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java new file mode 100644 index 0000000000..706efef8d7 --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RMRestWrapper.java @@ -0,0 +1,53 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.core; + +import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +/** + * Extends {@link RestWrapper} in order to call IG APIs with our own properties + * + * @author Tuna Aksoy + * @since 2.6 + */ +@Primary +@Service +@Scope(value = "prototype") +public class RMRestWrapper extends RestWrapper +{ + @Autowired + private RMRestProperties rmRestProperties; + + public RestIGCoreAPI withIGCoreAPI() + { + return new RestIGCoreAPI(this, rmRestProperties); + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java new file mode 100644 index 0000000000..99ff7b30ab --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/core/RestAPIFactory.java @@ -0,0 +1,87 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.core; + +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RestIGCoreAPI; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Service; + +/** + * REST API Factory Implementation + * + * @author Tuna Aksoy + * @since 2.6 + */ +@Service +@Scope(value = "prototype") +public class RestAPIFactory +{ + @Autowired + private DataUser dataUser; + + @Autowired + private RMRestWrapper rmRestWrapper; + + /** + * @return the rmRestWrapper + */ + public RMRestWrapper getRmRestWrapper() + { + return this.rmRestWrapper; + } + + private RestIGCoreAPI getRestIGCoreAPI(UserModel userModel) + { + getRmRestWrapper().authenticateUser(userModel != null ? userModel : dataUser.getAdminUser()); + return getRmRestWrapper().withIGCoreAPI(); + } + + public RMSiteAPI getRMSiteAPI() + { + return getRestIGCoreAPI(null).usingRMSite(); + } + + public RMSiteAPI getRMSiteAPI(UserModel userModel) + { + return getRestIGCoreAPI(userModel).usingRMSite(); + } + + public FilePlanComponentAPI getFilePlanComponentsAPI() + { + return getRestIGCoreAPI(null).usingFilePlanComponents(); + } + + public FilePlanComponentAPI getFilePlanComponentsAPI(UserModel userModel) + { + return getRestIGCoreAPI(userModel).usingFilePlanComponents(); + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java index 6957ed908b..ab43e79613 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponent.java @@ -37,9 +37,12 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.utility.model.TestModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; /** @@ -51,9 +54,10 @@ import lombok.NoArgsConstructor; */ @Builder @Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor -public class FilePlanComponent +public class FilePlanComponent extends TestModel { @JsonProperty (required = true) private String id; @@ -114,5 +118,4 @@ public class FilePlanComponent @JsonProperty (value = RELATIVE_PATH) private String relativePath; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAlias.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAlias.java index f7590c1b1e..e638648943 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAlias.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentAlias.java @@ -26,58 +26,16 @@ */ package org.alfresco.rest.rm.community.model.fileplancomponents; -import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString; - /** - * File plan component alias enumeration + * File plan component alias * * @author Tuna Aksoy * @since 2.6 */ -public enum FilePlanComponentAlias +public class FilePlanComponentAlias { - FILE_PLAN_ALIAS("-filePlan-"), - TRANSFERS_ALIAS("-transfers-"), - UNFILED_RECORDS_CONTAINER_ALIAS("-unfiled-"), - HOLDS_ALIAS("-holds-"); - - private String alias; - - private FilePlanComponentAlias(String alias) - { - this.alias = alias; - } - - public static final FilePlanComponentAlias getFilePlanComponentAlias(String alias) - { - mandatoryString("alias", alias); - - FilePlanComponentAlias result = null; - FilePlanComponentAlias[] values = values(); - - for (FilePlanComponentAlias filePlanComponentAlias : values) - { - if (filePlanComponentAlias.toString().equals(alias)) - { - result = filePlanComponentAlias; - break; - } - } - - if (result == null) - { - throw new IllegalArgumentException("Invalid file plan component alias enum value: '" + alias + "'."); - } - - return result; - } - - /** - * @see java.lang.Enum#toString() - */ - @Override - public String toString() - { - return this.alias; - } + public static final String FILE_PLAN_ALIAS = "-filePlan-"; + public static final String TRANSFERS_ALIAS = "-transfers-"; + public static final String UNFILED_RECORDS_CONTAINER_ALIAS = "-unfiled-"; + public static final String HOLDS_ALIAS = "-holds-"; } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java index 36eada3bb5..23aa496bb1 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentContent.java @@ -35,6 +35,7 @@ import lombok.NoArgsConstructor; /** * POJO for FilePlanComponent content field + * * @author Kristijan Conkas * @since 2.6 */ @@ -55,5 +56,4 @@ public class FilePlanComponentContent @JsonProperty (required = true) private Integer sizeInBytes; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java index eb06c96efb..1d72826604 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentEntry.java @@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.core.RestModels; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.alfresco.rest.core.RestModels; /** * POJO for file plan component entry @@ -44,11 +46,11 @@ import org.alfresco.rest.core.RestModels; */ @Builder @Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor public class FilePlanComponentEntry extends RestModels { @JsonProperty(ENTRY) - FilePlanComponent filePlanComponent; - + FilePlanComponent filePlanComponentModel; } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java index de3dfb957b..ebe0edc335 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentIdNamePair.java @@ -45,5 +45,4 @@ public class FilePlanComponentIdNamePair { public String id; public String name; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java index 69c5a9c652..e2a356d163 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentPath.java @@ -37,7 +37,7 @@ import lombok.NoArgsConstructor; /** * POJO for FilePlanComponent path parameter - *
+ * * @author Kristijan Conkas * @since 2.6 */ @@ -51,5 +51,4 @@ public class FilePlanComponentPath private String name; private Boolean isComplete; private List elements; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java index 020caf167f..4dee1bef31 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentProperties.java @@ -67,7 +67,6 @@ import lombok.NoArgsConstructor; @AllArgsConstructor public class FilePlanComponentProperties { - @JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR) private Boolean vitalRecord; @@ -85,28 +84,26 @@ public class FilePlanComponentProperties @JsonProperty(PROPERTIES_REVIEW_PERIOD) @JsonSerialize (using = ReviewPeriodSerializer.class) - private ReviewPeriod reviewPeriod; + private FilePlanComponentReviewPeriod reviewPeriod; @JsonProperty(PROPERTIES_LOCATION) private String location; @JsonProperty(value = PROPERTIES_IS_CLOSED, required = false) private Boolean isClosed; - + @JsonProperty(value = PROPERTIES_BOX, required = false) private String box; - + @JsonProperty(value = PROPERTIES_FILE, required = false) private String file; - + @JsonProperty(value = PROPERTIES_SHELF, required = false) private String shelf; - + @JsonProperty(value = PROPERTIES_NUMBER_OF_COPIES, required = false) private Integer numberOfCopies; - + @JsonProperty(value = PROPERTIES_PHYSICAL_SIZE, required = false) private Integer physicalSize; - - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentReviewPeriod.java similarity index 93% rename from rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java rename to rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentReviewPeriod.java index eef6342922..1b466cf071 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/ReviewPeriod.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentReviewPeriod.java @@ -32,7 +32,7 @@ import lombok.Data; import lombok.NoArgsConstructor; /** - * POJO for the review period + * POJO for the file plan component review period * * @author Rodica Sutu * @since 2.6 @@ -41,7 +41,7 @@ import lombok.NoArgsConstructor; @Data @NoArgsConstructor @AllArgsConstructor -public class ReviewPeriod +public class FilePlanComponentReviewPeriod { private String periodType; private String expression; diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentType.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentType.java index cfa1f98c0c..9af5f106e9 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentType.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentType.java @@ -26,66 +26,24 @@ */ package org.alfresco.rest.rm.community.model.fileplancomponents; -import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString; - /** - * File plan component type enumeration + * File plan component type * * @author Tuna Aksoy * @since 2.6 */ -public enum FilePlanComponentType +public class FilePlanComponentType { - FILE_PLAN_TYPE("rma:filePlan"), - RECORD_CATEGORY_TYPE("rma:recordCategory"), - RECORD_FOLDER_TYPE("rma:recordFolder"), - HOLD_TYPE("rma:hold"), - UNFILED_RECORD_FOLDER_TYPE("rma:unfiledRecordFolder"), - HOLD_CONTAINER_TYPE("rma:holdContainer"), - TRANSFER_TYPE("rma:transfer"), - TRANSFER_CONTAINER_TYPE("rma:transferContainer"), - UNFILED_CONTAINER_TYPE("rma:unfiledRecordContainer"), - FOLDER_TYPE("cm:folder"), - CONTENT_TYPE("cm:content"), - NON_ELECTRONIC_RECORD_TYPE("rma:nonElectronicDocument"); - - private String type; - - private FilePlanComponentType(String type) - { - this.type = type; - } - - public static final FilePlanComponentType getFilePlanComponentType(String type) - { - mandatoryString("type", type); - - FilePlanComponentType result = null; - FilePlanComponentType[] values = values(); - - for (FilePlanComponentType filePlanComponentType : values) - { - if (filePlanComponentType.toString().equals(filePlanComponentType)) - { - result = filePlanComponentType; - break; - } - } - - if (result == null) - { - throw new IllegalArgumentException("Invalid file plan component type enum value: '" + type + "'."); - } - - return result; - } - - /** - * @see java.lang.Enum#toString() - */ - @Override - public String toString() - { - return this.type; - } + public static final String FILE_PLAN_TYPE = "rma:filePlan"; + public static final String RECORD_CATEGORY_TYPE = "rma:recordCategory"; + public static final String RECORD_FOLDER_TYPE = "rma:recordFolder"; + public static final String HOLD_TYPE = "rma:hold"; + public static final String UNFILED_RECORD_FOLDER_TYPE = "rma:unfiledRecordFolder"; + public static final String HOLD_CONTAINER_TYPE = "rma:holdContainer"; + public static final String TRANSFER_TYPE = "rma:transfer"; + public static final String TRANSFER_CONTAINER_TYPE = "rma:transferContainer"; + public static final String UNFILED_CONTAINER_TYPE = "rma:unfiledRecordContainer"; + public static final String FOLDER_TYPE = "cm:folder"; + public static final String CONTENT_TYPE = "cm:content"; + public static final String NON_ELECTRONIC_RECORD_TYPE = "rma:nonElectronicDocument"; } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java index cc9327b55f..411d682470 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentUserInfo.java @@ -45,5 +45,4 @@ public class FilePlanComponentUserInfo { private String id; private String displayName; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java index 2969bd5088..1316811039 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/site/RMSite.java @@ -30,11 +30,13 @@ import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE; import com.fasterxml.jackson.annotation.JsonProperty; +import org.alfresco.rest.model.RestSiteModel; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import org.alfresco.rest.model.RestSiteModel; /** * POJO for RM Site component @@ -44,11 +46,11 @@ import org.alfresco.rest.model.RestSiteModel; */ @Builder @Data +@EqualsAndHashCode(callSuper = true) @NoArgsConstructor @AllArgsConstructor public class RMSite extends RestSiteModel { - @JsonProperty (value = COMPLIANCE,required = true) + @JsonProperty (value = COMPLIANCE, required = true) private RMSiteCompliance compliance; - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java new file mode 100644 index 0000000000..5f05822e3e --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMModelRequest.java @@ -0,0 +1,58 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.requests; + +import org.alfresco.rest.core.RMRestWrapper; +import org.alfresco.rest.requests.ModelRequest; + +/** + * Extends {@link ModelRequest} to set {@link RMRestWrapper} + * + * @author Tuna Aksoy + * @since 2.6 + */ +public abstract class RMModelRequest extends ModelRequest +{ + private RMRestWrapper rmRestWrapper; + + /** + * @return the rmRestWrapper + */ + protected RMRestWrapper getRMRestWrapper() + { + return this.rmRestWrapper; + } + + /** + * @param restWrapper + */ + public RMModelRequest(RMRestWrapper rmRestWrapper) + { + super(rmRestWrapper); + this.rmRestWrapper = rmRestWrapper; + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/FilePlanComponentAPI.java similarity index 65% rename from rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java rename to rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/FilePlanComponentAPI.java index 5a2a269fbd..2bc7350088 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/FilePlanComponentAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/FilePlanComponentAPI.java @@ -24,16 +24,18 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.rest.rm.community.requests; +package org.alfresco.rest.rm.community.requests.igCoreAPI; import static com.jayway.restassured.RestAssured.basic; import static com.jayway.restassured.RestAssured.given; import static org.alfresco.rest.core.RestRequest.requestWithBody; import static org.alfresco.rest.core.RestRequest.simpleRequest; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject; import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryString; import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; +import static org.apache.commons.lang3.StringUtils.EMPTY; import static org.springframework.http.HttpMethod.DELETE; import static org.springframework.http.HttpMethod.GET; import static org.springframework.http.HttpMethod.POST; @@ -50,25 +52,30 @@ import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.http.ContentType; import com.jayway.restassured.response.Response; -import org.alfresco.rest.core.RestAPI; +import org.alfresco.rest.core.RMRestWrapper; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection; +import org.alfresco.rest.rm.community.requests.RMModelRequest; import org.alfresco.utility.model.UserModel; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; /** * File plan component REST API Wrapper * * @author Tuna Aksoy - * @author Kristijan Conkas * @since 2.6 */ -@Component -@Scope(value = "prototype") -public class FilePlanComponentAPI extends RestAPI +public class FilePlanComponentAPI extends RMModelRequest { + /** + * Constructor + * + * @param restWrapper + */ + public FilePlanComponentAPI(RMRestWrapper rmRestWrapper) + { + super(rmRestWrapper); + } + /** * Get a file plan component * @@ -85,10 +92,31 @@ public class FilePlanComponentAPI extends RestAPI { mandatoryString("filePlanComponentId", filePlanComponentId); - return usingRestWrapper().processModel(FilePlanComponent.class, simpleRequest( + return getFilePlanComponent(filePlanComponentId, EMPTY); + } + + /** + * Get a file plan component + * + * @param filePlanComponentId The id of the file plan component to get + * @param parameters The URL parameters to add + * @return The {@link FilePlanComponent} for the given file plan component id + * @throws Exception for the following cases: + *
    + *
  • {@code fileplanComponentId} is not a valid format
  • + *
  • authentication fails
  • + *
  • {@code fileplanComponentId} does not exist
  • + *
+ */ + public FilePlanComponent getFilePlanComponent(String filePlanComponentId, String parameters) throws Exception + { + mandatoryString("filePlanComponentId", filePlanComponentId); + + return getRMRestWrapper().processModel(FilePlanComponent.class, simpleRequest( GET, "fileplan-components/{fileplanComponentId}?{parameters}", - filePlanComponentId, getParameters() + filePlanComponentId, + parameters )); } @@ -108,7 +136,7 @@ public class FilePlanComponentAPI extends RestAPI { mandatoryString("filePlanComponentId", filePlanComponentId); - return usingRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest( + return getRMRestWrapper().processModels(FilePlanComponentsCollection.class, simpleRequest( GET, "fileplan-components/{fileplanComponentId}/children?{parameters}", filePlanComponentId, getParameters() @@ -135,15 +163,41 @@ public class FilePlanComponentAPI extends RestAPI { mandatoryObject("filePlanComponentProperties", filePlanComponentModel); mandatoryString("parentId", parentId); - - return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( - POST, - toJson(filePlanComponentModel), - "fileplan-components/{fileplanComponentId}/children?{parameters}", - parentId, - getParameters())); + + return createFilePlanComponent(filePlanComponentModel, parentId, EMPTY); } - + + /** + * Creates a file plan component with the given properties under the parent node with the given id + * + * @param filePlanComponentModel The properties of the file plan component to be created + * @param parameters The URL parameters to add + * @param parentId The id of the parent where the new file plan component should be created + * @return The {@link FilePlanComponent} with the given properties + * @throws Exception for the following cases: + *
    + *
  • {@code fileplanComponentId} is not a valid format
  • + *
  • authentication fails
  • + *
  • current user does not have permission to add children to {@code fileplanComponentId}
  • + *
  • {@code fileplanComponentId} does not exist
  • + *
  • new name clashes with an existing node in the current parent container
  • + *
  • model integrity exception, including node name with invalid characters
  • + *
+ */ + public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId, String parameters) throws Exception + { + mandatoryObject("filePlanComponentProperties", filePlanComponentModel); + mandatoryString("parentId", parentId); + + return getRMRestWrapper().processModel(FilePlanComponent.class, requestWithBody( + POST, + toJson(filePlanComponentModel), + "fileplan-components/{fileplanComponentId}/children?{parameters}", + parentId, + parameters + )); + } + /** * Create electronic record from file resource * @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created @@ -156,7 +210,7 @@ public class FilePlanComponentAPI extends RestAPI { return createElectronicRecord(electronicRecordModel, new File(Resources.getResource(fileName).getFile()), parentId); } - + /** * Create electronic record from file resource * @param electronicRecordModel {@link FilePlanComponent} for electronic record to be created @@ -167,53 +221,42 @@ public class FilePlanComponentAPI extends RestAPI */ public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception { - mandatoryObject("filePlanComponentProperties", electronicRecordModel); + mandatoryObject("electronicRecordModel", electronicRecordModel); mandatoryString("parentId", parentId); - if (!electronicRecordModel.getNodeType().equals(FilePlanComponentType.CONTENT_TYPE.toString())) + if (!electronicRecordModel.getNodeType().equals(CONTENT_TYPE)) { fail("Only electronic records are supported"); } - UserModel currentUser = usingRestWrapper().getTestUser(); - - /* + UserModel currentUser = getRMRestWrapper().getTestUser(); + + /* * For file uploads nodeBodyCreate is ignored hence can't be used. Append all FilePlanComponent fields * to the request. */ RequestSpecBuilder builder = new RequestSpecBuilder(); builder.setAuth(basic(currentUser.getUsername(), currentUser.getPassword())); - + ObjectMapper mapper = new ObjectMapper(); JsonNode root = mapper.readTree(toJson(electronicRecordModel)); Iterator fieldNames = root.fieldNames(); while (fieldNames.hasNext()) { - String f = fieldNames.next(); - try - { - builder.addMultiPart(f, root.get(f).asText(), ContentType.JSON.name()); - } - catch (Exception error) - { - LOG.error("Failed to set " + f + " error: " + error); - } + String fieldName = fieldNames.next(); + builder.addMultiPart(fieldName, root.get(fieldName).asText(), ContentType.JSON.name()); } - + builder.addMultiPart("filedata", recordContent, ContentType.BINARY.name()); - - /* - * RestWrapper adds some headers which break multipart/form-data uploads and also assumes json POST requests. * Upload the file using RestAssured library. */ Response response = given() .spec(builder.build()) .when() - .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getParameters()) + .post("fileplan-components/{fileplanComponentId}/children?{parameters}", parentId, getRMRestWrapper().getParameters()) .andReturn(); - usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode())); - LOG.info("electronic record created: " + response.getBody().prettyPrint()); - + getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode())); + /* return a FilePlanComponent object representing Response */ return response.jsonPath().getObject("entry", FilePlanComponent.class); } @@ -221,7 +264,7 @@ public class FilePlanComponentAPI extends RestAPI /** * Updates a file plan component * - * @param filePlanComponent The properties to be updated + * @param filePlanComponentModel The properties to be updated * @param filePlanComponentId The id of the file plan component which will be updated * @param returns The updated {@link FilePlanComponent} * @throws Exception for the following cases: @@ -234,17 +277,42 @@ public class FilePlanComponentAPI extends RestAPI *
  • model integrity exception, including node name with invalid characters
  • * */ - public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception + public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponentModel, String filePlanComponentId) throws Exception + { + mandatoryObject("filePlanComponentProperties", filePlanComponentModel); + mandatoryString("filePlanComponentId", filePlanComponentId); + + return updateFilePlanComponent(filePlanComponentModel, filePlanComponentId, EMPTY); + } + + /** + * Updates a file plan component + * + * @param filePlanComponentModel The properties to be updated + * @param parameters The URL parameters to add + * @param filePlanComponentId The id of the file plan component which will be updated + * @param returns The updated {@link FilePlanComponent} + * @throws Exception for the following cases: + *
      + *
    • the update request is invalid or {@code fileplanComponentId} is not a valid format or {@code filePlanComponentProperties} is invalid
    • + *
    • authentication fails
    • + *
    • current user does not have permission to update {@code fileplanComponentId}
    • + *
    • {@code fileplanComponentId} does not exist
    • + *
    • the updated name clashes with an existing node in the current parent folder
    • + *
    • model integrity exception, including node name with invalid characters
    • + *
    + */ + public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId, String parameters) throws Exception { mandatoryObject("filePlanComponentProperties", filePlanComponent); mandatoryString("filePlanComponentId", filePlanComponentId); - return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( + return getRMRestWrapper().processModel(FilePlanComponent.class, requestWithBody( PUT, toJson(filePlanComponent), "fileplan-components/{fileplanComponentId}?{parameters}", filePlanComponentId, - getParameters() + parameters )); } @@ -265,11 +333,10 @@ public class FilePlanComponentAPI extends RestAPI { mandatoryString("filePlanComponentId", filePlanComponentId); - usingRestWrapper().processEmptyModel(simpleRequest( + getRMRestWrapper().processEmptyModel(simpleRequest( DELETE, "fileplan-components/{fileplanComponentId}", filePlanComponentId )); } - } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMSiteAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMSiteAPI.java similarity index 78% rename from rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMSiteAPI.java rename to rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMSiteAPI.java index ee832f33a7..0b7ef5e80d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMSiteAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMSiteAPI.java @@ -24,7 +24,7 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.rest.rm.community.requests; +package org.alfresco.rest.rm.community.requests.igCoreAPI; import static org.alfresco.rest.core.RestRequest.requestWithBody; import static org.alfresco.rest.core.RestRequest.simpleRequest; @@ -36,26 +36,27 @@ import static org.springframework.http.HttpMethod.POST; import static org.springframework.http.HttpMethod.PUT; import static org.springframework.http.HttpStatus.OK; -import org.alfresco.rest.core.RestAPI; +import org.alfresco.rest.core.RMRestWrapper; import org.alfresco.rest.rm.community.model.site.RMSite; -import org.alfresco.utility.data.DataUser; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Component; +import org.alfresco.rest.rm.community.requests.RMModelRequest; /** - * File plan component REST API Wrapper + * RM Site REST API Wrapper * * @author Tuna Aksoy - * @author Rodica Sutu * @since 2.6 */ -@Component -@Scope (value = "prototype") -public class RMSiteAPI extends RestAPI +public class RMSiteAPI extends RMModelRequest { - @Autowired - private DataUser dataUser; + /** + * Constructor + * + * @param rmRestWrapper RM REST Wrapper + */ + public RMSiteAPI(RMRestWrapper rmRestWrapper) + { + super(rmRestWrapper); + } /** * Get the RM site @@ -71,7 +72,7 @@ public class RMSiteAPI extends RestAPI */ public RMSite getSite() throws Exception { - return usingRestWrapper().processModel(RMSite.class, simpleRequest( + return getRMRestWrapper().processModel(RMSite.class, simpleRequest( GET, "ig-sites/rm" )); @@ -90,13 +91,13 @@ public class RMSiteAPI extends RestAPI *
  • Api Response code default Unexpected error
  • * */ - public RMSite createRMSite(RMSite rmSite) throws Exception + public RMSite createRMSite(RMSite rmSiteModel) throws Exception { - mandatoryObject("rmSiteProperties", rmSite); + mandatoryObject("rmSiteModel", rmSiteModel); - return usingRestWrapper().processModel(RMSite.class, requestWithBody( + return getRMRestWrapper().processModel(RMSite.class, requestWithBody( POST, - toJson(rmSite), + toJson(rmSiteModel), "ig-sites" )); } @@ -114,7 +115,7 @@ public class RMSiteAPI extends RestAPI */ public void deleteRMSite() throws Exception { - usingRestWrapper().processEmptyModel(simpleRequest( + getRMRestWrapper().processEmptyModel(simpleRequest( DELETE, "ig-sites/rm" )); @@ -127,20 +128,20 @@ public class RMSiteAPI extends RestAPI * @return The updated {@link RMSite} * @throws Exception for the following cases: *
      - *
    • Api Response code 400 the update request is invalid {@code rmSiteProperties} is invalid
    • + *
    • Api Response code 400 the update request is invalid {@code rmSiteModel} is invalid
    • *
    • Api Response code 401 If authentication fails
    • *
    • Api Response code 403 does not have permission to update {@code RMSite}
    • - *
    • Api Response code 404 {@code RMSite} does not exist
    • + *
    • Api Response code 404 {@code RMSiteModel} does not exist
    • *
    • Api Response code default Unexpected error,model integrity exception
    • *
    */ - public RMSite updateRMSite(RMSite rmSiteProperties) throws Exception + public RMSite updateRMSite(RMSite rmSiteModel) throws Exception { - mandatoryObject("rmSiteProperties", rmSiteProperties); + mandatoryObject("rmSiteProperties", rmSiteModel); - return usingRestWrapper().processModel(RMSite.class, requestWithBody( + return getRMRestWrapper().processModel(RMSite.class, requestWithBody( PUT, - toJson(rmSiteProperties), + toJson(rmSiteModel), "ig-sites/rm" )); } @@ -159,8 +160,7 @@ public class RMSiteAPI extends RestAPI */ public boolean existsRMSite() throws Exception { - usingRestWrapper().authenticateUser(dataUser.getAdminUser()); getSite(); - return usingRestWrapper().getStatusCode().equals(OK.toString()); + return getRMRestWrapper().getStatusCode().equals(OK.toString()); } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMUserAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMUserAPI.java similarity index 52% rename from rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMUserAPI.java rename to rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMUserAPI.java index b5fc91be29..c03639c4ef 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/RMUserAPI.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RMUserAPI.java @@ -24,52 +24,62 @@ * along with Alfresco. If not, see . * #L% */ -package org.alfresco.rest.rm.community.requests; +package org.alfresco.rest.rm.community.requests.igCoreAPI; import static com.jayway.restassured.RestAssured.given; +import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; + +import com.google.gson.JsonObject; import com.jayway.restassured.builder.RequestSpecBuilder; +import com.jayway.restassured.http.ContentType; import com.jayway.restassured.response.Response; import com.jayway.restassured.specification.RequestSpecification; import org.alfresco.dataprep.AlfrescoHttpClient; import org.alfresco.dataprep.AlfrescoHttpClientFactory; +import org.alfresco.dataprep.UserService; import org.alfresco.rest.core.RestAPI; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** * RM user management API - * + * * @author Kristijan Conkas * @since 2.6 */ -// FIXME: As of December 2016 there is no v1-style API for managing RM users and users' -// roles. Until such APIs have become available, methods in this class are just proxies to +// FIXME: As of December 2016 there is no v1-style API for managing RM users and users' +// roles/permissions. Until such APIs have become available, methods in this class are just proxies to // "old-style" API calls. @Component @Scope (value = "prototype") public class RMUserAPI extends RestAPI { + @Autowired + private UserService userService; + @Autowired private DataUser dataUser; - + @Autowired private AlfrescoHttpClientFactory alfrescoHttpClientFactory; - + public void assignRoleToUser(String userName, String userRole) throws Exception { // get an "old-style" REST API client AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject(); - + // override v1 baseURI and basePath RequestSpecification spec = new RequestSpecBuilder() .setBaseUri(client.getApiUrl()) .setBasePath("/") .build(); - + Response response = given() .spec(spec) .log().all() @@ -83,4 +93,61 @@ public class RMUserAPI extends RestAPI .andReturn(); usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode())); } + + /** + * Helper method to add permission on a component to user + * @param component {@link FilePlanComponent} on which permission should be given + * @param user {@link UserModel} for a user to be granted permission + * @param permission {@link UserPermissions} to be granted + */ + public void addUserPermission(FilePlanComponent component, UserModel user, String permission) + { + // get an "old-style" REST API client + AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject(); + + JsonObject bodyJson = buildObject() + .addArray("permissions") + .addObject() + .add("authority", user.getUsername()) + .add("role", permission) + .end() + .getJson(); + + // override v1 baseURI and basePath + RequestSpecification spec = new RequestSpecBuilder() + .setBaseUri(client.getApiUrl()) + .setBasePath("/") + .build(); + + // execute an "old-style" API call + Response response = given() + .spec(spec) + .auth().basic(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword()) + .contentType(ContentType.JSON) + .body(bodyJson.toString()) + .pathParam("nodeId", component.getId()) + .log().all() + .when() + .post("/node/workspace/SpacesStore/{nodeId}/rmpermissions") + .prettyPeek() + .andReturn(); + usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode())); + } + + /** + * Creates a user with the given name using the old APIs + * + * @param userName The user name + * @return true if the user was created successfully, false otherwise. + */ + public boolean createUser(String userName) + { + return userService.create(dataUser.getAdminUser().getUsername(), + dataUser.getAdminUser().getPassword(), + userName, + "password", + "default@alfresco.com", + userName, + userName); + } } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RestIGCoreAPI.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RestIGCoreAPI.java new file mode 100644 index 0000000000..336933e39a --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/requests/igCoreAPI/RestIGCoreAPI.java @@ -0,0 +1,80 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.requests.igCoreAPI; + +import static java.lang.Integer.parseInt; +import static java.lang.String.format; + +import com.jayway.restassured.RestAssured; + +import org.alfresco.rest.core.RMRestProperties; +import org.alfresco.rest.core.RMRestWrapper; +import org.alfresco.rest.rm.community.requests.RMModelRequest; + +/** + * Defines the entire IG Core API + * {@link http://host:port/ig-api-explorer} select "IG Core API" + * + * @author Tuna Aksoy + * @since 2.6 + */ +public class RestIGCoreAPI extends RMModelRequest +{ + /** + * Constructor + * + * @param rmRestWrapper RM REST Wrapper + * @param rmRestProperties RM REST Properties + */ + public RestIGCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties) + { + super(rmRestWrapper); + RestAssured.baseURI = format("%s://%s", rmRestProperties.getScheme(), rmRestProperties.getServer()); + RestAssured.port = parseInt(rmRestProperties.getPort()); + RestAssured.basePath = rmRestProperties.getRestRmPath(); + } + + /** + * Provides DSL on all REST calls under ig-sites/rm/... API path + * + * @return {@link RMSiteAPI} + */ + public RMSiteAPI usingRMSite() + { + return new RMSiteAPI(getRMRestWrapper()); + } + + /** + * Provides DSL on all REST calls under fileplan-components/... API path + * + * @return {@link FilePlanComponentAPI} + */ + public FilePlanComponentAPI usingFilePlanComponents() + { + return new FilePlanComponentAPI(getRMRestWrapper()); + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java index 2181613152..7653f8ffc0 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java @@ -57,7 +57,6 @@ public class PojoUtility { //return the json object return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model); - } catch (JsonGenerationException e) { diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ReviewPeriodSerializer.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ReviewPeriodSerializer.java index 8680b83724..f4065cb748 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ReviewPeriodSerializer.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ReviewPeriodSerializer.java @@ -33,8 +33,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonSerializer; import com.fasterxml.jackson.databind.SerializerProvider; -import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod; - +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentReviewPeriod; /** * Utility class for serializing the Review Period type @@ -42,9 +41,8 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod; * @author Rodica Sutu * @since 2.6 */ -public class ReviewPeriodSerializer extends JsonSerializer +public class ReviewPeriodSerializer extends JsonSerializer { - /** * @param value The Review Period value that is being serialized. * @param gen Jackson utility is responsible for writing JSON @@ -53,12 +51,9 @@ public class ReviewPeriodSerializer extends JsonSerializer * @throws JsonProcessingException */ @Override - public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException + public void serialize(FilePlanComponentReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException { //create the custom string value for the Review Period type gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString()); - } } - - diff --git a/rm-automation/rm-automation-community-rest-api/src/test/resources/config.properties b/rm-automation/rm-automation-community-rest-api/src/main/resources/config.properties similarity index 100% rename from rm-automation/rm-automation-community-rest-api/src/test/resources/config.properties rename to rm-automation/rm-automation-community-rest-api/src/main/resources/config.properties 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 new file mode 100644 index 0000000000..a5e4b1825d --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRMRestTest.java @@ -0,0 +1,356 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2017 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.base; + +import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE; +import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createFilePlanComponentModel; +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel; +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.springframework.http.HttpStatus.CREATED; +import static org.springframework.http.HttpStatus.OK; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestAPIFactory; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.UserModel; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; + +/** + * Base class for all IG REST API Tests + * + * @author Kristijan Conkas + * @author Tuna Aksoy + * @since 2.6 + */ +public class BaseRMRestTest extends RestTest +{ + @Autowired + private RestAPIFactory restAPIFactory; + + @Autowired + private DataUser dataUser; + + /** + * Gets the REST API Factory + * + * @return the restAPIFactory The REST API Factory + */ + protected RestAPIFactory getRestAPIFactory() + { + return this.restAPIFactory; + } + + /** + * Gets the data user + * + * @return the dataUser The data user + */ + protected DataUser getDataUser() + { + return this.dataUser; + } + + /** + * Asserts the given status code + * + * @param statusCode The status code to assert + */ + protected void assertStatusCode(HttpStatus statusCode) + { + getRestAPIFactory().getRmRestWrapper().assertStatusCodeIs(statusCode); + } + + /** + * Gets the admin user + * + * @return The admin user + */ + protected UserModel getAdminUser() + { + return getDataUser().getAdminUser(); + } + + /** Valid root containers where electronic and non-electronic records can be created */ + @DataProvider(name = "validRootContainers") + public Object[][] getValidRootContainers() throws Exception + { + return new Object[][] + { + // an arbitrary record folder + { createCategoryFolderInFilePlan() }, + // unfiled records root + { getFilePlanComponent(UNFILED_RECORDS_CONTAINER_ALIAS) }, + // an arbitrary unfiled records folder + { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric()) } + }; + } + + /** + * @see org.alfresco.rest.RestTest#checkServerHealth() + */ + @Override + @BeforeClass (alwaysRun = true) + public void checkServerHealth() throws Exception + { + // Create RM Site if not exist + createRMSiteIfNotExists(); + } + + /** + * Helper method to create the RM Site via the POST request + * if the site doesn't exist + */ + public void createRMSiteIfNotExists() throws Exception + { + RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); + + // Check RM site doesn't exist + if (!rmSiteAPI.existsRMSite()) + { + // Create the RM site + rmSiteAPI.createRMSite(createStandardRMSiteModel()); + + // Verify the status code + assertStatusCode(CREATED); + } + } + + /** + * Helper method to create child category + * + * @param user The user under whose privileges this structure is going to be created + * @param parentCategoryId The id of the parent category + * @param categoryName The name of the category + * @return The created category + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createCategory(UserModel user, String parentCategoryId, String categoryName) throws Exception + { + return createComponent(user, parentCategoryId, categoryName, RECORD_CATEGORY_TYPE, CATEGORY_TITLE); + } + + /** + * Helper method to create child category as the admin user + * + * @param parentCategoryId The id of the parent category + * @param categoryName The name of the category + * @return The created category + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createCategory(String parentCategoryId, String categoryName) throws Exception + { + return createCategory(getAdminUser(), parentCategoryId, categoryName); + } + + /** + * Helper method to create child folder + * + * @param user The user under whose privileges this structure is going to be created + * @param parentCategoryId The id of the parent category + * @param folderName The name of the category + * @return The created category + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createFolder(UserModel user, String parentCategoryId, String folderName) throws Exception + { + return createComponent(user, parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE); + } + + /** + * Helper method to create child folder as the admin user + * + * @param parentCategoryId The id of the parent category + * @param folderName The name of the category + * @return The created category + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createFolder(String parentCategoryId, String folderName) throws Exception + { + return createFolder(getAdminUser(), parentCategoryId, folderName); + } + + /** + * Helper method to create child unfiled record folder + * + * @param user The user under whose privileges this structure is going to be created + * @param parentId The id of the parent folder + * @param folderName The name of the folder + * @return The created folder + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createUnfiledRecordsFolder(UserModel user, String parentId, String folderName) throws Exception + { + return createComponent(user, parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE); + } + + /** + * Helper method to create child unfiled record folder as the admin user + * + * @param parentId The id of the parent folder + * @param folderName The name of the folder + * @return The created folder + * @throws Exception on unsuccessful component creation + */ + public FilePlanComponent createUnfiledRecordsFolder(String parentId, String folderName) throws Exception + { + return createUnfiledRecordsFolder(getAdminUser(), parentId, folderName); + } + + /** + * Helper method to create generic child component + * + * @param user user under whose privileges this structure is going to be created + * @param parentComponentId The id of the parent file plan component + * @param componentName The name of the file plan component + * @param componentType The type of the file plan component + * @param componentTitle The title of the file plan component + * @return The created file plan component + * @throws Exception + */ + private FilePlanComponent createComponent(UserModel user, String parentComponentId, String componentName, String componentType, String componentTitle) throws Exception + { + FilePlanComponent filePlanComponentModel = createFilePlanComponentModel(componentName, componentType, componentTitle); + FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI(user).createFilePlanComponent(filePlanComponentModel, parentComponentId); + assertStatusCode(CREATED); + + return filePlanComponent; + } + + /** + * Helper method to close folder + * + * @param folderId The id of the folder + * @return The closed folder + * @throws Exception + */ + protected FilePlanComponent closeFolder(String folderId) throws Exception + { + // build file plan component + properties for update request + FilePlanComponentProperties properties = new FilePlanComponentProperties(); + properties.setIsClosed(true); + FilePlanComponent filePlanComponent = new FilePlanComponent(); + filePlanComponent.setProperties(properties); + + FilePlanComponent updatedComponent = getRestAPIFactory().getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, folderId); + assertStatusCode(OK); + return updatedComponent; + } + + /** + * Helper method to create a randomly-named / structure in file plan + * + * @param user The user under whose privileges this structure is going to be created + * @param parentId parent container id + * @return record folder + * @throws Exception on failed creation + */ + public FilePlanComponent createCategoryFolderInFilePlan(UserModel user) throws Exception + { + // create root category + FilePlanComponent recordCategory = createCategory(user, FILE_PLAN_ALIAS, "Category " + getRandomAlphanumeric()); + + // and return a folder underneath + return createFolder(user, recordCategory.getId(), "Folder " + getRandomAlphanumeric()); + } + + /** + * Helper method to create a randomly-named / structure in file plan as the admin user + * + * @param parentId parent container id + * @return record folder + * @throws Exception on failed creation + */ + public FilePlanComponent createCategoryFolderInFilePlan() throws Exception + { + return createCategoryFolderInFilePlan(getAdminUser()); + } + + /** + * Helper method to retrieve a file plan component with user's privilege + * + * @param user user under whose privileges a component is to be read + * @param componentId id of the component to read + * @return {@link FilePlanComponent} for given componentId + * @throws Exception if user doesn't have sufficient privileges + */ + public FilePlanComponent getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception + { + return getRestAPIFactory().getFilePlanComponentsAPI(user).getFilePlanComponent(componentId); + } + + /** + * Helper method to retrieve a file plan component with user's privilege as the admin user + * + * @param componentId id of the component to read + * @return {@link FilePlanComponent} for given componentId + * @throws Exception if user doesn't have sufficient privileges + */ + public FilePlanComponent getFilePlanComponent(String componentId) throws Exception + { + return getFilePlanComponentAsUser(getAdminUser(), componentId); + } + + /** + * Create temp file with content + * + * @param name file name + * @return {@link File} file + */ + public static File createTempFile(final String name,String content) + { + try + { + // create file + final File file = File.createTempFile(name, ".txt"); + + // create writer + try (FileOutputStream fos = new FileOutputStream(file); + OutputStreamWriter writer = new OutputStreamWriter(fos, Charset.forName("UTF-8").newEncoder())) + { + // place content in file + writer.write(content); + } + + return file; + } catch (Exception exception) + { + throw new RuntimeException("Unable to create test file.", exception); + } + } +} diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java deleted file mode 100644 index 23aa715f04..0000000000 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/BaseRestTest.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * #%L - * Alfresco Records Management Module - * %% - * Copyright (C) 2005 - 2017 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.base; - -import static java.lang.Integer.parseInt; - -import static com.jayway.restassured.RestAssured.given; - -import static org.alfresco.rest.rm.community.base.TestData.CATEGORY_TITLE; -import static org.alfresco.rest.rm.community.base.TestData.FOLDER_TITLE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; -import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD; -import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; -import static org.springframework.http.HttpStatus.CREATED; -import static org.springframework.http.HttpStatus.OK; - -import com.google.gson.JsonObject; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; -import java.nio.charset.Charset; - -import com.jayway.restassured.RestAssured; -import com.jayway.restassured.builder.RequestSpecBuilder; -import com.jayway.restassured.http.ContentType; -import com.jayway.restassured.response.Response; -import com.jayway.restassured.specification.RequestSpecification; - -import org.alfresco.dataprep.AlfrescoHttpClient; -import org.alfresco.dataprep.AlfrescoHttpClientFactory; -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType; -import org.alfresco.rest.rm.community.model.site.RMSite; -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; -import org.alfresco.rest.rm.community.requests.RMSiteAPI; -import org.alfresco.utility.data.DataUser; -import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.DataProvider; - -/** - * Base class for all IG REST API Tests - * - * @author Kristijan Conkas - * @author Tuna Aksoy - * @since 2.6 - */ -@Configuration -@PropertySource(value = {"classpath:default.properties", "classpath:config.properties"}) -@PropertySource(value = "classpath:module.properties", ignoreResourceNotFound = true) -@PropertySource(value = "classpath:local.properties", ignoreResourceNotFound = true) -public class BaseRestTest extends RestTest -{ - @Value ("${alfresco.scheme}") - private String scheme; - - @Value ("${alfresco.server}") - private String server; - - @Value ("${alfresco.port}") - private String port; - - @Value ("${rest.rmPath}") - private String restRmPath; - - @Value ("${rest.basePath}") - private String restCorePath; - - @Autowired - private RMSiteAPI rmSiteAPI; - - @Autowired - private DataUser dataUser; - - @Autowired - public FilePlanComponentAPI filePlanComponentAPI; - - @Autowired - private AlfrescoHttpClientFactory alfrescoHttpClientFactory; - - // Constants - public static final String RM_ID = "rm"; - public static final String RM_TITLE = "Records Management"; - public static final String RM_DESCRIPTION = "Records Management Site"; - - /** Valid root containers where electronic and non-electronic records can be created */ - @DataProvider(name = "validRootContainers") - public Object[][] getValidRootContainers() throws Exception { - return new Object[][] { - // an arbitrary record folder - { createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, - // unfiled records root - { getFilePlanComponentAsUser(dataUser.getAdminUser(), UNFILED_RECORDS_CONTAINER_ALIAS.toString()) }, - // an arbitrary unfiled records folder - { createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), "Unfiled Folder " + getRandomAlphanumeric()) } - }; - } - - /** - * @see org.alfresco.rest.RestTest#checkServerHealth() - */ - @Override - @BeforeClass (alwaysRun = true) - public void checkServerHealth() throws Exception - { - RestAssured.baseURI = scheme + "://" + server; - RestAssured.port = parseInt(port); - RestAssured.basePath = restRmPath; - - // Create RM Site if not exist - createRMSiteIfNotExists(); - } - - /** - * Helper method to create the RM Site via the POST request - * if the site doesn't exist - */ - public void createRMSiteIfNotExists() throws Exception - { - // Check RM site doesn't exist - if (!rmSiteAPI.existsRMSite()) - { - rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - - // Create the RM site - RMSite rmSite = RMSite.builder().compliance(STANDARD).build(); - rmSite.setTitle(RM_TITLE); - rmSite.setDescription(RM_DESCRIPTION); - rmSiteAPI.createRMSite(rmSite); - - // Verify the status code - rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED); - } - } - - /** - * Helper method to create child category - * - * @param parentCategoryId The id of the parent category - * @param categoryName The name of the category - * @return The created category - * @throws Exception on unsuccessful component creation - */ - public FilePlanComponent createCategory(String parentCategoryId, String categoryName) throws Exception - { - return createComponent(parentCategoryId, categoryName, RECORD_CATEGORY_TYPE, CATEGORY_TITLE); - } - - /** - * Helper method to create child folder - * - * @param parentCategoryId The id of the parent category - * @param folderName The name of the category - * @return The created category - * @throws Exception on unsuccessful component creation - */ - public FilePlanComponent createFolder(String parentCategoryId, String folderName) throws Exception - { - return createComponent(parentCategoryId, folderName, RECORD_FOLDER_TYPE, FOLDER_TITLE); - } - - /** - * Helper method to create child unfiled record folder - * - * @param parentId The id of the parent folder - * @param folderName The name of the folder - * @return The created folder - * @throws Exception on unsuccessful component creation - */ - public FilePlanComponent createUnfiledRecordsFolder(String parentId, String folderName) throws Exception - { - return createComponent(parentId, folderName, UNFILED_RECORD_FOLDER_TYPE, FOLDER_TITLE); - } - - /** - * Helper method to create generic child component - * - * @param parentComponentId The id of the parent file plan component - * @param componentName The name of the file plan component - * @param componentType The name of the file plan component - * @param componentTitle - * @return The created file plan component - * @throws Exception - */ - private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType, String componentTitle) throws Exception - { - RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - - FilePlanComponent filePlanComponent = FilePlanComponent.builder() - .name(componentName) - .nodeType(componentType.toString()) - .properties(FilePlanComponentProperties.builder() - .title(componentTitle) - .build()) - .build(); - - FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId); - restWrapper.assertStatusCodeIs(CREATED); - return fpc; - } - - /** - * Helper method to close folder - * @param folderId - * @return - * @throws Exception - */ - public FilePlanComponent closeFolder(String folderId) throws Exception - { - RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - - // build fileplan component + properties for update request - FilePlanComponentProperties properties = new FilePlanComponentProperties(); - properties.setIsClosed(true); - FilePlanComponent filePlanComponent = new FilePlanComponent(); - filePlanComponent.setProperties(properties); - - FilePlanComponent updatedComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent, folderId); - restWrapper.assertStatusCodeIs(OK); - return updatedComponent; - } - - /** - * Helper method to create a randomly-named / structure in fileplan - * @param user user under whose privileges this structure is going to be created - * @param parentId parent container id - * @return record folder - * @throws Exception on failed creation - */ - public FilePlanComponent createCategoryFolderInFilePlan(UserModel user, String parentId) throws Exception - { - filePlanComponentAPI.usingRestWrapper().authenticateUser(user); - - // create root category - FilePlanComponent recordCategory = createCategory(parentId, "Category " + getRandomAlphanumeric()); - - // and return a folder underneath - return createFolder(recordCategory.getId(), "Folder " + getRandomAlphanumeric()); - } - - /** - * Helper method to retieve a fileplan component with user's privilege - * @param user user under whose privileges a component is to be read - * @param componentId id of the component to read - * @return {@link FilePlanComponent} for given componentId - * @throws Exception if user doesn't have sufficient privileges - */ - public FilePlanComponent getFilePlanComponentAsUser(UserModel user, String componentId) throws Exception - { - filePlanComponentAPI.usingRestWrapper().authenticateUser(user); - return filePlanComponentAPI.getFilePlanComponent(componentId); - } - - - /** - * Helper method to add permission on a component to user - * @param component {@link FilePlanComponent} on which permission should be given - * @param user {@link UserModel} for a user to be granted permission - * @param permission {@link UserPermissions} to be granted - */ - // FIXME: As of December 2016 there is no v1-style API for managing RM permissions. - // Until such APIs have become available, this method is just a proxy to an "old-style" - // API call. - public void addUserPermission(FilePlanComponent component, UserModel user, String permission) - { - // get an "old-style" REST API client - AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject(); - - JsonObject bodyJson = buildObject() - .addArray("permissions") - .addObject() - .add("authority", user.getUsername()) - .add("role", permission) - .end() - .getJson(); - - // override v1 baseURI and basePath - RequestSpecification spec = new RequestSpecBuilder() - .setBaseUri(client.getApiUrl()) - .setBasePath("/") - .build(); - - // execute an "old-style" API call - Response response = given() - .spec(spec) - .auth().basic(dataUser.getAdminUser().getUsername(), dataUser.getAdminUser().getPassword()) - .contentType(ContentType.JSON) - .body(bodyJson.toString()) - .pathParam("nodeId", component.getId()) - .log().all() - .when() - .post("/node/workspace/SpacesStore/{nodeId}/rmpermissions") - .prettyPeek() - .andReturn(); - filePlanComponentAPI.usingRestWrapper().setStatusCode(Integer.toString(response.getStatusCode())); - } - - - /** - * Create temp file with content - * - * @param name file name - * @return {@link File} file - */ - public static File createTempFile(final String name,String content) - { - try - { - // create file - final File file = File.createTempFile(name, ".txt"); - - // create writer - try (FileOutputStream fos = new FileOutputStream(file); - OutputStreamWriter writer = new OutputStreamWriter(fos, Charset.forName("UTF-8").newEncoder())) - { - // place content in file - writer.write(content); - } - - return file; - } catch (Exception exception) - { - throw new RuntimeException("Unable to create test file.", exception); - } - } -} diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java index 3f580510c5..4c5f6840ec 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/base/TestData.java @@ -50,7 +50,7 @@ import org.testng.annotations.DataProvider; * @since 2.6 */ public interface TestData -{ +{ /** * A user with ALFRESCO_ADMINISTRATORS role. *

    "GROUP_ANOTHER_ADMIN_EXISTS" The ANOTHER_ADMIN user has been created. @@ -75,10 +75,10 @@ public interface TestData public static Object[][] getContainers() { return new Object[][] { - { FILE_PLAN_ALIAS.toString() }, - { TRANSFERS_ALIAS.toString() }, - { HOLDS_ALIAS.toString() }, - { UNFILED_RECORDS_CONTAINER_ALIAS.toString() }, + { FILE_PLAN_ALIAS }, + { TRANSFERS_ALIAS }, + { HOLDS_ALIAS }, + { UNFILED_RECORDS_CONTAINER_ALIAS }, }; } @@ -102,7 +102,7 @@ public interface TestData /** * The default CATEGORY name used when creating categories */ - public static String CATEGORY_NAME = "CATEGORY NAME"+ getRandomAlphanumeric(); + public static String CATEGORY_NAME = "CATEGORY NAME" + getRandomAlphanumeric(); /** * The default CATEGORY title used when creating categories @@ -130,15 +130,15 @@ public interface TestData public static Object[][] childrenNotAllowedForCategory() { return new Object[][] { - { FILE_PLAN_TYPE.toString() }, - { TRANSFER_CONTAINER_TYPE.toString() }, - { HOLD_CONTAINER_TYPE.toString() }, - { UNFILED_CONTAINER_TYPE.toString() }, - { UNFILED_RECORD_FOLDER_TYPE.toString()}, - { HOLD_TYPE.toString()}, - { TRANSFER_TYPE.toString()}, - { FOLDER_TYPE.toString()}, - { CONTENT_TYPE.toString()} + { FILE_PLAN_TYPE }, + { TRANSFER_CONTAINER_TYPE }, + { HOLD_CONTAINER_TYPE }, + { UNFILED_CONTAINER_TYPE }, + { UNFILED_RECORD_FOLDER_TYPE }, + { HOLD_TYPE }, + { TRANSFER_TYPE }, + { FOLDER_TYPE }, + { CONTENT_TYPE } }; } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/DeleteRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/DeleteRecordTests.java index e5d9e5e02e..f26a601606 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/DeleteRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/DeleteRecordTests.java @@ -26,27 +26,24 @@ */ package org.alfresco.rest.rm.community.fileplancomponents; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE; -import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; 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.NO_CONTENT; import static org.springframework.http.HttpStatus.OK; -import org.alfresco.rest.rm.community.base.BaseRestTest; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.community.model.user.UserPermissions; import org.alfresco.rest.rm.community.model.user.UserRoles; -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; -import org.alfresco.rest.rm.community.requests.RMSiteAPI; -import org.alfresco.rest.rm.community.requests.RMUserAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI; import org.alfresco.test.AlfrescoTest; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; import org.springframework.beans.factory.annotation.Autowired; @@ -61,22 +58,10 @@ import org.testng.annotations.Test; * @author Kristijan Conkas * @since 2.6 */ -public class DeleteRecordTests extends BaseRestTest +public class DeleteRecordTests extends BaseRMRestTest { - @Autowired - private FilePlanComponentAPI filePlanComponentAPI; - @Autowired private RMUserAPI rmUserAPI; - - @Autowired - private DataUser dataUser; - - @Autowired - private RMSiteAPI rmSiteAPI; - - /** image resource file to be used for records body */ - private static final String IMAGE_FILE = "money.JPG"; /** *

    @@ -86,7 +71,7 @@ public class DeleteRecordTests extends BaseRestTest
          * When I delete the record
          * Then it is deleted from the file plan
          * 
    - * + * * @param container * @throws Exception */ @@ -98,19 +83,13 @@ public class DeleteRecordTests extends BaseRestTest @AlfrescoTest(jira="RM-4363") public void adminCanDeleteElectronicRecord(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + FilePlanComponent newRecord = getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId()); - // create an electronic record - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(CONTENT_TYPE.toString()) - .build(); - FilePlanComponent newRecord = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + assertStatusCode(CREATED); deleteAndVerify(newRecord); } - + /** *
          * Given a record
    @@ -119,7 +98,7 @@ public class DeleteRecordTests extends BaseRestTest
          * When I delete the record
          * Then it is deleted from the file plan
          * 
    - * + * * @param container * @throws Exception */ @@ -131,21 +110,14 @@ public class DeleteRecordTests extends BaseRestTest @AlfrescoTest(jira="RM-4363") public void adminCanDeleteNonElectronicRecord(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // create a non-electronic record - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) - .build(); - FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( - record, - container.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + FilePlanComponent newRecord = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), container.getId()); + + assertStatusCode(CREATED); deleteAndVerify(newRecord); } - + /** *
          * Given a record
    @@ -154,7 +126,7 @@ public class DeleteRecordTests extends BaseRestTest
          * Then nothing happens
          * And error gets reported
          * 
    - * + * * @param container * @throws Exception */ @@ -165,37 +137,26 @@ public class DeleteRecordTests extends BaseRestTest @AlfrescoTest(jira="RM-4363") public void userWithoutWritePermissionsCantDeleteRecord() throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // create a non-electronic record in unfiled records - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) - .build(); - FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( - record, - UNFILED_RECORDS_CONTAINER_ALIAS.toString()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); - + FilePlanComponent newRecord = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), UNFILED_RECORDS_CONTAINER_ALIAS); + + assertStatusCode(CREATED); + // create test user and add it with collab. privileges - UserModel deleteUser = dataUser.createRandomTestUser("delnoperm"); + UserModel deleteUser = getDataUser().createRandomTestUser("delnoperm"); deleteUser.setUserRole(UserRole.SiteCollaborator); logger.info("test user: " + deleteUser.getUsername()); - dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator); - + getDataUser().addUserToSite(deleteUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator); + // add RM role to user rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER); rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK); - - // log in as deleteUser - filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser); - + // try to delete newRecord - filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + getRestAPIFactory().getFilePlanComponentsAPI(deleteUser).deleteFilePlanComponent(newRecord.getId()); + assertStatusCode(FORBIDDEN); } - + /** *
          * Given a record
    @@ -204,7 +165,7 @@ public class DeleteRecordTests extends BaseRestTest
          * Then nothing happens
          * And error gets reported
          * 
    - * + * * @param container * @throws Exception */ @@ -215,51 +176,41 @@ public class DeleteRecordTests extends BaseRestTest @AlfrescoTest(jira="RM-4363") public void userWithoutDeleteRecordsCapabilityCantDeleteRecord() throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // create test user and add it with collab. privileges - UserModel deleteUser = dataUser.createRandomTestUser("delnoperm"); + UserModel deleteUser = getDataUser().createRandomTestUser("delnoperm"); deleteUser.setUserRole(UserRole.SiteCollaborator); - dataUser.addUserToSite(deleteUser, new SiteModel(rmSiteAPI.getSite().getId()), UserRole.SiteCollaborator); + getDataUser().addUserToSite(deleteUser, new SiteModel(getRestAPIFactory().getRMSiteAPI().getSite().getId()), UserRole.SiteCollaborator); logger.info("test user: " + deleteUser.getUsername()); - + // add RM role to user, RM Power User doesn't have the Delete Record capabilities rmUserAPI.assignRoleToUser(deleteUser.getUsername(), UserRoles.ROLE_RM_POWER_USER); rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK); - + // create random folder - FilePlanComponent randomFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()); + FilePlanComponent randomFolder = createCategoryFolderInFilePlan(); logger.info("random folder:" + randomFolder.getName()); - + // grant deleteUser Filing privileges on randomFolder category, this will be // inherited to randomFolder - addUserPermission(filePlanComponentAPI.getFilePlanComponent(randomFolder.getParentId()), + FilePlanComponentAPI filePlanComponentsAPIAsAdmin = getRestAPIFactory().getFilePlanComponentsAPI(); + rmUserAPI.addUserPermission(filePlanComponentsAPIAsAdmin.getFilePlanComponent(randomFolder.getParentId()), deleteUser, UserPermissions.PERMISSION_FILING); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); - - // create a non-electronic record in randomFolder - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString()) - .build(); - FilePlanComponent newRecord = filePlanComponentAPI.createFilePlanComponent( - record, - randomFolder.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + rmUserAPI.usingRestWrapper().assertStatusCodeIs(OK); + + // create a non-electronic record in randomFolder + FilePlanComponent newRecord = filePlanComponentsAPIAsAdmin.createFilePlanComponent(createNonElectronicRecordModel(), randomFolder.getId()); + assertStatusCode(CREATED); - // log in as deleteUser - filePlanComponentAPI.usingRestWrapper().authenticateUser(deleteUser); - // verify the user can see the newRecord - filePlanComponentAPI.getFilePlanComponent(newRecord.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); - + FilePlanComponentAPI filePlanComponentsAPIAsUser = getRestAPIFactory().getFilePlanComponentsAPI(deleteUser); + filePlanComponentsAPIAsUser.getFilePlanComponent(newRecord.getId()); + assertStatusCode(OK); + // try to delete newRecord - filePlanComponentAPI.deleteFilePlanComponent(newRecord.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + filePlanComponentsAPIAsUser.deleteFilePlanComponent(newRecord.getId()); + assertStatusCode(FORBIDDEN); } - + /** * Utility method to delete a record and verify successful deletion * @param record @@ -267,14 +218,14 @@ public class DeleteRecordTests extends BaseRestTest */ private void deleteAndVerify(FilePlanComponent record) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + // delete it and verify status - filePlanComponentAPI.deleteFilePlanComponent(record.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NO_CONTENT); - + filePlanComponentsAPI.deleteFilePlanComponent(record.getId()); + assertStatusCode(NO_CONTENT); + // try to get deleted file plan component - filePlanComponentAPI.getFilePlanComponent(record.getId()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND); + filePlanComponentsAPI.getFilePlanComponent(record.getId()); + assertStatusCode(NOT_FOUND); } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java index f35c36cfbc..5ab98ae61c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ElectronicRecordTests.java @@ -32,18 +32,17 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; -import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.IMAGE_FILE; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createElectronicRecordModel; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.rm.community.base.BaseRestTest; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; -import org.alfresco.utility.data.DataUser; -import org.springframework.beans.factory.annotation.Autowired; +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -56,30 +55,22 @@ import org.testng.annotations.Test; * @author Kristijan Conkas * @since 2.6 */ -public class ElectronicRecordTests extends BaseRestTest +public class ElectronicRecordTests extends BaseRMRestTest { - @Autowired - private FilePlanComponentAPI filePlanComponentAPI; - - @Autowired - private DataUser dataUser; - - /** image resource file to be used for records body */ - private static final String IMAGE_FILE = "money.JPG"; - /** Valid root containers where electronic records can be created */ @DataProvider(name = "invalidParentContainers") - public Object[][] invalidContainers() throws Exception { - return new Object[][] { + public Object[][] invalidContainers() throws Exception + { + return new Object[][] + { // record category - { getFilePlanComponentAsUser(dataUser.getAdminUser(), - createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()).getParentId()) }, + { getFilePlanComponent(createCategoryFolderInFilePlan().getParentId()) }, // file plan root - { getFilePlanComponentAsUser(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()) }, + { getFilePlanComponent(FILE_PLAN_ALIAS) }, // transfers - { getFilePlanComponentAsUser(dataUser.getAdminUser(), TRANSFERS_ALIAS.toString()) }, + { getFilePlanComponent(TRANSFERS_ALIAS) }, // holds - { getFilePlanComponentAsUser(dataUser.getAdminUser(), HOLDS_ALIAS.toString()) }, + { getFilePlanComponent(HOLDS_ALIAS) }, }; } @@ -100,17 +91,11 @@ public class ElectronicRecordTests extends BaseRestTest ) public void cantCreateElectronicRecordsInInvalidContainers(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Build object the filePlan - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(CONTENT_TYPE.toString()) - .build(); - filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()); + getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, container.getId()); // verify the create request status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + assertStatusCode(UNPROCESSABLE_ENTITY); } /** @@ -126,8 +111,7 @@ public class ElectronicRecordTests extends BaseRestTest @Test(description = "Electronic record can't be created in closed record folder") public void cantCreateElectronicRecordInClosedFolder() throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString()); + FilePlanComponent recordFolder = createCategoryFolderInFilePlan(); // the folder should be open assertFalse(recordFolder.getProperties().getIsClosed()); @@ -136,14 +120,10 @@ public class ElectronicRecordTests extends BaseRestTest closeFolder(recordFolder.getId()); // try to create it, this should fail - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(CONTENT_TYPE.toString()) - .build(); - filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, recordFolder.getId()); + getRestAPIFactory().getFilePlanComponentsAPI().createElectronicRecord(createElectronicRecordModel(), IMAGE_FILE, recordFolder.getId()); // verify the status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + assertStatusCode(UNPROCESSABLE_ENTITY); } /** @@ -173,10 +153,9 @@ public class ElectronicRecordTests extends BaseRestTest ) public void canCreateElectronicRecordOnlyWithMandatoryProperties(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - logger.info("Root container:\n" + toJson(container)); - if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString())) + + if (container.getNodeType().equals(RECORD_FOLDER_TYPE)) { // only record folders can be open or closed assertFalse(container.getProperties().getIsClosed()); @@ -184,14 +163,14 @@ public class ElectronicRecordTests extends BaseRestTest // component without name FilePlanComponent record = FilePlanComponent.builder() - .nodeType(CONTENT_TYPE.toString()) + .nodeType(CONTENT_TYPE) .build(); // try to create it - filePlanComponentAPI.createFilePlanComponent(record, container.getId()); + getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(record, container.getId()); // verify the status code is BAD_REQUEST - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST); + assertStatusCode(BAD_REQUEST); } /** @@ -218,19 +197,15 @@ public class ElectronicRecordTests extends BaseRestTest ) public void canCreateElectronicRecordsInValidContainers(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - - FilePlanComponent record = FilePlanComponent.builder() - .name("Record " + getRandomAlphanumeric()) - .nodeType(CONTENT_TYPE.toString()) - .build(); - String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); + FilePlanComponent record = createElectronicRecordModel(); + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + String newRecordId = filePlanComponentsAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); // verify the create request status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + assertStatusCode(CREATED); - // get newly created electonic record and verify its properties - FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); + // get newly created electronic record and verify its properties + FilePlanComponent electronicRecord = filePlanComponentsAPI.getFilePlanComponent(newRecordId); // created record will have record identifier inserted in its name but will be prefixed with // the name it was created as assertTrue(electronicRecord.getName().startsWith(record.getName())); @@ -249,20 +224,19 @@ public class ElectronicRecordTests extends BaseRestTest ) public void recordNameDerivedFromFileName(FilePlanComponent container) throws Exception { - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // record object without name set FilePlanComponent record = FilePlanComponent.builder() - .nodeType(CONTENT_TYPE.toString()) + .nodeType(CONTENT_TYPE) .build(); - String newRecordId = filePlanComponentAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); + String newRecordId = filePlanComponentsAPI.createElectronicRecord(record, IMAGE_FILE, container.getId()).getId(); // verify the create request status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + assertStatusCode(CREATED); // get newly created electonic record and verify its properties - FilePlanComponent electronicRecord = filePlanComponentAPI.getFilePlanComponent(newRecordId); + FilePlanComponent electronicRecord = filePlanComponentsAPI.getFilePlanComponent(newRecordId); // record will have record identifier inserted in its name but will for sure start with file name // and end with its extension assertTrue(electronicRecord.getName().startsWith(IMAGE_FILE.substring(0, IMAGE_FILE.indexOf(".")))); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java index 9ffe5ab58c..f1aee9ce2e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/FilePlanTests.java @@ -43,19 +43,14 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import org.alfresco.rest.core.RestWrapper; -import org.alfresco.rest.rm.community.base.BaseRestTest; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.TestData; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType; -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; -import org.alfresco.rest.rm.community.requests.RMSiteAPI; -import org.alfresco.utility.data.DataUser; +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI; import org.alfresco.utility.model.UserModel; import org.alfresco.utility.report.Bug; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; /** @@ -65,20 +60,8 @@ import org.testng.annotations.Test; * @author Rodica Sutu * @since 2.6 */ -public class FilePlanTests extends BaseRestTest +public class FilePlanTests extends BaseRMRestTest { - @Autowired - private FilePlanComponentAPI filePlanComponentAPI; - - @Autowired - protected RestWrapper restWrapper; - - @Autowired - private RMSiteAPI rmSiteAPI; - - @Autowired - private DataUser dataUser; - /** * Given that the RM site doesn't exist * When I use the API to get the File Plan/Holds/Unfiled Records Container/Transfers @@ -90,8 +73,10 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainers" ) - public void getFilePlanComponentWhenRMIsNotCreated(String filePlanAlias) throws Exception + public void getFilePlanComponentWhenRMIsNotCreated(String filePlanComponentAlias) throws Exception { + RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI(); + // Check RM Site Exist if (rmSiteAPI.existsRMSite()) { @@ -99,18 +84,13 @@ public class FilePlanTests extends BaseRestTest rmSiteAPI.deleteRMSite(); } - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Get the file plan component - filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString()); + getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias); //check the response code is NOT_FOUND - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND); + assertStatusCode(NOT_FOUND); } - - /** * Given that a file plan exists * When I ask the API for the details of the file plan @@ -122,22 +102,19 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainersAndTypes" ) - public void getFilePlanComponentWhenRMIsCreated(FilePlanComponentAlias filePlanAlias, FilePlanComponentType rmType) throws Exception + public void getFilePlanComponentWhenRMIsCreated(String filePlanComponentAlias, String filePlanComponentType) throws Exception { // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Get the file plan special container - FilePlanComponent filePlanComponent = filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString()); + FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(filePlanComponentAlias); // Check the response code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + assertStatusCode(OK); // Check the response contains the right node type - assertEquals(filePlanComponent.getNodeType(), rmType.toString()); + assertEquals(filePlanComponent.getNodeType(), filePlanComponentType); } /** @@ -156,14 +133,11 @@ public class FilePlanTests extends BaseRestTest // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Get the file plan special containers with the optional parameter allowableOperations - FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include="+ ALLOWABLE_OPERATIONS).getFilePlanComponent(specialContainerAlias); + FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(specialContainerAlias, "include=" + ALLOWABLE_OPERATIONS); // Check the list of allowableOperations returned - if(specialContainerAlias.equals(TRANSFERS_ALIAS.toString())) + if(specialContainerAlias.equals(TRANSFERS_ALIAS)) { assertTrue(filePlanComponent.getAllowableOperations().containsAll(asList(UPDATE)), "Wrong list of the allowable operations is return" + filePlanComponent.getAllowableOperations().toString()); @@ -195,9 +169,6 @@ public class FilePlanTests extends BaseRestTest // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Build object for updating the filePlan FilePlanComponent filePlanComponent = FilePlanComponent.builder() .properties(FilePlanComponentProperties.builder() @@ -207,10 +178,10 @@ public class FilePlanTests extends BaseRestTest .build(); // Update the record category - FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString()); + FilePlanComponent renamedFilePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().updateFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS); // Verify the response status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); + assertStatusCode(OK); // Verify the returned description field for the file plan component assertEquals(renamedFilePlanComponent.getProperties().getDescription(), FILE_PLAN_DESCRIPTION); @@ -230,19 +201,16 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainers" ) - public void deleteFilePlanSpecialComponents(String filePlanAlias) throws Exception + public void deleteFilePlanSpecialComponents(String filePlanComponentAlias) throws Exception { // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Delete the file plan component - filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString()); + getRestAPIFactory().getFilePlanComponentsAPI().deleteFilePlanComponent(filePlanComponentAlias); // Check the DELETE response status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + assertStatusCode(UNPROCESSABLE_ENTITY); } /** @@ -256,27 +224,19 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainers" ) - public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception + public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanComponentAlias) throws Exception { // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Disconnect the current user from the API session - rmSiteAPI.usingRestWrapper().disconnect(); - // Authenticate admin user to Alfresco REST API - restClient.authenticateUser(dataUser.getAdminUser()); - // Create a random user - UserModel nonRMuser = dataUser.createRandomTestUser("testUser"); - - // Authenticate using the random user - filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser); + UserModel nonRMuser = getDataUser().createRandomTestUser("testUser"); // Delete the file plan component - filePlanComponentAPI.deleteFilePlanComponent(filePlanAlias.toString()); + getRestAPIFactory().getFilePlanComponentsAPI(nonRMuser).deleteFilePlanComponent(filePlanComponentAlias); // Check the DELETE response status code - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + assertStatusCode(FORBIDDEN); } /** @@ -291,40 +251,36 @@ public class FilePlanTests extends BaseRestTest dataProvider = "getContainersAndTypes" ) @Bug(id = "RM-4296") - public void createFilePlanSpecialContainerWhenExists(FilePlanComponentAlias filePlanAlias, FilePlanComponentType rmType) throws Exception + public void createFilePlanSpecialContainerWhenExists(String filePlanComponentAlias, String filePlanComponentType) throws Exception { // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Authenticate with admin user - rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Get the RM site ID - String rmSiteId = rmSiteAPI.getSite().getGuid(); - String name = filePlanAlias + getRandomAlphanumeric(); + String rmSiteId = getRestAPIFactory().getRMSiteAPI().getSite().getGuid(); + String name = filePlanComponentAlias + getRandomAlphanumeric(); // Build the file plan root properties FilePlanComponent filePlanComponent = FilePlanComponent.builder() .name(name) - .nodeType(rmType.toString()) + .nodeType(filePlanComponentType) .properties(FilePlanComponentProperties.builder() .build()) .build(); - // Authenticate with admin user - filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI(); // Create the special containers into RM site - parent folder - filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, rmSiteId); + assertStatusCode(UNPROCESSABLE_ENTITY); // Create the special containers into RM site - parent folder - filePlanComponentAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS.toString()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS); + assertStatusCode(UNPROCESSABLE_ENTITY); // Create the special containers into the root of special containers containers - filePlanComponentAPI.createFilePlanComponent(filePlanComponent, filePlanAlias.toString()); - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); + filePlanComponentsAPI.createFilePlanComponent(filePlanComponent, filePlanComponentAlias); + assertStatusCode(UNPROCESSABLE_ENTITY); } /** @@ -338,27 +294,18 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainers" ) - public void getSpecialFilePlanComponentsWithNonRMuser(String filePlanAlias) throws Exception + public void getSpecialFilePlanComponentsWithNonRMuser(String filePlanComponentAlias) throws Exception { // Create RM Site if doesn't exist createRMSiteIfNotExists(); - // Disconnect user from REST API session - rmSiteAPI.usingRestWrapper().disconnect(); - - // Authenticate admin user to Alfresco REST API - restClient.authenticateUser(dataUser.getAdminUser()); - // Create a random user - UserModel nonRMuser = dataUser.createRandomTestUser("testUser"); - - // Authenticate using the random user - filePlanComponentAPI.usingRestWrapper().authenticateUser(nonRMuser); + UserModel nonRMuser = getDataUser().createRandomTestUser("testUser"); // Get the special file plan components - filePlanComponentAPI.getFilePlanComponent(filePlanAlias.toString()); + getRestAPIFactory().getFilePlanComponentsAPI(nonRMuser).getFilePlanComponent(filePlanComponentAlias); // Check the response status code is FORBIDDEN - filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); + assertStatusCode(FORBIDDEN); } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java index 3fc3f9488d..0e09096d4d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/NonElectronicRecordTests.java @@ -35,6 +35,8 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_CATEGORY_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; +import static org.alfresco.rest.rm.community.utils.FilePlanComponentsUtil.createNonElectronicRecordModel; +import static org.alfresco.utility.constants.UserRole.SiteManager; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CREATED; @@ -45,16 +47,13 @@ import static org.testng.Assert.assertFalse; import java.util.Random; -import org.alfresco.rest.rm.community.base.BaseRestTest; +import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties; -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI; -import org.alfresco.rest.rm.community.requests.RMSiteAPI; +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI; import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser; import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.UserModel; -import org.springframework.beans.factory.annotation.Autowired; import org.testng.annotations.Test; /** @@ -63,17 +62,8 @@ import org.testng.annotations.Test; * @author Kristijan Conkas * @since 2.6 */ -public class NonElectronicRecordTests extends BaseRestTest +public class NonElectronicRecordTests extends BaseRMRestTest { - @Autowired - private FilePlanComponentAPI filePlanComponentAPI; - - @Autowired - private DataUser dataUser; - - @Autowired - private RMSiteAPI rmSiteAPI; - /** *
          * Given a parent container that is NOT a record folder or an unfiled record folder
    @@ -86,37 +76,30 @@ public class NonElectronicRecordTests extends BaseRestTest
         @Test(description = "Non-electronic record can't be created as a child of invalid parent Id")
         public void cantCreateForInvalidParentIds() throws Exception
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
    -        // non-electronic record object to be used for create tests
    -        FilePlanComponent nonElectronicRecord = FilePlanComponent.builder()
    -                                                .name("Record " + getRandomAlphanumeric())
    -                                                .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
    -                                                .build();
    -
             // create record category, non-electronic records can't be its children
             FilePlanComponent recordCategoryModel = FilePlanComponent.builder()
                                                              .name("Category " + getRandomAlphanumeric())
    -                                                         .nodeType(RECORD_CATEGORY_TYPE.toString())
    +                                                         .nodeType(RECORD_CATEGORY_TYPE)
                                                              .build();
     
    -        FilePlanComponent recordCategory = filePlanComponentAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS.toString());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        FilePlanComponent recordCategory = filePlanComponentsAPI.createFilePlanComponent(recordCategoryModel, FILE_PLAN_ALIAS);
     
             // iterate through all invalid parent containers and try to create/file an electronic record
    -        asList(FILE_PLAN_ALIAS.toString(), TRANSFERS_ALIAS.toString(), HOLDS_ALIAS.toString(), recordCategory.getId())
    +        asList(FILE_PLAN_ALIAS, TRANSFERS_ALIAS, HOLDS_ALIAS, recordCategory.getId())
                 .stream()
                 .forEach(id ->
                 {
                     try
                     {
    -                    filePlanComponentAPI.createFilePlanComponent(nonElectronicRecord, id);
    +                    filePlanComponentsAPI.createFilePlanComponent(createNonElectronicRecordModel(), id);
                     }
                     catch (Exception error)
                     {
                     }
     
                     // Verify the status code
    -                filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
    +                assertStatusCode(UNPROCESSABLE_ENTITY);
                 });
         }
     
    @@ -144,10 +127,9 @@ public class NonElectronicRecordTests extends BaseRestTest
         )
         public void canCreateInValidContainers(FilePlanComponent container) throws Exception
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             logger.info("Root container:\n" + toJson(container));
    -        if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
    +
    +        if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
             {
                 // only record folders can be open or closed
                 assertFalse(container.getProperties().getIsClosed());
    @@ -168,7 +150,7 @@ public class NonElectronicRecordTests extends BaseRestTest
             // set values of all available properties for the non electronic records
             FilePlanComponent filePlanComponent = FilePlanComponent.builder()
                                                                .name("Record " + getRandomAlphanumeric())
    -                                                           .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
    +                                                           .nodeType(NON_ELECTRONIC_RECORD_TYPE)
                                                                .properties(FilePlanComponentProperties.builder()
                                                                                                       .title(title)
                                                                                                       .description(description)
    @@ -182,15 +164,16 @@ public class NonElectronicRecordTests extends BaseRestTest
                                                                .build();
     
             // create non-electronic record
    -        String nonElectronicId = filePlanComponentAPI.createFilePlanComponent(
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        String nonElectronicId = filePlanComponentsAPI.createFilePlanComponent(
                 filePlanComponent,
                 container.getId()).getId();
     
             // verify the create request status code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // get newly created non-electonic record and verify its properties
    -        FilePlanComponent nonElectronicRecord = filePlanComponentAPI.getFilePlanComponent(nonElectronicId);
    +        FilePlanComponent nonElectronicRecord = filePlanComponentsAPI.getFilePlanComponent(nonElectronicId);
     
             assertEquals(title, nonElectronicRecord.getProperties().getTitle());
             assertEquals(description, nonElectronicRecord.getProperties().getDescription());
    @@ -215,8 +198,7 @@ public class NonElectronicRecordTests extends BaseRestTest
         @Test(description = "Non-electronic record can't be created in closed record folder")
         public void cantCreateInClosedFolder() throws Exception
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        FilePlanComponent recordFolder = createCategoryFolderInFilePlan(dataUser.getAdminUser(), FILE_PLAN_ALIAS.toString());
    +        FilePlanComponent recordFolder = createCategoryFolderInFilePlan();
     
             // the folder should be open
             assertFalse(recordFolder.getProperties().getIsClosed());
    @@ -225,16 +207,10 @@ public class NonElectronicRecordTests extends BaseRestTest
             closeFolder(recordFolder.getId());
     
             // try to create it, this should fail and throw an exception
    -
    -        filePlanComponentAPI.createFilePlanComponent(FilePlanComponent.builder()
    -                                                                      .name("Record " + getRandomAlphanumeric())
    -                                                                      .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
    -                                                                      .build(),
    -                                                    recordFolder.getId())
    -                                                                    .getId();
    +        getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(createNonElectronicRecordModel(), recordFolder.getId());
     
             // verify the status code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
    +        assertStatusCode(UNPROCESSABLE_ENTITY);
         }
     
         /**
    @@ -263,10 +239,8 @@ public class NonElectronicRecordTests extends BaseRestTest
         )
         public void allMandatoryPropertiesRequired(FilePlanComponent container) throws Exception
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             logger.info("Root container:\n" + toJson(container));
    -        if (container.getNodeType().equals(RECORD_FOLDER_TYPE.toString()))
    +        if (container.getNodeType().equals(RECORD_FOLDER_TYPE))
             {
                 // only record folders can be open or closed
                 assertFalse(container.getProperties().getIsClosed());
    @@ -296,14 +270,14 @@ public class NonElectronicRecordTests extends BaseRestTest
                 // this should fail and throw an exception
                 try
                 {
    -                filePlanComponentAPI.createFilePlanComponent(c, container.getId());
    +                getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(c, container.getId());
                 }
                 catch (Exception e)
                 {
                 }
     
                 // verify the status code is BAD_REQUEST
    -            filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
    +            assertStatusCode(BAD_REQUEST);
             });
         }
     
    @@ -323,33 +297,30 @@ public class NonElectronicRecordTests extends BaseRestTest
         )
         public void cantCreateIfNoRmPrivileges(FilePlanComponent container) throws Exception
         {
    -        String username = "zzzuser";
    -        UserModel user = createUserWithRole(username, UserRole.SiteManager);
    -
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(user);
    +        UserModel user = createUserWithRole("zzzuser", SiteManager);
     
             // try to create a fileplan component
    -        FilePlanComponent record=FilePlanComponent.builder()
    +        FilePlanComponent record = FilePlanComponent.builder()
                                                       .properties(FilePlanComponentProperties.builder()
                                                                                              .description("Description")
                                                                                              .title("Title")
                                                                                              .build())
                                                       .name("Record Name")
    -                                                  .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
    +                                                  .nodeType(NON_ELECTRONIC_RECORD_TYPE)
                                                       .build();
     
     
             // this should fail and throw an exception
             try
             {
    -            filePlanComponentAPI.createFilePlanComponent(record, container.getId());
    +            getRestAPIFactory().getFilePlanComponentsAPI(user).createFilePlanComponent(record, container.getId());
             }
             catch (Exception e)
             {
             }
     
             // user who isn't an RM site member can't access the container path
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
    +        assertStatusCode(FORBIDDEN);
         }
     
         /**
    @@ -358,8 +329,8 @@ public class NonElectronicRecordTests extends BaseRestTest
          */
         private FilePlanComponent getDummyNonElectronicRecord()
         {
    -        FilePlanComponent component=FilePlanComponent.builder()
    -                                            .nodeType(NON_ELECTRONIC_RECORD_TYPE.toString())
    +        FilePlanComponent component = FilePlanComponent.builder()
    +                                            .nodeType(NON_ELECTRONIC_RECORD_TYPE)
                                                 .build();
             return component;
         }
    @@ -378,21 +349,20 @@ public class NonElectronicRecordTests extends BaseRestTest
          */
         private UserModel createUserWithRole(String userName, UserRole userRole) throws Exception
         {
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        String siteId = rmSiteAPI.getSite().getId();
    +        String siteId = getRestAPIFactory().getRMSiteAPI().getSite().getId();
     
             // check if user exists
             UserModel user = new UserModel();
             user.setUsername(userName);
             user.setPassword(userName);
     
    -        if (!dataUser.isUserInRepo(userName))
    +        if (!getDataUser().isUserInRepo(userName))
             {
                 // user doesn't exist, create it
    -            user = dataUser.createUser(userName, userName);
    +            user = getDataUser().createUser(userName, userName);
                 user.setUserRole(userRole);
     
    -            dataUser.addUserToSite(user, new SiteModel(siteId), userRole);
    +            getDataUser().addUserToSite(user, new SiteModel(siteId), userRole);
             }
     
             return user;
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ReadRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ReadRecordTests.java
    index 29787ef498..f9882804e1 100644
    --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ReadRecordTests.java
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/ReadRecordTests.java
    @@ -386,7 +386,7 @@ public class ReadRecordTests extends BaseRestTest
                 }
                 );
         }
    -   
    +
         /**
          * Given a record
          * When I try to read the children
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java
    index 20b3416d67..653e83ef25 100644
    --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordCategoryTest.java
    @@ -44,17 +44,13 @@ import static org.testng.Assert.fail;
     import java.util.ArrayList;
     import java.util.NoSuchElementException;
     
    -import org.alfresco.rest.core.RestWrapper;
    -import org.alfresco.rest.rm.community.base.BaseRestTest;
    +import org.alfresco.rest.rm.community.base.BaseRMRestTest;
     import org.alfresco.rest.rm.community.base.TestData;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
    -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
    -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
    -import org.alfresco.utility.data.DataUser;
    +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
     import org.alfresco.utility.report.Bug;
    -import org.springframework.beans.factory.annotation.Autowired;
     import org.testng.annotations.Test;
     
     /**
    @@ -64,14 +60,8 @@ import org.testng.annotations.Test;
      * @author Tuna Aksoy
      * @since 2.6
      */
    -public class RecordCategoryTest extends BaseRestTest
    +public class RecordCategoryTest extends BaseRMRestTest
     {
    -    @Autowired
    -    private FilePlanComponentAPI filePlanComponentAPI;
    -
    -    @Autowired
    -    private DataUser dataUser;
    -
         // Number of children (for children creation test)
         private static final int NUMBER_OF_CHILDREN = 10;
     
    @@ -87,16 +77,13 @@ public class RecordCategoryTest extends BaseRestTest
         )
         public void createCategoryTest() throws Exception
         {
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             String categoryName = "Category name " + getRandomAlphanumeric();
             String categoryTitle = "Category title " + getRandomAlphanumeric();
     
             // Build the record category properties
             FilePlanComponent recordCategory = FilePlanComponent.builder()
                 .name(categoryName)
    -            .nodeType(RECORD_CATEGORY_TYPE.toString())
    +            .nodeType(RECORD_CATEGORY_TYPE)
                 .properties(
                         FilePlanComponentProperties.builder()
                             .title(categoryTitle)
    @@ -104,10 +91,10 @@ public class RecordCategoryTest extends BaseRestTest
                 .build();
     
             // Create the record category
    -        FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
    +        FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned file plan component
             assertTrue(filePlanComponent.getIsCategory());
    @@ -115,9 +102,9 @@ public class RecordCategoryTest extends BaseRestTest
             assertFalse(filePlanComponent.getIsRecordFolder());
     
             assertEquals(filePlanComponent.getName(), categoryName);
    -        assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString());
    +        assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE);
     
    -        assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +        assertEquals(filePlanComponent.getCreatedByUser().getId(), getAdminUser().getUsername());
     
             // Verify the returned file plan component properties
             FilePlanComponentProperties filePlanComponentProperties = filePlanComponent.getProperties();
    @@ -138,9 +125,6 @@ public class RecordCategoryTest extends BaseRestTest
         )
         public void renameCategory() throws Exception
         {
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // Create record category first
             String categoryName = "Category name " + getRandomAlphanumeric();
             String categoryTitle = "Category title " + getRandomAlphanumeric();
    @@ -148,7 +132,7 @@ public class RecordCategoryTest extends BaseRestTest
             // Build the record category properties
             FilePlanComponent recordCategory = FilePlanComponent.builder()
                 .name(categoryName)
    -            .nodeType(RECORD_CATEGORY_TYPE.toString())
    +            .nodeType(RECORD_CATEGORY_TYPE)
                 .properties(
                         FilePlanComponentProperties.builder()
                             .title(categoryTitle)
    @@ -156,7 +140,8 @@ public class RecordCategoryTest extends BaseRestTest
                 .build();
     
             // Create the record category
    -        FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        FilePlanComponent filePlanComponent = filePlanComponentsAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
     
             String newCategoryName = "Rename " + categoryName;
     
    @@ -164,16 +149,16 @@ public class RecordCategoryTest extends BaseRestTest
             FilePlanComponent recordCategoryUpdated = FilePlanComponent.builder().name(newCategoryName).build();
     
             // Update the record category
    -        FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
    +        FilePlanComponent renamedFilePlanComponent = filePlanComponentsAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId());
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // Verify the returned file plan component
             assertEquals(renamedFilePlanComponent.getName(), newCategoryName);
     
             // Get actual FILE_PLAN_ALIAS id
    -        FilePlanComponent parentComponent = filePlanComponentAPI.getFilePlanComponent(FILE_PLAN_ALIAS.toString());
    +        FilePlanComponent parentComponent = filePlanComponentsAPI.getFilePlanComponent(FILE_PLAN_ALIAS);
     
             // verify renamed component still has this parent
             assertEquals(renamedFilePlanComponent.getParentId(), parentComponent.getId());
    @@ -191,9 +176,6 @@ public class RecordCategoryTest extends BaseRestTest
         )
         public void deleteCategory() throws Exception
         {
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // Create record category first
             String categoryName = "Category name " + getRandomAlphanumeric();
             String categoryTitle = "Category title " + getRandomAlphanumeric();
    @@ -201,7 +183,7 @@ public class RecordCategoryTest extends BaseRestTest
             // Build the record category properties
             FilePlanComponent recordCategory = FilePlanComponent.builder()
                     .name(categoryName)
    -                .nodeType(RECORD_CATEGORY_TYPE.toString())
    +                .nodeType(RECORD_CATEGORY_TYPE)
                     .properties(
                             FilePlanComponentProperties.builder()
                                 .title(categoryTitle)
    @@ -209,17 +191,18 @@ public class RecordCategoryTest extends BaseRestTest
                     .build();
     
             // Create the record category
    -        FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        FilePlanComponent filePlanComponent = filePlanComponentsAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS);
     
             // Delete the record category
    -        filePlanComponentAPI.deleteFilePlanComponent(filePlanComponent.getId());
    +        filePlanComponentsAPI.deleteFilePlanComponent(filePlanComponent.getId());
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(NO_CONTENT);
    +        assertStatusCode(NO_CONTENT);
     
             // Deleted component should no longer be retrievable
    -        filePlanComponentAPI.getFilePlanComponent(filePlanComponent.getId());
    -        restWrapper.assertStatusCodeIs(NOT_FOUND);
    +        filePlanComponentsAPI.getFilePlanComponent(filePlanComponent.getId());
    +        assertStatusCode(NOT_FOUND);
         }
     
         /**
    @@ -235,7 +218,7 @@ public class RecordCategoryTest extends BaseRestTest
         public void createSubcategory() throws Exception
         {
             // Create root level category
    -        FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), getRandomAlphanumeric());
    +        FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS, getRandomAlphanumeric());
             assertNotNull(rootCategory.getId());
     
             // Create subcategory as a child of rootCategory
    @@ -249,7 +232,7 @@ public class RecordCategoryTest extends BaseRestTest
             assertTrue(childCategory.getIsCategory());
             assertFalse(childCategory.getIsFile());
             assertFalse(childCategory.getIsRecordFolder());
    -        assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString());
    +        assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE);
         }
     
         /**
    @@ -267,7 +250,7 @@ public class RecordCategoryTest extends BaseRestTest
         public void listChildren() throws Exception
         {
             // Create root level category
    -        FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS.toString(), getRandomAlphanumeric());
    +        FilePlanComponent rootCategory = createCategory(FILE_PLAN_ALIAS, getRandomAlphanumeric());
             assertNotNull(rootCategory.getId());
     
             // Add child categories/folders
    @@ -283,20 +266,17 @@ public class RecordCategoryTest extends BaseRestTest
                 children.add(child);
             }
     
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // List children from API
    -        FilePlanComponentsCollection apiChildren = filePlanComponentAPI.listChildComponents(rootCategory.getId());
    +        FilePlanComponentsCollection apiChildren = getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(rootCategory.getId());
     
             // Check status code
    -        restWrapper.assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
             logger.info("parent: " + rootCategory.getId());
     
             // Check listed children against created list
             apiChildren.getEntries().forEach(c ->
             {
    -            FilePlanComponent filePlanComponent = c.getFilePlanComponent();
    +            FilePlanComponent filePlanComponent = c.getFilePlanComponentModel();
                 assertNotNull(filePlanComponent.getId());
                 logger.info("Checking child " + filePlanComponent.getId());
     
    @@ -309,7 +289,7 @@ public class RecordCategoryTest extends BaseRestTest
                         .get();
     
                     // Created by
    -                assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +                assertEquals(filePlanComponent.getCreatedByUser().getId(), getAdminUser().getUsername());
     
                     // Is parent Id set correctly?
                     assertEquals(filePlanComponent.getParentId(), rootCategory.getId());
    @@ -319,7 +299,7 @@ public class RecordCategoryTest extends BaseRestTest
     
                     // Boolean properties related to node type
                     // Only RECORD_CATEGORY_TYPE and RECORD_FOLDER_TYPE have been created
    -                if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE.toString()))
    +                if (filePlanComponent.getNodeType().equals(RECORD_CATEGORY_TYPE))
                     {
                         assertTrue(filePlanComponent.getIsCategory());
                         assertFalse(filePlanComponent.getIsRecordFolder());
    @@ -361,11 +341,8 @@ public class RecordCategoryTest extends BaseRestTest
         {
             String COMPONENT_NAME = "Component"+getRandomAlphanumeric();
     
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             //Create the category
    -        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), COMPONENT_NAME);
    +        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS, COMPONENT_NAME);
     
             //Build node  properties
             FilePlanComponent recordCategory = FilePlanComponent.builder()
    @@ -378,8 +355,8 @@ public class RecordCategoryTest extends BaseRestTest
                     .build();
     
             //create the invalid node type
    -        filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId());
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
    +        getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordCategory, category.getId());
    +        assertStatusCode(UNPROCESSABLE_ENTITY);
         }
     
     
    @@ -405,20 +382,20 @@ public class RecordCategoryTest extends BaseRestTest
          * @return The created file plan component
          * @throws Exception
          */
    -    private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType) throws Exception
    +    private FilePlanComponent createComponent(String parentComponentId, String componentName, String componentType) throws Exception
         {
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        //Build node  properties
    +        // Build node  properties
             FilePlanComponent component = FilePlanComponent.builder()
                     .name(componentName)
    -                .nodeType(componentType.toString())
    +                .nodeType(componentType)
                     .properties(FilePlanComponentProperties.builder()
                             .title("Title for " + componentName)
                             .build())
                     .build();
     
    -        FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId);
    -        restWrapper.assertStatusCodeIs(CREATED);
    -        return fpc;
    +        FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(component, parentComponentId);
    +        assertStatusCode(CREATED);
    +
    +        return filePlanComponent;
         }
     }
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
    index d2e2fe6b66..cae584fdb8 100644
    --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/RecordFolderTests.java
    @@ -49,17 +49,14 @@ import java.time.LocalDateTime;
     import java.util.ArrayList;
     import java.util.NoSuchElementException;
     
    -import org.alfresco.rest.core.RestWrapper;
    -import org.alfresco.rest.rm.community.base.BaseRestTest;
    +import org.alfresco.rest.rm.community.base.BaseRMRestTest;
     import org.alfresco.rest.rm.community.base.TestData;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
    +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentReviewPeriod;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
    -import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
    -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
    -import org.alfresco.utility.data.DataUser;
    +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
     import org.alfresco.utility.report.Bug;
    -import org.springframework.beans.factory.annotation.Autowired;
     import org.testng.annotations.AfterClass;
     import org.testng.annotations.Test;
     
    @@ -70,15 +67,9 @@ import org.testng.annotations.Test;
      * @author Rodica Sutu
      * @since 2.6
      */
    -public class RecordFolderTests extends BaseRestTest
    +public class RecordFolderTests extends BaseRMRestTest
     {
    -    @Autowired
    -    public FilePlanComponentAPI filePlanComponentAPI;
    -
    -    @Autowired
    -    public DataUser dataUser;
    -
    -    private static final int NUMBER_OF_FOLDERS= 5;
    +    private static final int NUMBER_OF_FOLDERS = 5;
         /**
          * Given that a record category exists
          * When I use the API to create a new record folder
    @@ -91,23 +82,22 @@ public class RecordFolderTests extends BaseRestTest
         public void createFolderTest() throws Exception
         {
             String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
    +
             // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        FilePlanComponent filePlanComponent = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
    +        FilePlanComponent filePlanComponent = createCategory(FILE_PLAN_ALIAS, CATEGORY);
     
             FilePlanComponent recordFolder = FilePlanComponent.builder()
                     .name(FOLDER_NAME)
    -                .nodeType(RECORD_FOLDER_TYPE.toString())
    +                .nodeType(RECORD_FOLDER_TYPE)
                     .properties(FilePlanComponentProperties.builder()
                             .title(FOLDER_TITLE)
                             .build())
                     .build();
     
             // Create the record folder
    -        FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId());
    +        FilePlanComponent folder = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(recordFolder, filePlanComponent.getId());
     
    -
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Check folder has been created  within the category created
             assertEquals(filePlanComponent.getId(),folder.getParentId());
    @@ -117,8 +107,8 @@ public class RecordFolderTests extends BaseRestTest
             assertTrue(folder.getIsRecordFolder());
     
             assertEquals(folder.getName(), FOLDER_NAME);
    -        assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString());
    -        assertEquals(folder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +        assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE);
    +        assertEquals(folder.getCreatedByUser().getId(), getAdminUser().getUsername());
     
             // Verify the returned file plan component properties
             FilePlanComponentProperties folderProperties = folder.getProperties();
    @@ -139,25 +129,23 @@ public class RecordFolderTests extends BaseRestTest
         @Bug(id="RM-4327")
         public void createFolderIntoSpecialContainers(String filePlanComponent) throws Exception
         {
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
    -        String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId();
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        String componentID = filePlanComponentsAPI.getFilePlanComponent(filePlanComponent).getId();
     
             // Build the record category properties
             FilePlanComponent recordFolder = FilePlanComponent.builder()
                     .name(FOLDER_NAME)
    -                .nodeType(RECORD_FOLDER_TYPE.toString())
    +                .nodeType(RECORD_FOLDER_TYPE)
                     .properties(FilePlanComponentProperties.builder()
                                     .title(FOLDER_TITLE)
                                     .build())
                     .build();
     
             // Create a record folder
    -        filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID);
    +        filePlanComponentsAPI.createFilePlanComponent(recordFolder, componentID);
     
             // Check the API Response code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
    +        assertStatusCode(UNPROCESSABLE_ENTITY);
         }
     
         /**
    @@ -172,25 +160,23 @@ public class RecordFolderTests extends BaseRestTest
         public void checkTheRecordFolderProperties() throws Exception
         {
             String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
    +
    +        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
             FilePlanComponent folder = createFolder(category.getId(),FOLDER_NAME);
     
    -        FilePlanComponent folderDetails = filePlanComponentAPI.withParams("include="+IS_CLOSED).getFilePlanComponent(folder.getId());
    +        FilePlanComponent folderDetails = getRestAPIFactory().getFilePlanComponentsAPI().getFilePlanComponent(folder.getId(), "include=" + IS_CLOSED);
     
             // Verify the returned properties for the file plan component - record folder
    -        assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType());
    +        assertEquals(RECORD_FOLDER_TYPE, folderDetails.getNodeType());
             assertTrue(folderDetails.getIsRecordFolder());
             assertFalse(folderDetails.getIsCategory());
             assertFalse(folderDetails.getIsFile());
             assertFalse(folderDetails.getIsClosed());
     
             assertEquals(FOLDER_NAME,folderDetails.getName());
    -        assertEquals(dataUser.getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId());
    -        assertEquals(dataUser.getAdminUser().getUsername(), folderDetails.getModifiedByUser().getId());
    +        assertEquals(getAdminUser().getUsername(),folderDetails.getCreatedByUser().getId());
    +        assertEquals(getAdminUser().getUsername(), folderDetails.getModifiedByUser().getId());
             assertEquals(FOLDER_TITLE,folderDetails.getProperties().getTitle());
    -
         }
     
     
    @@ -208,10 +194,9 @@ public class RecordFolderTests extends BaseRestTest
         public void updateTheRecordFolderProperties() throws Exception
         {
             String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +
             //Create a record category
    -        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
    +        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
     
             //Create a record folder
             FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
    @@ -229,16 +214,16 @@ public class RecordFolderTests extends BaseRestTest
                                     .title(folderTitle)
                                     .description(folderDescription)
                                     .vitalRecord(true)
    -                                .reviewPeriod(new ReviewPeriod("month","1"))
    +                                .reviewPeriod(new FilePlanComponentReviewPeriod("month","1"))
                                     .location(location)
                                     .build())
                     .build();
     
             // Update the record category
    -        FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId());
    +        FilePlanComponent folderUpdated = getRestAPIFactory().getFilePlanComponentsAPI().updateFilePlanComponent(recordFolder, folder.getId());
     
             // Check the Response Status Code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // Verify the returned properties for the file plan component - record folder
             assertEquals(folderName, folderUpdated.getName());
    @@ -264,22 +249,22 @@ public class RecordFolderTests extends BaseRestTest
         {
             String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
     
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
             // Create the record category
    -        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
    +        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
     
             // Create the record folder
             FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME);
     
             // Delete the Record folder
    -        filePlanComponentAPI.deleteFilePlanComponent(folder.getId());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        filePlanComponentsAPI.deleteFilePlanComponent(folder.getId());
             // Check the Response Status Code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NO_CONTENT);
    +        assertStatusCode(NO_CONTENT);
    +
             // Check the File Plan Component is not found
    -        filePlanComponentAPI.getFilePlanComponent(folder.getId());
    +        filePlanComponentsAPI.getFilePlanComponent(folder.getId());
             // Check the Response Status Code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND);
    +        assertStatusCode(NOT_FOUND);
         }
     
         /**
    @@ -299,8 +284,7 @@ public class RecordFolderTests extends BaseRestTest
             String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric();
     
             // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY);
    +        FilePlanComponent category = createCategory(FILE_PLAN_ALIAS, CATEGORY);
     
             // Add child olders
             ArrayList children = new ArrayList();
    @@ -313,19 +297,16 @@ public class RecordFolderTests extends BaseRestTest
                 children.add(child);
             }
     
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // List children from API
    -        FilePlanComponentsCollection apiChildren = filePlanComponentAPI.listChildComponents(category.getId());
    +        FilePlanComponentsCollection apiChildren = getRestAPIFactory().getFilePlanComponentsAPI().listChildComponents(category.getId());
     
             // Check status code
    -        restWrapper.assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // Check listed children against created list
             apiChildren.getEntries().forEach(c ->
                     {
    -                    FilePlanComponent filePlanComponent = c.getFilePlanComponent();
    +                    FilePlanComponent filePlanComponent = c.getFilePlanComponentModel();
                         assertNotNull(filePlanComponent.getId());
                         logger.info("Checking child " + filePlanComponent.getId());
     
    @@ -338,7 +319,7 @@ public class RecordFolderTests extends BaseRestTest
                                                                          .get();
     
                             // Created by
    -                        assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +                        assertEquals(filePlanComponent.getCreatedByUser().getId(), getAdminUser().getUsername());
     
                             // Is parent Id set correctly
                             assertEquals(filePlanComponent.getParentId(), category.getId());
    @@ -376,21 +357,20 @@ public class RecordFolderTests extends BaseRestTest
         public void createFolderWithRelativePath() throws Exception
         {
             //RelativePath specify the container structure to create relative to the record folder to be created
    -        String RELATIVE_PATH = LocalDateTime.now().getYear()+"/"+ LocalDateTime.now().getMonth()+"/"+ LocalDateTime.now().getDayOfMonth();
    +        String relativePath = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" + LocalDateTime.now().getDayOfMonth();
     
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
             //The record folder to be created
             FilePlanComponent recordFolder = FilePlanComponent.builder()
                                                               .name(FOLDER_NAME)
    -                                                          .nodeType(RECORD_FOLDER_TYPE.toString())
    -                                                          .relativePath(RELATIVE_PATH)
    +                                                          .nodeType(RECORD_FOLDER_TYPE)
    +                                                          .relativePath(relativePath)
                                                               .build();
     
             // Create the record folder
    -        FilePlanComponent folder = filePlanComponentAPI.withParams("include="+ PATH).createFilePlanComponent(recordFolder,FILE_PLAN_ALIAS.toString());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        FilePlanComponent folder = filePlanComponentsAPI.createFilePlanComponent(recordFolder, FILE_PLAN_ALIAS, "include=" + PATH);
             //Check the API response code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned properties for the file plan component - record folder
             assertFalse(folder.getIsCategory());
    @@ -398,35 +378,35 @@ public class RecordFolderTests extends BaseRestTest
             assertTrue(folder.getIsRecordFolder());
     
             //Check the path return contains the RELATIVE_PATH
    -        assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
    +        assertTrue(folder.getPath().getName().contains(relativePath));
             //check the parent is a category
    -        assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
    +        assertTrue(filePlanComponentsAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
     
             //check the created folder from the server
    -        folder=filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder.getId());
    +        folder = filePlanComponentsAPI.getFilePlanComponent(folder.getId(), "include=" + PATH);
             //Check the API response code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
             // Verify the returned properties for the file plan component - record folder
             assertFalse(folder.getIsCategory());
             assertFalse(folder.getIsFile());
             assertTrue(folder.getIsRecordFolder());
     
             //Check the path return contains the RELATIVE_PATH
    -        assertTrue(folder.getPath().getName().contains(RELATIVE_PATH));
    +        assertTrue(folder.getPath().getName().contains(relativePath));
     
             //New Relative Path only a part of containers need to be created before the record folder
    -        String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" +( LocalDateTime.now().getDayOfMonth()+1);
    +        String NEW_RELATIVE_PATH = LocalDateTime.now().getYear() + "/" + LocalDateTime.now().getMonth() + "/" + (LocalDateTime.now().getDayOfMonth() + 1);
             //The record folder to be created
             FilePlanComponent recordFolder2 = FilePlanComponent.builder()
                                                               .name(FOLDER_NAME)
    -                                                          .nodeType(RECORD_FOLDER_TYPE.toString())
    +                                                          .nodeType(RECORD_FOLDER_TYPE)
                                                               .relativePath(NEW_RELATIVE_PATH)
                                                               .build();
     
             // Create the record folder
    -        FilePlanComponent folder2 = filePlanComponentAPI.withParams("include=" + PATH).createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS.toString());
    +        FilePlanComponent folder2 = filePlanComponentsAPI.createFilePlanComponent(recordFolder2, FILE_PLAN_ALIAS, "include=" + PATH);
             //Check the API response code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned properties for the file plan component - record folder
             assertFalse(folder2.getIsCategory());
    @@ -436,12 +416,12 @@ public class RecordFolderTests extends BaseRestTest
             assertTrue(folder2.getPath().getName().contains(NEW_RELATIVE_PATH));
     
             //check the parent is a category
    -        assertTrue(filePlanComponentAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
    +        assertTrue(filePlanComponentsAPI.getFilePlanComponent(folder.getParentId()).getIsCategory());
     
             // Check the folder created on the server
    -        folder2 = filePlanComponentAPI.withParams("include=" + PATH).getFilePlanComponent(folder2.getId());
    +        folder2 = filePlanComponentsAPI.getFilePlanComponent(folder2.getId(), "include=" + PATH);
             //Check the API response code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // Verify the returned properties for the file plan component - record folder
             assertFalse(folder2.getIsCategory());
    @@ -454,12 +434,12 @@ public class RecordFolderTests extends BaseRestTest
         @AfterClass (alwaysRun = true)
         public void tearDown() throws Exception
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -        filePlanComponentAPI.listChildComponents(FILE_PLAN_ALIAS.toString()).getEntries().forEach(filePlanComponentEntry ->
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        filePlanComponentsAPI.listChildComponents(FILE_PLAN_ALIAS).getEntries().forEach(filePlanComponentEntry ->
             {
                 try
                 {
    -                filePlanComponentAPI.deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponent().getId());
    +                filePlanComponentsAPI.deleteFilePlanComponent(filePlanComponentEntry.getFilePlanComponentModel().getId());
                 }
                 catch (Exception e)
                 {
    @@ -467,7 +447,4 @@ public class RecordFolderTests extends BaseRestTest
                 }
             });
         }
    -
    -
    -
     }
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java
    index cd36c86cd0..ee6bd0c69a 100644
    --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/fileplancomponents/UnfiledRecordsFolderTests.java
    @@ -48,15 +48,11 @@ import static org.testng.Assert.assertTrue;
     import java.util.List;
     import java.util.stream.Collectors;
     
    -import org.alfresco.rest.core.RestWrapper;
    -import org.alfresco.rest.rm.community.base.BaseRestTest;
    +import org.alfresco.rest.rm.community.base.BaseRMRestTest;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
    -import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType;
     import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
    -import org.alfresco.rest.rm.community.requests.FilePlanComponentAPI;
    -import org.alfresco.utility.data.DataUser;
    -import org.springframework.beans.factory.annotation.Autowired;
    +import org.alfresco.rest.rm.community.requests.igCoreAPI.FilePlanComponentAPI;
     import org.testng.annotations.DataProvider;
     import org.testng.annotations.Test;
     
    @@ -66,27 +62,23 @@ import org.testng.annotations.Test;
      * @author Kristijan Conkas
      * @since 2.6
      */
    -public class UnfiledRecordsFolderTests extends BaseRestTest
    +public class UnfiledRecordsFolderTests extends BaseRMRestTest
     {
    -    @Autowired
    -    private FilePlanComponentAPI filePlanComponentAPI;
    -
    -    @Autowired
    -    private DataUser dataUser;
    -
         /** invalid root level types, at unfiled records root level these shouldn't be possible to create */
     
    -@DataProvider(name = "invalidRootTypes")
    -    public Object[][] createData1() {
    -     return new Object[][] {
    -       { FILE_PLAN_TYPE },
    -       { RECORD_CATEGORY_TYPE },
    -       { RECORD_FOLDER_TYPE },
    -       { HOLD_TYPE },
    -       { HOLD_CONTAINER_TYPE },
    -       { TRANSFER_CONTAINER_TYPE },
    -       { UNFILED_CONTAINER_TYPE }
    -     };
    +    @DataProvider(name = "invalidRootTypes")
    +    public Object[][] createData1()
    +    {
    +        return new Object[][]
    +        {
    +            { FILE_PLAN_TYPE },
    +            { RECORD_CATEGORY_TYPE },
    +            { RECORD_FOLDER_TYPE },
    +            { HOLD_TYPE },
    +            { HOLD_CONTAINER_TYPE },
    +            { TRANSFER_CONTAINER_TYPE },
    +            { UNFILED_CONTAINER_TYPE }
    +        };
         }
     
         /**
    @@ -99,9 +91,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
         @Test(description = "Create root unfiled records folder")
         public void createRootUnfiledRecordsFolder() throws Exception
         {
    -        // Authenticate with admin user
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             String folderName = "Folder " + getRandomAlphanumeric();
             String folderTitle = folderName + " Title";
             String folderDescription = folderName + " Description";
    @@ -109,18 +98,17 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
             // Build unfiled records folder properties
             FilePlanComponent unfiledFolder = FilePlanComponent.builder()
                     .name(folderName)
    -                .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
    +                .nodeType(UNFILED_RECORD_FOLDER_TYPE)
                     .properties(FilePlanComponentProperties.builder()
                                     .title(folderTitle)
                                     .description(folderDescription)
                                     .build())
                     .build();
     
    -        FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
    -            UNFILED_RECORDS_CONTAINER_ALIAS.toString());
    +        FilePlanComponent filePlanComponent = getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS);
     
             // Verify the status code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned file plan component
             assertFalse(filePlanComponent.getIsCategory());
    @@ -128,9 +116,9 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
             assertFalse(filePlanComponent.getIsRecordFolder()); // it is not a _normal_ record folder!
     
             assertEquals(filePlanComponent.getName(), folderName);
    -        assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
    +        assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
     
    -        assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +        assertEquals(filePlanComponent.getCreatedByUser().getId(), getAdminUser().getUsername());
     
             // Verify the returned file plan component properties
             FilePlanComponentProperties filePlanComponentProperties = filePlanComponent.getProperties();
    @@ -146,20 +134,18 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
             dataProvider = "invalidRootTypes",
             description = "Only unfiled records folders can be created at unfiled records root level"
         )
    -    public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(FilePlanComponentType componentType)
    +    public void onlyRecordFoldersCanBeCreatedAtUnfiledRecordsRoot(String filePlanComponentType)
         {
    -        filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             String folderName = "Folder " + getRandomAlphanumeric();
             String folderTitle = folderName + " Title";
             String folderDescription = folderName + " Description";
     
    -        logger.info("creating " + componentType.toString());
    +        logger.info("creating " + filePlanComponentType);
     
             // Build unfiled records folder properties
             FilePlanComponent unfiledFolder = FilePlanComponent.builder()
                 .name(folderName)
    -            .nodeType(componentType.toString())
    +            .nodeType(filePlanComponentType)
                 .properties(FilePlanComponentProperties.builder()
                                 .title(folderTitle)
                                 .description(folderDescription)
    @@ -168,15 +154,14 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
     
             try
             {
    -            filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
    -                UNFILED_RECORDS_CONTAINER_ALIAS.toString());
    +            getRestAPIFactory().getFilePlanComponentsAPI().createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS);
             }
             catch (Exception error)
             {
             }
     
             // Verify the status code
    -        filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY);
    +        assertStatusCode(UNPROCESSABLE_ENTITY);
         }
     
         /**
    @@ -189,21 +174,19 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
         @Test(description = "Child unfiled records folder can be created in a parent unfiled records folder")
         public void childUnfiledRecordsFolderCanBeCreated() throws Exception
         {
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             String parentFolderName = "Parent Folder " + getRandomAlphanumeric();
             String childFolderName = "Child Folder " + getRandomAlphanumeric();
             String childFolderTitle = childFolderName + " Title";
             String childFolderDescription = childFolderName + " Description";
     
             // No need for fine control, create it using utility function
    -        FilePlanComponent parentFolder = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), parentFolderName);
    +        FilePlanComponent parentFolder = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, parentFolderName);
             assertEquals(parentFolderName, parentFolder.getName());
     
             // Build the unfiled records folder properties
             FilePlanComponent unfiledFolder = FilePlanComponent.builder()
                     .name(childFolderName)
    -                .nodeType(UNFILED_RECORD_FOLDER_TYPE.toString())
    +                .nodeType(UNFILED_RECORD_FOLDER_TYPE)
                     .properties(FilePlanComponentProperties.builder()
                             .title(childFolderTitle)
                             .description(childFolderDescription)
    @@ -211,11 +194,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
                     .build();
     
             // Create it as a child of parentFolder
    -        FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder,
    -            parentFolder.getId());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        FilePlanComponent childFolder = filePlanComponentsAPI.createFilePlanComponent(unfiledFolder, parentFolder.getId());
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned file plan component
             assertFalse(childFolder.getIsCategory());
    @@ -223,8 +206,8 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
             assertFalse(childFolder.getIsRecordFolder()); // it is not a _normal_ record folder!
     
             assertEquals(childFolder.getName(), childFolderName);
    -        assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
    -        assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
    +        assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE);
    +        assertEquals(childFolder.getCreatedByUser().getId(), getAdminUser().getUsername());
     
             // Verify the returned file plan component properties
             FilePlanComponentProperties childProperties = childFolder.getProperties();
    @@ -236,11 +219,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
     
             // Does child's parent point to it?
             // Perform another call as our parentFolder had been executed before childFolder existed
    -        FilePlanComponentsCollection parentsChildren = filePlanComponentAPI.listChildComponents(parentFolder.getId());
    -        restWrapper.assertStatusCodeIs(OK);
    +        FilePlanComponentsCollection parentsChildren = filePlanComponentsAPI.listChildComponents(parentFolder.getId());
    +        assertStatusCode(OK);
             List childIds = parentsChildren.getEntries()
                 .stream()
    -            .map(c -> c.getFilePlanComponent().getId())
    +            .map(c -> c.getFilePlanComponentModel().getId())
                 .collect(Collectors.toList());
     
             // Child folder is listed in parent
    @@ -260,12 +243,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
         @Test(description = "Unfiled record folder")
         public void editUnfiledRecordsFolder() throws Exception
         {
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
             String modified = "Modified ";
             String folderName = "Folder To Modify" + getRandomAlphanumeric();
     
             // No need for fine control, create it using utility function
    -        FilePlanComponent folderToModify = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
    +        FilePlanComponent folderToModify = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, folderName);
             assertEquals(folderName, folderToModify.getName());
     
             // Build the properties which will be updated
    @@ -278,12 +260,13 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
                 .build();
     
             // Update the unfiled records folder
    -        filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        filePlanComponentsAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId());
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // This is to ensure the change was actually applied, rather than simply trusting the object returned by PUT
    -        FilePlanComponent renamedFolder = filePlanComponentAPI.getFilePlanComponent(folderToModify.getId());
    +        FilePlanComponent renamedFolder = filePlanComponentsAPI.getFilePlanComponent(folderToModify.getId());
     
             // Verify the returned file plan component
             assertEquals(modified + folderToModify.getName(), renamedFolder.getName());
    @@ -301,21 +284,21 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
         @Test(description = "Delete unfiled record folder")
         public void deleteUnfiledRecordsFolder() throws Exception
         {
    -        RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
             String folderName = "Folder To Delete" + getRandomAlphanumeric();
     
             // Create folderToDelete
    -        FilePlanComponent folderToDelete = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS.toString(), folderName);
    +        FilePlanComponent folderToDelete = createUnfiledRecordsFolder(UNFILED_RECORDS_CONTAINER_ALIAS, folderName);
             assertEquals(folderName, folderToDelete.getName());
     
             // Delete folderToDelete
    -        filePlanComponentAPI.deleteFilePlanComponent(folderToDelete.getId());
    +        FilePlanComponentAPI filePlanComponentsAPI = getRestAPIFactory().getFilePlanComponentsAPI();
    +        filePlanComponentsAPI.deleteFilePlanComponent(folderToDelete.getId());
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(NO_CONTENT);
    +        assertStatusCode(NO_CONTENT);
     
             // Deleted component should no longer be retrievable
    -        filePlanComponentAPI.getFilePlanComponent(folderToDelete.getId());
    -        restWrapper.assertStatusCodeIs(NOT_FOUND);
    +        filePlanComponentsAPI.getFilePlanComponent(folderToDelete.getId());
    +        assertStatusCode(NOT_FOUND);
         }
     }
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java
    index 356f7695c1..d7cf4b9435 100644
    --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/site/RMSiteTests.java
    @@ -27,10 +27,16 @@
     package org.alfresco.rest.rm.community.site;
     
     import static org.alfresco.rest.rm.community.base.TestData.ANOTHER_ADMIN;
    -import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_EMAIL;
     import static org.alfresco.rest.rm.community.base.TestData.DEFAULT_PASSWORD;
     import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
     import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_DESCRIPTION;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_ID;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.RM_TITLE;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createDOD5015RMSiteModel;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createRMSiteModel;
    +import static org.alfresco.rest.rm.community.utils.RMSiteUtil.createStandardRMSiteModel;
    +import static org.alfresco.utility.constants.UserRole.SiteManager;
     import static org.springframework.http.HttpStatus.BAD_REQUEST;
     import static org.springframework.http.HttpStatus.CONFLICT;
     import static org.springframework.http.HttpStatus.CREATED;
    @@ -42,13 +48,10 @@ import static org.springframework.social.alfresco.api.entities.Site.Visibility.P
     import static org.testng.Assert.assertEquals;
     import static org.testng.Assert.assertNotNull;
     
    -import org.alfresco.dataprep.UserService;
    -import org.alfresco.rest.core.RestWrapper;
    -import org.alfresco.rest.rm.community.base.BaseRestTest;
    +import org.alfresco.rest.rm.community.base.BaseRMRestTest;
     import org.alfresco.rest.rm.community.model.site.RMSite;
    -import org.alfresco.rest.rm.community.requests.RMSiteAPI;
    -import org.alfresco.utility.constants.UserRole;
    -import org.alfresco.utility.data.DataUser;
    +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMSiteAPI;
    +import org.alfresco.rest.rm.community.requests.igCoreAPI.RMUserAPI;
     import org.alfresco.utility.data.RandomData;
     import org.alfresco.utility.model.UserModel;
     import org.alfresco.utility.report.Bug;
    @@ -62,16 +65,10 @@ import org.testng.annotations.Test;
      * @author Rodica Sutu
      * @since 2.6
      */
    -public class RMSiteTests extends BaseRestTest
    +public class RMSiteTests extends BaseRMRestTest
     {
         @Autowired
    -    private UserService userService;
    -
    -    @Autowired
    -    private RMSiteAPI rmSiteAPI;
    -
    -    @Autowired
    -    private DataUser dataUser;
    +    private RMUserAPI rmUserAPI;
     
         /**
          * Given that RM module is installed
    @@ -84,8 +81,7 @@ public class RMSiteTests extends BaseRestTest
         )
         public void createRMSiteAsAdminUser() throws Exception
         {
    -        // Authenticate with admin user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
     
             // Check if the RM site exists
             if (rmSiteAPI.existsRMSite())
    @@ -95,14 +91,10 @@ public class RMSiteTests extends BaseRestTest
             }
     
             // Create the RM site
    -        RMSite rmSite =RMSite.builder().compliance(STANDARD).build();
    -        rmSite.setTitle(RM_TITLE);
    -        rmSite.setDescription(RM_DESCRIPTION);
    -
    -        RMSite rmSiteResponse = rmSiteAPI.createRMSite(rmSite);
    +        RMSite rmSiteResponse = rmSiteAPI.createRMSite(createStandardRMSiteModel());
     
             // Verify the status code
    -        rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned file plan component
             assertEquals(rmSiteResponse.getId(), RM_ID);
    @@ -110,7 +102,7 @@ public class RMSiteTests extends BaseRestTest
             assertEquals(rmSiteResponse.getDescription(), RM_DESCRIPTION);
             assertEquals(rmSiteResponse.getCompliance(), STANDARD);
             assertEquals(rmSiteResponse.getVisibility(), PUBLIC);
    -        assertEquals(rmSiteResponse.getRole(), UserRole.SiteManager.toString());
    +        assertEquals(rmSiteResponse.getRole(), SiteManager.toString());
         }
     
         /**
    @@ -127,22 +119,16 @@ public class RMSiteTests extends BaseRestTest
             // Create the RM site if it does not exist
             createRMSiteIfNotExists();
     
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // Construct new properties
             String newTitle = RM_TITLE + "createRMSiteWhenSiteExists";
             String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists";
     
             // Create the RM site
    -        RMSite rmSite = RMSite.builder().compliance(STANDARD).build();
    -        rmSite.setTitle(newTitle);
    -        rmSite.setDescription(newDescription);
    -
    -        rmSiteAPI.createRMSite(rmSite);
    +        RMSite rmSiteModel = createRMSiteModel(STANDARD, newTitle, newDescription);
    +        getRestAPIFactory().getRMSiteAPI().createRMSite(rmSiteModel);
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(CONFLICT);
    +        assertStatusCode(CONFLICT);
         }
     
         /**
    @@ -156,14 +142,14 @@ public class RMSiteTests extends BaseRestTest
         )
         public void deleteRMSite() throws Exception
         {
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        // Create the RM site if it does not exist
    +        createRMSiteIfNotExists();
     
             // Delete the RM site
    -        rmSiteAPI.deleteRMSite();
    +        getRestAPIFactory().getRMSiteAPI().deleteRMSite();
     
             // Verify the status code
    -        restWrapper.assertStatusCodeIs(NO_CONTENT);
    +        assertStatusCode(NO_CONTENT);
         }
     
         /**
    @@ -177,27 +163,26 @@ public class RMSiteTests extends BaseRestTest
         )
         public void getRMSite() throws Exception
         {
    -        // Authenticate with admin user
    -        RestWrapper restWrapper = rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
     
             // Check if RM site exists
             if (!rmSiteAPI.existsRMSite())
             {
                 // Verify the status code when RM site  doesn't exist
    -            restWrapper.assertStatusCodeIs(NOT_FOUND);
    +            assertStatusCode(NOT_FOUND);
                 createRMSiteIfNotExists();
             }
             else
             {
                 // Get the RM site
    -            RMSite rmSite = rmSiteAPI.getSite();
    +            RMSite rmSiteModel = rmSiteAPI.getSite();
     
                 // Verify the status code
    -            restWrapper.assertStatusCodeIs(OK);
    -            assertEquals(rmSite.getId(), RM_ID);
    -            assertEquals(rmSite.getDescription(), RM_DESCRIPTION);
    -            assertEquals(rmSite.getCompliance(), STANDARD);
    -            assertEquals(rmSite.getVisibility(), PUBLIC);
    +            assertStatusCode(OK);
    +            assertEquals(rmSiteModel.getId(), RM_ID);
    +            assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
    +            assertEquals(rmSiteModel.getCompliance(), STANDARD);
    +            assertEquals(rmSiteModel.getVisibility(), PUBLIC);
             }
         }
     
    @@ -213,8 +198,7 @@ public class RMSiteTests extends BaseRestTest
         @Bug (id="RM-4289")
         public void createRMSiteAsAnotherAdminUser() throws Exception
         {
    -        // Authenticate with admin user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        RMSiteAPI rmSiteAPI = getRestAPIFactory().getRMSiteAPI();
     
             // Check if the RM site exists
             if (rmSiteAPI.existsRMSite())
    @@ -223,40 +207,22 @@ public class RMSiteTests extends BaseRestTest
                 rmSiteAPI.deleteRMSite();
             }
     
    -        // Disconnect the current user from the API session
    -        rmSiteAPI.usingRestWrapper().disconnect();
    -
             // Create user
    -        userService.create(dataUser.getAdminUser().getUsername(),
    -                dataUser.getAdminUser().getPassword(),
    -                ANOTHER_ADMIN,
    -                DEFAULT_PASSWORD,
    -                DEFAULT_EMAIL,
    -                ANOTHER_ADMIN,
    -                ANOTHER_ADMIN);
    -
    -        // Build the user model
    -        UserModel userModel = new UserModel(ANOTHER_ADMIN,DEFAULT_PASSWORD);
    -
    -        // Authenticate as that new user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(userModel);
    +        rmUserAPI.createUser(ANOTHER_ADMIN);
     
             // Create the RM site
    -        RMSite rmSite = RMSite.builder().compliance(DOD5015).build();
    -        rmSite.setTitle(RM_TITLE);
    -        rmSite.setDescription(RM_DESCRIPTION);
    -        rmSite=rmSiteAPI.createRMSite(rmSite);
    +        RMSite rmSiteModel = getRestAPIFactory().getRMSiteAPI(new UserModel(ANOTHER_ADMIN, DEFAULT_PASSWORD)).createRMSite(createDOD5015RMSiteModel());
     
             // Verify the status code
    -        rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED);
    +        assertStatusCode(CREATED);
     
             // Verify the returned file plan component
    -        assertEquals(rmSite.getId(), RM_ID);
    -        assertEquals(rmSite.getTitle(), RM_TITLE);
    -        assertEquals(rmSite.getDescription(), RM_DESCRIPTION);
    -        assertEquals(rmSite.getCompliance(), DOD5015);
    -        assertEquals(rmSite.getVisibility(), PUBLIC);
    -        assertEquals(rmSite.getRole(), UserRole.SiteManager.toString());
    +        assertEquals(rmSiteModel.getId(), RM_ID);
    +        assertEquals(rmSiteModel.getTitle(), RM_TITLE);
    +        assertEquals(rmSiteModel.getDescription(), RM_DESCRIPTION);
    +        assertEquals(rmSiteModel.getCompliance(), DOD5015);
    +        assertEquals(rmSiteModel.getVisibility(), PUBLIC);
    +        assertEquals(rmSiteModel.getRole(), SiteManager.toString());
         }
     
         /**
    @@ -267,55 +233,37 @@ public class RMSiteTests extends BaseRestTest
          * Then RM site details are updated
          */
         @Test
    -    public void updateRMSiteDetails()throws Exception
    +    public void updateRMSiteDetails() throws Exception
         {
             String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric();
    -        String NEW_DESCRIPTION = RM_DESCRIPTION+ RandomData.getRandomAlphanumeric();
    -
    -        // Authenticate with admin user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        String NEW_DESCRIPTION = RM_DESCRIPTION + RandomData.getRandomAlphanumeric();
     
             // Create the site if it does not exist
             createRMSiteIfNotExists();
     
    -        //Create RM site model
    -        RMSite rmSiteToUpdate = new RMSite();
    +        // Create RM site model
    +        RMSite rmSiteToUpdate = RMSite.builder().build();
             rmSiteToUpdate.setTitle(NEW_TITLE);
             rmSiteToUpdate.setDescription(NEW_DESCRIPTION);
     
    -        // Disconnect the user from the API session
    -        rmSiteAPI.usingRestWrapper().disconnect();
    -
    -        // Create a random user
    -        UserModel nonRMuser = dataUser.createRandomTestUser("testUser");
    -
    -        // Authenticate as that random user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(nonRMuser);
    -
             // Create the RM site
    -        rmSiteAPI.updateRMSite(rmSiteToUpdate);
    +        getRestAPIFactory().getRMSiteAPI(getDataUser().createRandomTestUser("testUser")).updateRMSite(rmSiteToUpdate);
     
             // Verify the status code
    -        rmSiteAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN);
    -
    -        // Disconnect the user from the API session
    -        rmSiteAPI.usingRestWrapper().disconnect();
    -
    -        // Authenticate with admin user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    +        assertStatusCode(FORBIDDEN);
     
             // Update the RM Site
    -        RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate);
    +        RMSite rmSiteModel = getRestAPIFactory().getRMSiteAPI().updateRMSite(rmSiteToUpdate);
     
             // Verify the response status code
    -        rmSiteAPI.usingRestWrapper().assertStatusCodeIs(OK);
    +        assertStatusCode(OK);
     
             // Verify the returned file plan component
    -        assertEquals(rmSite.getId(), RM_ID);
    -        assertEquals(rmSite.getTitle(), NEW_TITLE);
    -        assertEquals(rmSite.getDescription(), NEW_DESCRIPTION);
    -        assertNotNull(rmSite.getCompliance());
    -        assertEquals(rmSite.getVisibility(), PUBLIC);
    +        assertEquals(rmSiteModel.getId(), RM_ID);
    +        assertEquals(rmSiteModel.getTitle(), NEW_TITLE);
    +        assertEquals(rmSiteModel.getDescription(), NEW_DESCRIPTION);
    +        assertNotNull(rmSiteModel.getCompliance());
    +        assertEquals(rmSiteModel.getVisibility(), PUBLIC);
         }
     
         /**
    @@ -326,19 +274,16 @@ public class RMSiteTests extends BaseRestTest
         @Test
         public void updateRMSiteComplianceAsAdmin() throws Exception
         {
    -        // Authenticate with admin user
    -        rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
    -
             // Create the RM site if it does not exist
             createRMSiteIfNotExists();
     
             // Build the RM site properties
    -        RMSite rmSiteToUpdate =  RMSite.builder().compliance(DOD5015).build();
    +        RMSite rmSiteToUpdate = RMSite.builder().compliance(DOD5015).build();
     
             // Update the RM site
    -        rmSiteAPI.updateRMSite(rmSiteToUpdate);
    +        getRestAPIFactory().getRMSiteAPI().updateRMSite(rmSiteToUpdate);
     
             // Verify the response status code
    -        rmSiteAPI.usingRestWrapper().assertStatusCodeIs(BAD_REQUEST);
    +        assertStatusCode(BAD_REQUEST);
         }
     }
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/FilePlanComponentsUtil.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/FilePlanComponentsUtil.java
    new file mode 100644
    index 0000000000..7f34a2d42e
    --- /dev/null
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/FilePlanComponentsUtil.java
    @@ -0,0 +1,104 @@
    +/*
    + * #%L
    + * Alfresco Records Management Module
    + * %%
    + * Copyright (C) 2005 - 2017 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.utils;
    +
    +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.CONTENT_TYPE;
    +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.NON_ELECTRONIC_RECORD_TYPE;
    +import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric;
    +
    +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
    +import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentProperties;
    +
    +/**
    + * Utility class for file plan component models
    + *
    + * @author Tuna Aksoy
    + * @since 2.6
    + */
    +public class FilePlanComponentsUtil
    +{
    +    private FilePlanComponentsUtil()
    +    {
    +        // Intentionally blank
    +    }
    +
    +    /** image resource file to be used for records body */
    +    public static final String IMAGE_FILE = "money.JPG";
    +
    +    /**
    +     *  Creates a record model with the given type and a random name (with "Record " prefix)
    +     *
    +     * @param nodeType The node type
    +     * @return The {@link FilePlanComponent} with for the given node type
    +     */
    +    private static FilePlanComponent createRecordModel(String nodeType)
    +    {
    +        return FilePlanComponent.builder()
    +                .name("Record " + getRandomAlphanumeric())
    +                .nodeType(nodeType)
    +                .build();
    +    }
    +
    +    /**
    +     * Creates an electronic record model with a random name (with "Record " prefix)
    +     *
    +     * @return The electronic record as {@link FilePlanComponent}
    +     */
    +    public static FilePlanComponent createElectronicRecordModel()
    +    {
    +        return createRecordModel(CONTENT_TYPE);
    +    }
    +
    +    /**
    +     * Creates a non-electronic record model with a random name (with "Record " prefix)
    +     *
    +     * @return The non-electronic record as {@link FilePlanComponent}
    +     */
    +    public static FilePlanComponent createNonElectronicRecordModel()
    +    {
    +        return createRecordModel(NON_ELECTRONIC_RECORD_TYPE);
    +    }
    +
    +    /**
    +     * Creates a file plan component with the given name, type and title
    +     *
    +     * @param name The name of the file plan component
    +     * @param type The type of the file plan component
    +     * @param title The title of the file plan component
    +     * @return The {@link FilePlanComponent} with the given details
    +     */
    +    public static FilePlanComponent createFilePlanComponentModel(String name, String type, String title)
    +    {
    +        return FilePlanComponent.builder()
    +                .name(name)
    +                .nodeType(type)
    +                .properties(FilePlanComponentProperties.builder()
    +                                .title(title)
    +                                .build())
    +                .build();
    +    }
    +}
    diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java
    new file mode 100644
    index 0000000000..b484748d7f
    --- /dev/null
    +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/utils/RMSiteUtil.java
    @@ -0,0 +1,99 @@
    +/*
    + * #%L
    + * Alfresco Records Management Module
    + * %%
    + * Copyright (C) 2005 - 2017 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.utils;
    +
    +import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.DOD5015;
    +import static org.alfresco.rest.rm.community.model.site.RMSiteCompliance.STANDARD;
    +
    +import org.alfresco.rest.rm.community.model.site.RMSiteCompliance;
    +import org.alfresco.rest.rm.community.model.site.RMSite;
    +
    +/**
    + * Utility class for the RM Site
    + *
    + * @author Tuna Aksoy
    + * @since 2.6
    + */
    +public class RMSiteUtil
    +{
    +    private RMSiteUtil()
    +    {
    +        // Intentionally blank
    +    }
    +
    +    /** Constants */
    +    public static final String RM_ID = "rm";
    +    public static final String RM_TITLE = "Records Management";
    +    public static final String RM_DESCRIPTION = "Records Management Site";
    +
    +    /**
    +     * Creates an RM Site model for the given compliance, title and description
    +     *
    +     * @param compliance The RM site compliance
    +     * @param title The site title
    +     * @param description The site description
    +     * @return The {@link RMSite} with the given details
    +     */
    +    public static RMSite createRMSiteModel(RMSiteCompliance compliance, String title, String description)
    +    {
    +        RMSite rmSiteModel = RMSite.builder().compliance(compliance).build();
    +        rmSiteModel.setTitle(title);
    +        rmSiteModel.setDescription(description);
    +        return rmSiteModel;
    +    }
    +
    +    /**
    +     * Creates an RM Site for the given compliance and default title and description
    +     *
    +     * @param The RM site compliance
    +     * @return The {@link RMSite} with the given details
    +     */
    +    private static RMSite createRMSiteModel(RMSiteCompliance compliance)
    +    {
    +        return createRMSiteModel(compliance, RM_TITLE, RM_DESCRIPTION);
    +    }
    +
    +    /**
    +     * Creates a standard RM site with the default title and description
    +     *
    +     * @return The standard RM site
    +     */
    +    public static RMSite createStandardRMSiteModel()
    +    {
    +        return createRMSiteModel(STANDARD);
    +    }
    +
    +    /**
    +     * Creates a DOD5015 compliance RM site with the default title and description
    +     *
    +     * @return The DOD5015 compliance RM site
    +     */
    +    public static RMSite createDOD5015RMSiteModel()
    +    {
    +        return createRMSiteModel(DOD5015);
    +    }
    +}