- Create a utility class with the toJson() method to convert models to json object

- update the test to use models
This commit is contained in:
Rodica Sutu
2016-11-28 10:11:01 +02:00
parent 74b8e0ac18
commit e87df92099
14 changed files with 283 additions and 293 deletions

View File

@@ -55,22 +55,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<String> aspectNames;
@@ -88,13 +88,32 @@ public class FilePlanComponent
@JsonProperty (required = true)
private String modifiedAt;
@JsonProperty (required = true)
private String createdAt;
@JsonProperty (required = true)
private FilePlanComponentUserInfo modifiedByUser;
public FilePlanComponent(String name, String nodeType, FilePlanComponentProperties properties)
{
this.name = name;
this.nodeType = nodeType;
this.properties = properties;
}
public FilePlanComponent()
{
}
public FilePlanComponent(String name)
{
this.name = name;
}
public FilePlanComponent(String name, FilePlanComponentProperties properties)
{
this.name = name;
this.properties = properties;
}
/**
* @return the id
@@ -163,7 +182,7 @@ public class FilePlanComponent
/**
* @return the isCategory
*/
public boolean isIsCategory()
public Boolean isIsCategory()
{
return this.isCategory;
}
@@ -171,7 +190,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 +198,7 @@ public class FilePlanComponent
/**
* @return the isRecordFolder
*/
public boolean isIsRecordFolder()
public Boolean isIsRecordFolder()
{
return this.isRecordFolder;
}
@@ -187,7 +206,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 +214,7 @@ public class FilePlanComponent
/**
* @return the isFile
*/
public boolean isIsFile()
public Boolean isIsFile()
{
return this.isFile;
}
@@ -203,7 +222,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 +230,7 @@ public class FilePlanComponent
/**
* @return the hasRetentionSchedule
*/
public boolean isHasRetentionSchedule()
public Boolean isHasRetentionSchedule()
{
return this.hasRetentionSchedule;
}
@@ -219,7 +238,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 +366,7 @@ public class FilePlanComponent
/**
* @return the isClosed
*/
public boolean isClosed()
public Boolean isClosed()
{
return this.isClosed;
}
@@ -355,7 +374,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 +382,7 @@ public class FilePlanComponent
/**
* @return the isCompleted
*/
public boolean isCompleted()
public Boolean isCompleted()
{
return this.isCompleted;
}
@@ -371,7 +390,7 @@ public class FilePlanComponent
/**
* @param completed the isCompleted to set
*/
public void setCompleted(boolean completed)
public void setCompleted(Boolean completed)
{
this.isCompleted = completed;
}

View File

@@ -40,7 +40,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public class FilePlanComponentPath
{
private String name;
private boolean isComplete;
private Boolean isComplete;
private List<FilePlanComponentIdNamePair> 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;
}

View File

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

View File

@@ -32,11 +32,22 @@ package org.alfresco.rest.rm.community.model.fileplancomponents;
* @author Rodica Sutu
* @since 2.6
*/
public class ReviewPeriod
{
private String periodType;
private String expression;
public ReviewPeriod(String periodType, String expression)
{
this.periodType = periodType;
this.expression = expression;
}
public ReviewPeriod()
{
}
/**
* @return the periodType
*/

View File

@@ -26,7 +26,10 @@
*/
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 com.google.gson.Gson;
import org.alfresco.rest.model.RestSiteModel;
@@ -38,9 +41,24 @@ import org.alfresco.rest.model.RestSiteModel;
*/
public class RMSite extends RestSiteModel
{
@JsonProperty (required = true)
@JsonProperty (value = COMPLIANCE,required = true)
private RMSiteCompliance compliance;
public RMSite(String title, String description, RMSiteCompliance compliance)
{
this.title=title;
this.description=description;
this.compliance=compliance;
}
public RMSite() { }
public RMSite(RMSiteCompliance compliance)
{
super();
this.compliance = compliance;
}
/**
* Helper method to set RM site compliance
*
@@ -60,4 +78,5 @@ public class RMSite extends RestSiteModel
{
return compliance;
}
}

View File

@@ -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<FilePlanComponentAPI>
/**
* 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<FilePlanComponentAPI>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
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<FilePlanComponentAPI>
/**
* 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<FilePlanComponentAPI>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
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<FilePlanComponentAPI>
filePlanComponentId
));
}
}

View File

@@ -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<RMSiteAPI>
/**
* 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:
* <ul>
@@ -91,13 +90,13 @@ public class RMSiteAPI extends RestAPI<RMSiteAPI>
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
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<RMSiteAPI>
* <li>Api Response code default Unexpected error,model integrity exception</li>
* </ul>
*/
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"
));
}

View File

@@ -0,0 +1,66 @@
/*
* #%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 <http://www.gnu.org/licenses/>.
* #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
{
public static String toJson(Object rmModel) throws JsonProcessingException
{
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_DEFAULT);
try
{
String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rmModel);
System.out.println("Json object generated is :" + json);
return json;
} catch (JsonGenerationException e)
{
return e.toString();
} catch (JsonMappingException e)
{
return e.toString();
} catch (IOException e)
{
return e.toString();
}
}
}

View File

@@ -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;
@@ -127,15 +120,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);
@@ -195,14 +182,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;
}

View File

@@ -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()))
@@ -199,15 +199,12 @@ public class FilePlanTests extends BaseRestTest
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();
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);
@@ -304,23 +301,20 @@ public class FilePlanTests extends BaseRestTest
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);
}

View File

@@ -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,16 +94,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());
// Verify the status code
restWrapper.assertStatusCodeIs(CREATED);
@@ -122,7 +109,6 @@ public class RecordCategoryTest extends BaseRestTest
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());
@@ -368,20 +341,15 @@ public class RecordCategoryTest extends BaseRestTest
{
String COMPONENT_NAME="Component"+getRandomAlphanumeric();
// Authenticate with admin user
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
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 +379,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;
}

View File

@@ -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,19 +47,17 @@ 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;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
/**
@@ -103,18 +92,15 @@ public class RecordFolderTests extends BaseRestTest
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
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.createFilePlanComponent(recordFolderProperties, 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
@@ -151,16 +137,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);
@@ -224,22 +204,16 @@ public class RecordFolderTests extends BaseRestTest
String folderName= "The folder name is updated" + getRandomAlphanumeric();
String folderTitle = "Update title " + getRandomAlphanumeric();
String location="Location"+getRandomAlphanumeric();
String review_period="month|1";
// 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();
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);
@@ -361,7 +335,7 @@ public class RecordFolderTests extends BaseRestTest
);
}
@AfterClass (alwaysRun = true)
//@AfterClass (alwaysRun = true)
public void tearDown() throws Exception
{
filePlanComponentAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());

View File

@@ -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,6 +75,7 @@ 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")
public Object[][] createData1() {
return new Object[][] {
@@ -114,20 +107,14 @@ 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());
@@ -136,7 +123,6 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
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,17 +189,11 @@ 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
@@ -230,7 +206,7 @@ public class UnfiledRecordsFolderTests extends BaseRestTest
assertEquals(childFolder.getName(), childFolderName);
assertEquals(childFolder.getNodeType(), UNFILED_RECORD_FOLDER_TYPE.toString());
assertFalse(childFolder.isHasRetentionSchedule());
// assertFalse(childFolder.isHasRetentionSchedule());
assertEquals(childFolder.getCreatedByUser().getId(), dataUser.getAdminUser().getUsername());
@@ -277,16 +253,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);

View File

@@ -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);
@@ -288,18 +264,17 @@ public class RMSiteTests extends BaseRestTest
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();
// Authenticate with admin user
rmSiteAPI.usingRestWrapper().authenticateUser(dataUser.getAdminUser());
// 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);