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 05a8eeea9b..8342ce9661 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 @@ -38,6 +38,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; * POJO for file plan component * * @author Tuna Aksoy + * @author Rodica Sutu * @since 2.6 */ public class FilePlanComponent @@ -55,22 +56,22 @@ public class FilePlanComponent private String nodeType; @JsonProperty (required = true) - private boolean isCategory; + private Boolean isCategory; @JsonProperty (required = true) - private boolean isRecordFolder; + private Boolean isRecordFolder; @JsonProperty (required = true) - private boolean isFile; + private Boolean isFile; @JsonProperty - private boolean hasRetentionSchedule; + private Boolean hasRetentionSchedule; @JsonProperty(value = IS_CLOSED) - private boolean isClosed; + private Boolean isClosed; @JsonProperty - private boolean isCompleted; + private Boolean isCompleted; @JsonProperty (required = true) private List aspectNames; @@ -83,12 +84,12 @@ public class FilePlanComponent @JsonProperty (value = ALLOWABLE_OPERATIONS) private List allowableOperations; + private FilePlanComponentPath path; @JsonProperty (required = true) private String modifiedAt; - @JsonProperty (required = true) private String createdAt; @@ -96,6 +97,46 @@ public class FilePlanComponent private FilePlanComponentUserInfo modifiedByUser; + /**Helper constructor for creating the file plan component using + * + * @param name File Plan Component name + * @param nodeType File Plan Component node type + * @param properties File Plan Component properties + */ + public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties) + { + this.name = name; + this.nodeType = nodeType; + this.properties = properties; + } + + /** + * Helper constructor to create empty file plan component + */ + public FilePlanComponent() { } + + /** + * Helper constructor for creating the file plan component using + * + * @param name File Plan Component name + */ + public FilePlanComponent(String name) + { + this.name = name; + } + + /** + * Helper constructor for creating the file plan component using + * + * @param name File Plan Component name + * @param properties File Plan Component properties + */ + public FilePlanComponent(String name, FilePlanComponentProperties properties) + { + this.name = name; + this.properties = properties; + } + /** * @return the id */ @@ -163,7 +204,7 @@ public class FilePlanComponent /** * @return the isCategory */ - public boolean isIsCategory() + public Boolean isCategory() { return this.isCategory; } @@ -171,7 +212,7 @@ public class FilePlanComponent /** * @param isCategory the isCategory to set */ - public void setCategory(boolean isCategory) + public void setCategory(Boolean isCategory) { this.isCategory = isCategory; } @@ -179,7 +220,7 @@ public class FilePlanComponent /** * @return the isRecordFolder */ - public boolean isIsRecordFolder() + public Boolean isRecordFolder() { return this.isRecordFolder; } @@ -187,7 +228,7 @@ public class FilePlanComponent /** * @param isRecordFolder the isRecordFolder to set */ - public void setRecordFolder(boolean isRecordFolder) + public void setRecordFolder(Boolean isRecordFolder) { this.isRecordFolder = isRecordFolder; } @@ -195,7 +236,7 @@ public class FilePlanComponent /** * @return the isFile */ - public boolean isIsFile() + public Boolean isFile() { return this.isFile; } @@ -203,7 +244,7 @@ public class FilePlanComponent /** * @param isFile the isFile to set */ - public void setFile(boolean isFile) + public void setFile(Boolean isFile) { this.isFile = isFile; } @@ -211,7 +252,7 @@ public class FilePlanComponent /** * @return the hasRetentionSchedule */ - public boolean isHasRetentionSchedule() + public Boolean hasRetentionSchedule() { return this.hasRetentionSchedule; } @@ -219,7 +260,7 @@ public class FilePlanComponent /** * @param hasRetentionSchedule the hasRetentionSchedule to set */ - public void setHasRetentionSchedule(boolean hasRetentionSchedule) + public void setHasRetentionSchedule(Boolean hasRetentionSchedule) { this.hasRetentionSchedule = hasRetentionSchedule; } @@ -347,7 +388,7 @@ public class FilePlanComponent /** * @return the isClosed */ - public boolean isClosed() + public Boolean isClosed() { return this.isClosed; } @@ -355,7 +396,7 @@ public class FilePlanComponent /** * @param closed the isClosed to set */ - public void setClosed(boolean closed) + public void setClosed(Boolean closed) { this.isClosed = closed; } @@ -363,7 +404,7 @@ public class FilePlanComponent /** * @return the isCompleted */ - public boolean isCompleted() + public Boolean isCompleted() { return this.isCompleted; } @@ -371,7 +412,7 @@ public class FilePlanComponent /** * @param completed the isCompleted to set */ - public void setCompleted(boolean completed) + public void setCompleted(Boolean completed) { this.isCompleted = completed; } diff --git a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java index 4775e67fa9..98f38afd36 100644 --- a/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/model/fileplancomponents/FilePlanComponentFields.java @@ -45,7 +45,7 @@ public class FilePlanComponentFields public static final String PROPERTIES_DESCRIPTION = "cm:description"; public static final String PROPERTIES_SUPPLEMENTAL_MARKING_LIST = "rmc:supplementalMarkingList"; public static final String ALLOWABLE_OPERATIONS = "allowableOperations"; - public static final String IS_CLOSED="isclosed"; + public static final String IS_CLOSED="isClosed"; public static final String PROPERTIES_REVIEW_PERIOD="rma:reviewPeriod"; public static final String PROPERTIES_LOCATION="rma:location"; } 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 bee8bbac4a..ca612a556d 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 @@ -40,7 +40,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; public class FilePlanComponentPath { private String name; - private boolean isComplete; + private Boolean isComplete; private List elements; /** @@ -62,7 +62,7 @@ public class FilePlanComponentPath /** * @return the isComplete */ - public boolean isComplete() + public Boolean isComplete() { return this.isComplete; } @@ -70,7 +70,7 @@ public class FilePlanComponentPath /** * @param isComplete the isComplete to set */ - public void setComplete(boolean isComplete) + public void setComplete(Boolean isComplete) { this.isComplete = isComplete; } 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 588d406ea1..ab8fbcd253 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 @@ -38,6 +38,9 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + +import org.alfresco.rest.rm.community.util.ReviewPeriodSerializer; /** * POJO for file plan component properties @@ -51,7 +54,7 @@ public class FilePlanComponentProperties { @JsonProperty(PROPERTIES_VITAL_RECORD_INDICATOR) - private boolean vitalRecord; + private Boolean vitalRecord; @JsonProperty(PROPERTIES_TITLE) private String title; @@ -66,16 +69,32 @@ public class FilePlanComponentProperties private List supplementalMarkingList; @JsonProperty(PROPERTIES_REVIEW_PERIOD) + @JsonSerialize (using = ReviewPeriodSerializer.class) private ReviewPeriod reviewPeriod; @JsonProperty(PROPERTIES_LOCATION) private String location; + public FilePlanComponentProperties(String title, String description) + { + this.title = title; + this.description = description; + } + + public FilePlanComponentProperties(String title) + { + this.title = title; + } + + public FilePlanComponentProperties() + { + } + /** * @return the vitalRecord */ - public boolean isVitalRecord() + public Boolean isVitalRecord() { return this.vitalRecord; } @@ -83,7 +102,7 @@ public class FilePlanComponentProperties /** * @param vitalRecord the vitalRecord to set */ - public void setVitalRecord(boolean vitalRecord) + public void setVitalRecord(Boolean vitalRecord) { this.vitalRecord = vitalRecord; } @@ -183,4 +202,5 @@ public class FilePlanComponentProperties { this.location = location; } + } 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/ReviewPeriod.java index 87f4929197..30c2c63938 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/ReviewPeriod.java @@ -32,11 +32,31 @@ package org.alfresco.rest.rm.community.model.fileplancomponents; * @author Rodica Sutu * @since 2.6 */ + public class ReviewPeriod { private String periodType; private String expression; + /** + * Helper constructor with + * + * @param periodType + * @param expression + */ + public ReviewPeriod(String periodType, String expression) + { + this.periodType = periodType; + this.expression = expression; + } + + /** + * Helper constructor + */ + public ReviewPeriod() + { + } + /** * @return the periodType */ 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 cc6c72b27e..e9f80ede48 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 @@ -26,6 +26,8 @@ */ package org.alfresco.rest.rm.community.model.site; +import static org.alfresco.rest.rm.community.model.site.RMSiteFields.COMPLIANCE; + import com.fasterxml.jackson.annotation.JsonProperty; import org.alfresco.rest.model.RestSiteModel; @@ -38,9 +40,39 @@ import org.alfresco.rest.model.RestSiteModel; */ public class RMSite extends RestSiteModel { - @JsonProperty (required = true) + @JsonProperty (value = COMPLIANCE,required = true) private RMSiteCompliance compliance; + /** + * Helper constructor to create RM Site object using + * + * @param title + * @param description + * @param compliance + */ + public RMSite(String title, String description, RMSiteCompliance compliance) + { + this.title=title; + this.description=description; + this.compliance=compliance; + } + + /** + * Helper constructor for creating the RM Site + */ + public RMSite() { } + + /** + * Helper constructor to create RM Site object using + * + * @param compliance RM Site Compliance + */ + public RMSite(RMSiteCompliance compliance) + { + super(); + this.compliance = compliance; + } + /** * Helper method to set RM site compliance * @@ -60,4 +92,5 @@ public class RMSite extends RestSiteModel { return compliance; } + } 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/FilePlanComponentAPI.java index 760b9772b3..0ba49263ab 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/FilePlanComponentAPI.java @@ -30,13 +30,12 @@ import static org.alfresco.rest.core.RestRequest.requestWithBody; import static org.alfresco.rest.core.RestRequest.simpleRequest; 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.springframework.http.HttpMethod.DELETE; import static org.springframework.http.HttpMethod.GET; import static org.springframework.http.HttpMethod.POST; import static org.springframework.http.HttpMethod.PUT; -import com.google.gson.JsonObject; - import org.alfresco.rest.core.RestAPI; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection; @@ -103,7 +102,7 @@ public class FilePlanComponentAPI extends RestAPI /** * Creates a file plan component with the given properties under the parent node with the given id * - * @param filePlanComponentProperties The properties of the file plan component to be created + * @param filePlanComponentModel The properties of the file plan component to be created * @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: @@ -116,14 +115,14 @@ public class FilePlanComponentAPI extends RestAPI *
  • model integrity exception, including node name with invalid characters
  • * */ - public FilePlanComponent createFilePlanComponent(JsonObject filePlanComponentProperties, String parentId) throws Exception + public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception { - mandatoryObject("filePlanComponentProperties", filePlanComponentProperties); + mandatoryObject("filePlanComponentProperties", filePlanComponentModel); mandatoryString("parentId", parentId); return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( POST, - filePlanComponentProperties.toString(), + toJson(filePlanComponentModel), "fileplan-components/{fileplanComponentId}/children", parentId )); @@ -132,7 +131,7 @@ public class FilePlanComponentAPI extends RestAPI /** * Updates a file plan component * - * @param filePlanComponentProperties The properties to be updated + * @param filePlanComponent 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: @@ -145,14 +144,14 @@ public class FilePlanComponentAPI extends RestAPI *
  • model integrity exception, including node name with invalid characters
  • * */ - public FilePlanComponent updateFilePlanComponent(JsonObject filePlanComponentProperties, String filePlanComponentId) throws Exception + public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId) throws Exception { - mandatoryObject("filePlanComponentProperties", filePlanComponentProperties); + mandatoryObject("filePlanComponentProperties", filePlanComponent); mandatoryString("filePlanComponentId", filePlanComponentId); return usingRestWrapper().processModel(FilePlanComponent.class, requestWithBody( PUT, - filePlanComponentProperties.toString(), + toJson(filePlanComponent), "fileplan-components/{fileplanComponentId}", filePlanComponentId )); @@ -181,4 +180,5 @@ public class FilePlanComponentAPI extends RestAPI 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/RMSiteAPI.java index d855db885d..57c7745cbc 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/RMSiteAPI.java @@ -29,14 +29,13 @@ package org.alfresco.rest.rm.community.requests; import static org.alfresco.rest.core.RestRequest.requestWithBody; import static org.alfresco.rest.core.RestRequest.simpleRequest; import static org.alfresco.rest.rm.community.util.ParameterCheck.mandatoryObject; +import static org.alfresco.rest.rm.community.util.PojoUtility.toJson; import static org.springframework.http.HttpMethod.DELETE; import static org.springframework.http.HttpMethod.GET; import static org.springframework.http.HttpMethod.POST; import static org.springframework.http.HttpMethod.PUT; import static org.springframework.http.HttpStatus.OK; -import com.google.gson.JsonObject; - import org.alfresco.rest.core.RestAPI; import org.alfresco.rest.rm.community.model.site.RMSite; import org.alfresco.utility.data.DataUser; @@ -81,7 +80,7 @@ public class RMSiteAPI extends RestAPI /** * Create the RM site * - * @param rmSiteProperties The properties of the rm site to be created + * @param rmSite The properties of the rm site to be created * @return The {@link RMSite} with the given properties * @throws Exception for the following cases: *
      @@ -91,13 +90,13 @@ public class RMSiteAPI extends RestAPI *
    • Api Response code default Unexpected error
    • *
    */ - public RMSite createRMSite(JsonObject rmSiteProperties) throws Exception + public RMSite createRMSite(RMSite rmSite) throws Exception { - mandatoryObject("rmSiteProperties", rmSiteProperties); + mandatoryObject("rmSiteProperties", rmSite); return usingRestWrapper().processModel(RMSite.class, requestWithBody( POST, - rmSiteProperties.toString(), + toJson(rmSite), "ig-sites" )); } @@ -135,13 +134,13 @@ public class RMSiteAPI extends RestAPI *
  • Api Response code default Unexpected error,model integrity exception
  • * */ - public RMSite updateRMSite(JsonObject rmSiteProperties) throws Exception + public RMSite updateRMSite(RMSite rmSiteProperties) throws Exception { mandatoryObject("rmSiteProperties", rmSiteProperties); return usingRestWrapper().processModel(RMSite.class, requestWithBody( PUT, - rmSiteProperties.toString(), + toJson(rmSiteProperties), "ig-sites/rm" )); } 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 new file mode 100644 index 0000000000..7ecb945d9c --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/PojoUtility.java @@ -0,0 +1,75 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 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.util; + +import java.io.IOException; + +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.core.JsonGenerationException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +/** + * Utility class for creating the json object + * + * @author Rodica Sutu + * @since 2.6 + */ +public class PojoUtility +{ + /** + * Converting object to JSON string + * + * @param model The java object model to convert + * @throws JsonProcessingException Throws exceptions if the given object doesn't match to the POJO class model + */ + public static String toJson(Object model) throws JsonProcessingException + { + ObjectMapper mapper = new ObjectMapper(); + //include only values that differ from default settings to be included + mapper.setSerializationInclusion(Include.NON_DEFAULT); + try + { + //return the json object + return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model); + + } + catch (JsonGenerationException e) + { + return e.toString(); + } + catch (JsonMappingException e) + { + return e.toString(); + } + catch (IOException e) + { + return e.toString(); + } + } +} 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 new file mode 100644 index 0000000000..97c8847dcf --- /dev/null +++ b/rm-automation/rm-automation-community-rest-api/src/main/java/org/alfresco/rest/rm/community/util/ReviewPeriodSerializer.java @@ -0,0 +1,64 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2016 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.util; + +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +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; + + +/** + * Utility class for serializing the Review Period type + * + * @author Rodica Sutu + * @since 2.6 + */ +public class ReviewPeriodSerializer extends JsonSerializer +{ + + /** + * @param value The Review Period value that is being serialized. + * @param gen Jackson utility is responsible for writing JSON + * @param serializers Provider for getting access to other serializers and configurations registered with the ObjectMapper. + * @throws IOException + * @throws JsonProcessingException + */ + @Override + public void serialize(ReviewPeriod 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/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 index 1b975ea750..7eade80baa 100644 --- 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 @@ -30,27 +30,20 @@ import static java.lang.Integer.parseInt; 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.FilePlanComponentFields.NAME; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; 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.rest.rm.community.model.site.RMSiteFields.COMPLIANCE; -import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION; -import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.springframework.http.HttpStatus.CREATED; -import com.google.gson.JsonObject; import com.jayway.restassured.RestAssured; 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; @@ -128,15 +121,9 @@ public class BaseRestTest extends RestTest { rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Build the RM site properties - JsonObject rmSiteProperties = buildObject() - .add(TITLE, RM_TITLE) - .add(DESCRIPTION, RM_DESCRIPTION) - .add(COMPLIANCE, STANDARD.toString()) - .getJson(); - // Create the RM site - rmSiteAPI.createRMSite(rmSiteProperties); + RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD); + rmSiteAPI.createRMSite(rmSite); // Verify the status code rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED); @@ -196,14 +183,9 @@ public class BaseRestTest extends RestTest { RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - JsonObject componentProperties = buildObject().add(NAME, componentName) - .add(NODE_TYPE, componentType.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, componentTitle) - .end() - .getJson(); + FilePlanComponent filePlanComponent = new FilePlanComponent(componentName, componentType.toString(),new FilePlanComponentProperties(componentTitle)); - FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, parentComponentId); + FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(filePlanComponent, parentComponentId); restWrapper.assertStatusCodeIs(CREATED); return fpc; } 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 2d50011cfa..d0b6be85b2 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 @@ -33,13 +33,8 @@ import static org.alfresco.rest.rm.community.base.AllowableOperations.DELETE; import static org.alfresco.rest.rm.community.base.AllowableOperations.UPDATE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.FILE_PLAN_ALIAS; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.TRANSFERS_ALIAS; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; +import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.ALLOWABLE_OPERATIONS; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.springframework.http.HttpStatus.FORBIDDEN; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.OK; @@ -48,12 +43,12 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; -import com.google.gson.JsonObject; - +import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.rm.community.base.BaseRestTest; 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; @@ -75,6 +70,9 @@ public class FilePlanTests extends BaseRestTest @Autowired private FilePlanComponentAPI filePlanComponentAPI; + @Autowired + protected RestWrapper restWrapper; + @Autowired private RMSiteAPI rmSiteAPI; @@ -111,6 +109,8 @@ public class FilePlanTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(NOT_FOUND); } + + /** * Given that a file plan exists * When I ask the API for the details of the file plan @@ -160,7 +160,7 @@ public class FilePlanTests extends BaseRestTest filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); // Get the file plan special containers with the optional parameter allowableOperations - FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include=allowableOperations").getFilePlanComponent(specialContainerAlias); + FilePlanComponent filePlanComponent = filePlanComponentAPI.withParams("include="+ ALLOWABLE_OPERATIONS).getFilePlanComponent(specialContainerAlias); // Check the list of allowableOperations returned if(specialContainerAlias.equals(TRANSFERS_ALIAS.toString())) @@ -198,16 +198,13 @@ public class FilePlanTests extends BaseRestTest // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - // Build the file plan root properties - JsonObject filePlanProperties = buildObject() - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, FILE_PLAN_TITLE) - .add(PROPERTIES_DESCRIPTION, FILE_PLAN_DESCRIPTION) - .end() - .getJson(); + // Build object for updating the filePlan + FilePlanComponent filePlanComponent = new FilePlanComponent(); + FilePlanComponentProperties filePlanComponentProperties=new FilePlanComponentProperties(FILE_PLAN_TITLE, FILE_PLAN_DESCRIPTION); + filePlanComponent.setProperties(filePlanComponentProperties); // Update the record category - FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanProperties,FILE_PLAN_ALIAS.toString()); + FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(filePlanComponent,FILE_PLAN_ALIAS.toString()); // Verify the response status code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); @@ -252,10 +249,10 @@ public class FilePlanTests extends BaseRestTest */ @Test ( - description = "Check the response code when deleting the special file plan components with non RM user", - dataProviderClass = TestData.class, - dataProvider = "getContainers" - ) + description = "Check the response code when deleting the special file plan components with non RM user", + dataProviderClass = TestData.class, + dataProvider = "getContainers" + ) public void deleteFilePlanSpecialComponentsNonRMUser(String filePlanAlias) throws Exception { // Create RM Site if doesn't exist @@ -290,7 +287,7 @@ public class FilePlanTests extends BaseRestTest dataProviderClass = TestData.class, dataProvider = "getContainersAndTypes" ) - @Bug(id="RM-4296") + @Bug(id = "RM-4296") public void createFilePlanSpecialContainerWhenExists(FilePlanComponentAlias filePlanAlias, FilePlanComponentType rmType) throws Exception { // Create RM Site if doesn't exist @@ -298,29 +295,27 @@ public class FilePlanTests extends BaseRestTest // Authenticate with admin user rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + // Get the RM site ID String rmSiteId = rmSiteAPI.getSite().getGuid(); - String name = filePlanAlias + getRandomAlphanumeric(); // Build the file plan root properties - JsonObject componentProperties = buildObject() - .add(NAME, name) - .add(NODE_TYPE, rmType.toString()) - .getJson(); + FilePlanComponent filePlanComponent = new FilePlanComponent(name,rmType.toString(),new FilePlanComponentProperties()); // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + // Create the special containers into RM site - parent folder - filePlanComponentAPI.createFilePlanComponent(componentProperties, rmSiteId); + filePlanComponentAPI.createFilePlanComponent(filePlanComponent, rmSiteId); filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); // Create the special containers into RM site - parent folder - filePlanComponentAPI.createFilePlanComponent(componentProperties, FILE_PLAN_ALIAS.toString()); + filePlanComponentAPI.createFilePlanComponent(filePlanComponent, FILE_PLAN_ALIAS.toString()); filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); // Create the special containers into the root of special containers containers - filePlanComponentAPI.createFilePlanComponent(componentProperties, filePlanAlias.toString()); + filePlanComponentAPI.createFilePlanComponent(filePlanComponent, filePlanAlias.toString()); filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } 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 8b1e4cac09..c812282573 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 @@ -27,14 +27,9 @@ 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.FilePlanComponentFields.NAME; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; 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.utility.data.RandomData.getRandomAlphanumeric; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -49,8 +44,6 @@ import static org.testng.Assert.fail; import java.util.ArrayList; import java.util.NoSuchElementException; -import com.google.gson.JsonObject; - import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.rm.community.base.BaseRestTest; import org.alfresco.rest.rm.community.base.TestData; @@ -101,28 +94,21 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - JsonObject recordCategoryProperties = buildObject(). - add(NAME, categoryName). - add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()). - addObject(PROPERTIES). - add(PROPERTIES_TITLE, categoryTitle). - end(). - getJson(); - + FilePlanComponent recordCategory = new FilePlanComponent(categoryName,RECORD_CATEGORY_TYPE.toString(), + new FilePlanComponentProperties(categoryTitle)); // Create the record category - FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString()); + FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); // Verify the status code restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertTrue(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsFile()); - assertFalse(filePlanComponent.isIsRecordFolder()); + assertTrue(filePlanComponent.isCategory()); + assertFalse(filePlanComponent.isFile()); + assertFalse(filePlanComponent.isRecordFolder()); assertEquals(filePlanComponent.getName(), categoryName); assertEquals(filePlanComponent.getNodeType(), RECORD_CATEGORY_TYPE.toString()); - assertFalse(filePlanComponent.isHasRetentionSchedule()); assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername()); @@ -153,26 +139,19 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - JsonObject recordCategoryProperties = buildObject(). - add(NAME, categoryName). - add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()). - addObject(PROPERTIES). - add(PROPERTIES_TITLE, categoryTitle). - end(). - getJson(); + FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), + new FilePlanComponentProperties(categoryTitle)); // Create the record category - FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString()); + FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); String newCategoryName = "Rename " + categoryName; // Build the properties which will be updated - JsonObject updateRecordCategoryProperties = buildObject(). - add(NAME, newCategoryName). - getJson(); + FilePlanComponent recordCategoryUpdated = new FilePlanComponent(newCategoryName); // Update the record category - FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(updateRecordCategoryProperties, filePlanComponent.getId()); + FilePlanComponent renamedFilePlanComponent = filePlanComponentAPI.updateFilePlanComponent(recordCategoryUpdated, filePlanComponent.getId()); // Verify the status code restWrapper.assertStatusCodeIs(OK); @@ -207,16 +186,10 @@ public class RecordCategoryTest extends BaseRestTest String categoryTitle = "Category title " + getRandomAlphanumeric(); // Build the record category properties - JsonObject recordCategoryProperties = buildObject(). - add(NAME, categoryName). - add(NODE_TYPE, RECORD_CATEGORY_TYPE.toString()). - addObject(PROPERTIES). - add(PROPERTIES_TITLE, categoryTitle). - end(). - getJson(); - + FilePlanComponent recordCategory = new FilePlanComponent(categoryName, RECORD_CATEGORY_TYPE.toString(), + new FilePlanComponentProperties(categoryTitle)); // Create the record category - FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategoryProperties, FILE_PLAN_ALIAS.toString()); + FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(recordCategory, FILE_PLAN_ALIAS.toString()); // Delete the record category filePlanComponentAPI.deleteFilePlanComponent(filePlanComponent.getId()); @@ -253,9 +226,9 @@ public class RecordCategoryTest extends BaseRestTest // Verify child category assertEquals(childCategory.getParentId(), rootCategory.getId()); - assertTrue(childCategory.isIsCategory()); - assertFalse(childCategory.isIsFile()); - assertFalse(childCategory.isIsRecordFolder()); + assertTrue(childCategory.isCategory()); + assertFalse(childCategory.isFile()); + assertFalse(childCategory.isRecordFolder()); assertEquals(childCategory.getNodeType(), RECORD_CATEGORY_TYPE.toString()); } @@ -322,19 +295,19 @@ public class RecordCategoryTest extends BaseRestTest assertEquals(filePlanComponent.getParentId(), rootCategory.getId()); // Only categories or folders have been created - assertFalse(filePlanComponent.isIsFile()); + assertFalse(filePlanComponent.isFile()); // 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())) { - assertTrue(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsRecordFolder()); + assertTrue(filePlanComponent.isCategory()); + assertFalse(filePlanComponent.isRecordFolder()); } else { - assertTrue(filePlanComponent.isIsRecordFolder()); - assertFalse(filePlanComponent.isIsCategory()); + assertTrue(filePlanComponent.isRecordFolder()); + assertFalse(filePlanComponent.isCategory()); } // Does returned object have the same contents as the created one? @@ -366,22 +339,20 @@ public class RecordCategoryTest extends BaseRestTest @Bug (id="RM-4367") public void createTypesNotAllowedInCategory(String nodeType) throws Exception { - String COMPONENT_NAME="Component"+getRandomAlphanumeric(); + 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); //Build node properties - JsonObject componentProperties = buildObject() - .add(NAME, COMPONENT_NAME) - .add(NODE_TYPE, nodeType) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, "Title for " + COMPONENT_NAME) - .end() - .getJson(); + FilePlanComponent recordCategory = new FilePlanComponent(COMPONENT_NAME,nodeType, + new FilePlanComponentProperties("Title for " + COMPONENT_NAME)); //create the invalid node type - filePlanComponentAPI.createFilePlanComponent(componentProperties, category.getId()); + filePlanComponentAPI.createFilePlanComponent(recordCategory, category.getId()); filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } @@ -411,16 +382,10 @@ public class RecordCategoryTest extends BaseRestTest private FilePlanComponent createComponent(String parentComponentId, String componentName, FilePlanComponentType componentType) throws Exception { RestWrapper restWrapper = filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); - - JsonObject componentProperties = buildObject(). - add(NAME, componentName). - add(NODE_TYPE, componentType.toString()). - addObject(PROPERTIES). - add(PROPERTIES_TITLE, "Title for " + componentName). - end(). - getJson(); - - FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(componentProperties, parentComponentId); + //Build node properties + FilePlanComponent component = new FilePlanComponent(componentName, componentType.toString(), + new FilePlanComponentProperties("Title for " + componentName)); + FilePlanComponent fpc = filePlanComponentAPI.createFilePlanComponent(component, parentComponentId); restWrapper.assertStatusCodeIs(CREATED); return fpc; } 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 fee7b46171..705e79258b 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 @@ -31,17 +31,8 @@ import static org.alfresco.rest.rm.community.base.TestData.FOLDER_NAME; 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.FilePlanComponentFields.IS_CLOSED; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_LOCATION; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_REVIEW_PERIOD; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_VITAL_RECORD_INDICATOR; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.RECORD_FOLDER_TYPE; 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.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -56,14 +47,13 @@ import static org.testng.AssertJUnit.assertTrue; import java.util.ArrayList; import java.util.NoSuchElementException; -import com.google.gson.JsonObject; - import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.rm.community.base.BaseRestTest; 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.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.utility.report.Bug; @@ -101,26 +91,23 @@ public class RecordFolderTests extends BaseRestTest 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.toString(), CATEGORY); - // Build the record category properties - JsonObject recordFolderProperties = buildObject() - .add(NAME, FOLDER_NAME) - .add(NODE_TYPE, RECORD_FOLDER_TYPE.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, FOLDER_TITLE) - .end() - .getJson(); + FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(FOLDER_TITLE); + FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), filePlanComponentProperties); // Create the record folder - FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolderProperties, filePlanComponent.getId()); + FilePlanComponent folder = filePlanComponentAPI.createFilePlanComponent(recordFolder, filePlanComponent.getId()); + + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); + // Check folder has been created within the category created assertEquals(filePlanComponent.getId(),folder.getParentId()); // Verify the returned properties for the file plan component - record folder - assertFalse(folder.isIsCategory()); - assertFalse(folder.isIsFile()); - assertTrue(folder.isIsRecordFolder()); + assertFalse(folder.isCategory()); + assertFalse(folder.isFile()); + assertTrue(folder.isRecordFolder()); assertEquals(folder.getName(), FOLDER_NAME); assertEquals(folder.getNodeType(), RECORD_FOLDER_TYPE.toString()); @@ -151,16 +138,10 @@ public class RecordFolderTests extends BaseRestTest String componentID = filePlanComponentAPI.getFilePlanComponent(filePlanComponent).getId(); // Build the record category properties - JsonObject recordFolderProperties = buildObject() - .add(NAME, FOLDER_NAME) - .add(NODE_TYPE, RECORD_FOLDER_TYPE.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, FOLDER_TITLE) - .end() - .getJson(); - + FilePlanComponent recordFolder = new FilePlanComponent(FOLDER_NAME,RECORD_FOLDER_TYPE.toString(), + new FilePlanComponentProperties(FOLDER_TITLE)); // Create a record folder - filePlanComponentAPI.createFilePlanComponent(recordFolderProperties, componentID); + filePlanComponentAPI.createFilePlanComponent(recordFolder, componentID); // Check the API Response code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); @@ -177,19 +158,19 @@ public class RecordFolderTests extends BaseRestTest ) public void checkTheRecordFolderProperties() throws Exception { - String CATEGORY=CATEGORY_NAME + getRandomAlphanumeric(); + String CATEGORY = CATEGORY_NAME + getRandomAlphanumeric(); // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY); - FilePlanComponent folder =createFolder(category.getId(),FOLDER_NAME); + FilePlanComponent folder = createFolder(category.getId(),FOLDER_NAME); - FilePlanComponent folderDetails=filePlanComponentAPI.withParams("include="+IS_CLOSED).getFilePlanComponent(folder.getId()); + FilePlanComponent folderDetails = filePlanComponentAPI.withParams("include="+IS_CLOSED).getFilePlanComponent(folder.getId()); // Verify the returned properties for the file plan component - record folder assertEquals(RECORD_FOLDER_TYPE.toString(),folderDetails.getNodeType()); - assertTrue(folderDetails.isIsRecordFolder()); - assertFalse(folderDetails.isIsCategory()); - assertFalse(folderDetails.isIsFile()); + assertTrue(folderDetails.isRecordFolder()); + assertFalse(folderDetails.isCategory()); + assertFalse(folderDetails.isFile()); assertFalse(folderDetails.isClosed()); assertEquals(FOLDER_NAME,folderDetails.getName()); @@ -216,30 +197,27 @@ public class RecordFolderTests extends BaseRestTest 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); + + //Create a record folder FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME); // Create record category first String folderDescription = "The folder description is updated" + getRandomAlphanumeric(); - String folderName= "The folder name is updated" + getRandomAlphanumeric(); + String folderName = "The folder name is updated" + getRandomAlphanumeric(); String folderTitle = "Update title " + getRandomAlphanumeric(); - String location="Location"+getRandomAlphanumeric(); - String review_period="month|1"; + String location = "Location"+getRandomAlphanumeric(); - // Build the file plan root properties - JsonObject folderProperties = buildObject() - .add(NAME, folderName) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, folderTitle) - .add(PROPERTIES_DESCRIPTION, folderDescription) - .add(PROPERTIES_VITAL_RECORD_INDICATOR,true) - .add(PROPERTIES_REVIEW_PERIOD, review_period) - .add(PROPERTIES_LOCATION, location) - .end() - .getJson(); + //Create the file plan component properties to update + FilePlanComponentProperties filePlanComponentProperties = new FilePlanComponentProperties(folderTitle, folderDescription); + filePlanComponentProperties.setVitalRecord(true); + filePlanComponentProperties.setReviewPeriod( new ReviewPeriod("month","1")); + filePlanComponentProperties.setLocation(location); + FilePlanComponent recordFolder = new FilePlanComponent(folderName,filePlanComponentProperties); // Update the record category - FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(folderProperties, folder.getId()); + FilePlanComponent folderUpdated = filePlanComponentAPI.updateFilePlanComponent(recordFolder, folder.getId()); // Check the Response Status Code filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(OK); @@ -253,7 +231,6 @@ public class RecordFolderTests extends BaseRestTest assertNotNull(folderUpdated.getProperties().getReviewPeriod().getPeriodType()); assertNotNull(folderUpdated.getProperties().getReviewPeriod().getExpression()); - } /** @@ -271,8 +248,12 @@ public class RecordFolderTests extends BaseRestTest // Authenticate with admin user filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); + // Create the record category FilePlanComponent category = createCategory(FILE_PLAN_ALIAS.toString(), CATEGORY); + + // Create the record folder FilePlanComponent folder = createFolder(category.getId(), FOLDER_NAME); + // Delete the Record folder filePlanComponentAPI.deleteFilePlanComponent(folder.getId()); // Check the Response Status Code @@ -343,11 +324,11 @@ public class RecordFolderTests extends BaseRestTest // Is parent Id set correctly assertEquals(filePlanComponent.getParentId(), category.getId()); - assertFalse(filePlanComponent.isIsFile()); + assertFalse(filePlanComponent.isFile()); // Boolean properties related to node type - assertTrue(filePlanComponent.isIsRecordFolder()); - assertFalse(filePlanComponent.isIsCategory()); + assertTrue(filePlanComponent.isRecordFolder()); + assertFalse(filePlanComponent.isCategory()); assertEquals(createdComponent.getName(), filePlanComponent.getName()); assertEquals(createdComponent.getNodeType(), filePlanComponent.getNodeType()); 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 329131b95c..d074f1c8e8 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 @@ -27,11 +27,6 @@ package org.alfresco.rest.rm.community.fileplancomponents; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentAlias.UNFILED_RECORDS_CONTAINER_ALIAS; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NAME; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.NODE_TYPE; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_DESCRIPTION; -import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentFields.PROPERTIES_TITLE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.FILE_PLAN_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.HOLD_TYPE; @@ -41,7 +36,6 @@ import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanCo import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_CONTAINER_TYPE; import static org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentType.UNFILED_RECORD_FOLDER_TYPE; import static org.alfresco.utility.data.RandomData.getRandomAlphanumeric; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.springframework.http.HttpStatus.CREATED; import static org.springframework.http.HttpStatus.NOT_FOUND; import static org.springframework.http.HttpStatus.NO_CONTENT; @@ -54,8 +48,6 @@ import static org.testng.Assert.assertTrue; import java.util.List; import java.util.stream.Collectors; -import com.google.gson.JsonObject; - import org.alfresco.rest.core.RestWrapper; import org.alfresco.rest.rm.community.base.BaseRestTest; import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent; @@ -83,7 +75,8 @@ public class UnfiledRecordsFolderTests extends BaseRestTest private DataUser dataUser; /** invalid root level types, at unfiled records root level these shouldn't be possible to create */ - @DataProvider(name = "invalidRootTypes") + +@DataProvider(name = "invalidRootTypes") public Object[][] createData1() { return new Object[][] { { FILE_PLAN_TYPE }, @@ -114,29 +107,22 @@ public class UnfiledRecordsFolderTests extends BaseRestTest String folderDescription = folderName + " Description"; // Build unfiled records folder properties - JsonObject unfiledFolderProperties = buildObject() - .add(NAME, folderName) - .add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, folderTitle) - .add(PROPERTIES_DESCRIPTION, folderDescription) - .end() - .getJson(); + FilePlanComponent unfiledFolder=new FilePlanComponent(folderName,UNFILED_RECORD_FOLDER_TYPE.toString(), + new FilePlanComponentProperties(folderTitle,folderDescription)); - FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties, + FilePlanComponent filePlanComponent = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS.toString()); // Verify the status code - restWrapper.assertStatusCodeIs(CREATED); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(filePlanComponent.isIsCategory()); - assertFalse(filePlanComponent.isIsFile()); - assertFalse(filePlanComponent.isIsRecordFolder()); // it is not a _normal_ record folder! + assertFalse(filePlanComponent.isCategory()); + assertFalse(filePlanComponent.isFile()); + assertFalse(filePlanComponent.isRecordFolder()); // it is not a _normal_ record folder! assertEquals(filePlanComponent.getName(), folderName); assertEquals(filePlanComponent.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); - assertFalse(filePlanComponent.isHasRetentionSchedule()); assertEquals(filePlanComponent.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername()); @@ -164,17 +150,13 @@ public class UnfiledRecordsFolderTests extends BaseRestTest logger.info("creating " + componentType.toString()); - JsonObject unfiledFolderProperties = buildObject() - .add(NAME, folderName) - .add(NODE_TYPE, componentType.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, folderTitle) - .add(PROPERTIES_DESCRIPTION, folderDescription) - .end() - .getJson(); + // Build unfiled records folder properties + FilePlanComponent unfiledFolder = new FilePlanComponent(folderName, componentType.toString(), + new FilePlanComponentProperties(folderTitle, folderDescription)); + try { - filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties, + filePlanComponentAPI.createFilePlanComponent(unfiledFolder, UNFILED_RECORDS_CONTAINER_ALIAS.toString()); } catch (Exception error) @@ -182,7 +164,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest } // Verify the status code - restWrapper.assertStatusCodeIs(UNPROCESSABLE_ENTITY); + filePlanComponentAPI.usingRestWrapper().assertStatusCodeIs(UNPROCESSABLE_ENTITY); } /** @@ -207,31 +189,23 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(parentFolderName, parentFolder.getName()); // Build the unfiled records folder properties - JsonObject unfiledFolderProperties = buildObject() - .add(NAME, childFolderName) - .add(NODE_TYPE, UNFILED_RECORD_FOLDER_TYPE.toString()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, childFolderTitle) - .add(PROPERTIES_DESCRIPTION, childFolderDescription) - .end() - .getJson(); + FilePlanComponent unfiledFolder = new FilePlanComponent(childFolderName, UNFILED_RECORD_FOLDER_TYPE.toString(), + new FilePlanComponentProperties(childFolderTitle, childFolderDescription)); // Create it as a child of parentFolder - FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolderProperties, + FilePlanComponent childFolder = filePlanComponentAPI.createFilePlanComponent(unfiledFolder, parentFolder.getId()); // Verify the status code restWrapper.assertStatusCodeIs(CREATED); // Verify the returned file plan component - assertFalse(childFolder.isIsCategory()); - assertFalse(childFolder.isIsFile()); - assertFalse(childFolder.isIsRecordFolder()); // it is not a _normal_ record folder! + assertFalse(childFolder.isCategory()); + assertFalse(childFolder.isFile()); + assertFalse(childFolder.isRecordFolder()); // it is not a _normal_ record folder! assertEquals(childFolder.getName(), childFolderName); assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString()); - assertFalse(childFolder.isHasRetentionSchedule()); - assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername()); // Verify the returned file plan component properties @@ -277,16 +251,11 @@ public class UnfiledRecordsFolderTests extends BaseRestTest assertEquals(folderName, folderToModify.getName()); // Build the properties which will be updated - JsonObject updateFolderProperties = buildObject() - .add(NAME, modified + folderToModify.getName()) - .addObject(PROPERTIES) - .add(PROPERTIES_TITLE, modified + folderToModify.getProperties().getTitle()) - .add(PROPERTIES_DESCRIPTION, modified + folderToModify.getProperties().getDescription()) - .end() - .getJson(); - + FilePlanComponent folderToUpdate = new FilePlanComponent(modified + folderToModify.getName(), + new FilePlanComponentProperties(modified + folderToModify.getProperties().getTitle(), + modified + folderToModify.getProperties().getDescription())); // Update the unfiled records folder - filePlanComponentAPI.updateFilePlanComponent(updateFolderProperties, folderToModify.getId()); + filePlanComponentAPI.updateFilePlanComponent(folderToUpdate, folderToModify.getId()); // Verify the status code restWrapper.assertStatusCodeIs(OK); 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 4193ad70d6..417895d64f 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 @@ -31,10 +31,6 @@ 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.model.site.RMSiteFields.COMPLIANCE; -import static org.alfresco.rest.rm.community.model.site.RMSiteFields.DESCRIPTION; -import static org.alfresco.rest.rm.community.model.site.RMSiteFields.TITLE; -import static org.jglue.fluentjson.JsonBuilderFactory.buildObject; import static org.springframework.http.HttpStatus.BAD_REQUEST; import static org.springframework.http.HttpStatus.CONFLICT; import static org.springframework.http.HttpStatus.CREATED; @@ -46,13 +42,11 @@ import static org.springframework.social.alfresco.api.entities.Site.Visibility.P import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import com.google.gson.JsonObject; - 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.model.site.RMSite; import org.alfresco.rest.rm.community.requests.RMSiteAPI; -import org.alfresco.rest.core.RestWrapper; import org.alfresco.utility.constants.UserRole; import org.alfresco.utility.data.DataUser; import org.alfresco.utility.data.RandomData; @@ -100,26 +94,20 @@ public class RMSiteTests extends BaseRestTest rmSiteAPI.deleteRMSite(); } - // Build the RM site properties - JsonObject rmSiteProperties = buildObject() - .add(TITLE, RM_TITLE) - .add(DESCRIPTION, RM_DESCRIPTION) - .add(COMPLIANCE, STANDARD.toString()) - .getJson(); - // Create the RM site - RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties); + RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, STANDARD); + RMSite rmSiteResponse = rmSiteAPI.createRMSite(rmSite); // Verify the status code rmSiteAPI.usingRestWrapper().assertStatusCodeIs(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(), STANDARD); - assertEquals(rmSite.getVisibility(), PUBLIC); - assertEquals(rmSite.getRole(), UserRole.SiteManager.toString()); + assertEquals(rmSiteResponse.getId(), RM_ID); + assertEquals(rmSiteResponse.getTitle(), RM_TITLE); + assertEquals(rmSiteResponse.getDescription(), RM_DESCRIPTION); + assertEquals(rmSiteResponse.getCompliance(), STANDARD); + assertEquals(rmSiteResponse.getVisibility(), PUBLIC); + assertEquals(rmSiteResponse.getRole(), UserRole.SiteManager.toString()); } /** @@ -143,15 +131,9 @@ public class RMSiteTests extends BaseRestTest String newTitle = RM_TITLE + "createRMSiteWhenSiteExists"; String newDescription = RM_DESCRIPTION + "createRMSiteWhenSiteExists"; - // Build the RM site properties - JsonObject rmSiteProperties = buildObject() - .add(TITLE, newTitle) - .add(DESCRIPTION, newDescription) - .add(COMPLIANCE, STANDARD.toString()) - .getJson(); - // Create the RM site - rmSiteAPI.createRMSite(rmSiteProperties); + RMSite rmSite = new RMSite(newTitle, newDescription, STANDARD); + rmSiteAPI.createRMSite(rmSite); // Verify the status code restWrapper.assertStatusCodeIs(CONFLICT); @@ -253,15 +235,9 @@ public class RMSiteTests extends BaseRestTest // Authenticate as that new user rmSiteAPI.usingRestWrapper().authenticateUser(userModel); - // Build the RM site properties - JsonObject rmSiteProperties = buildObject() - .add(TITLE, RM_TITLE) - .add(DESCRIPTION, RM_DESCRIPTION) - .add(COMPLIANCE, DOD5015.toString()) - .getJson(); - // Create the RM site - RMSite rmSite = rmSiteAPI.createRMSite(rmSiteProperties); + RMSite rmSite = new RMSite(RM_TITLE, RM_DESCRIPTION, DOD5015); + rmSite=rmSiteAPI.createRMSite(rmSite); // Verify the status code rmSiteAPI.usingRestWrapper().assertStatusCodeIs(CREATED); @@ -286,13 +262,7 @@ public class RMSiteTests extends BaseRestTest public void updateRMSiteDetails()throws Exception { String NEW_TITLE = RM_TITLE + RandomData.getRandomAlphanumeric(); - String NEW_DESCRIPTION=RM_DESCRIPTION+ RandomData.getRandomAlphanumeric(); - - // Build the RM site properties - JsonObject rmSiteToUpdate = buildObject() - .add(TITLE, NEW_TITLE) - .add(DESCRIPTION, NEW_DESCRIPTION) - .getJson(); + String NEW_DESCRIPTION = RM_DESCRIPTION+ RandomData.getRandomAlphanumeric(); // Authenticate with admin user rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); @@ -300,6 +270,11 @@ public class RMSiteTests extends BaseRestTest // Create the site if it does not exist createRMSiteIfNotExists(); + //Create RM site model + RMSite rmSiteToUpdate = new RMSite(); + rmSiteToUpdate.setTitle(NEW_TITLE); + rmSiteToUpdate.setDescription(NEW_DESCRIPTION); + // Disconnect the user from the API session rmSiteAPI.usingRestWrapper().disconnect(); @@ -310,7 +285,7 @@ public class RMSiteTests extends BaseRestTest rmSiteAPI.usingRestWrapper().authenticateUser(nonRMuser); // Create the RM site - RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); + rmSiteAPI.updateRMSite(rmSiteToUpdate); // Verify the status code rmSiteAPI.usingRestWrapper().assertStatusCodeIs(FORBIDDEN); @@ -322,7 +297,7 @@ public class RMSiteTests extends BaseRestTest rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser()); // Update the RM Site - rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); + RMSite rmSite = rmSiteAPI.updateRMSite(rmSiteToUpdate); // Verify the response status code rmSiteAPI.usingRestWrapper().assertStatusCodeIs(OK); @@ -350,9 +325,7 @@ public class RMSiteTests extends BaseRestTest createRMSiteIfNotExists(); // Build the RM site properties - JsonObject rmSiteToUpdate = buildObject() - .add(COMPLIANCE, DOD5015.toString()) - .getJson(); + RMSite rmSiteToUpdate = new RMSite(DOD5015); // Update the RM site rmSiteAPI.updateRMSite(rmSiteToUpdate);