RM-4488 (Refactor REST API Automation test code according to the latest changes)

This commit is contained in:
Tuna Aksoy
2016-12-26 23:19:14 +00:00
parent 2be7e42f93
commit 8876f48c1e
25 changed files with 493 additions and 388 deletions

View File

@@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/**
* FIXME!!!
* Extends {@link RestProperties} to be able to change/add properties
*
* @author Tuna Aksoy
* @since 2.6

View File

@@ -33,7 +33,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
/**
* FIXME!!!
* Extends {@link RestWrapper} in order to call IG APIs with our own properties
*
* @author Tuna Aksoy
* @since 2.6

View File

@@ -56,7 +56,7 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentModel extends TestModel
public class FilePlanComponent extends TestModel
{
@JsonProperty (required = true)
private String id;

View File

@@ -49,8 +49,8 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class FilePlanComponentEntry extends RestModels<FilePlanComponentModel, FilePlanComponentEntry>
public class FilePlanComponentEntry extends RestModels<FilePlanComponent, FilePlanComponentEntry>
{
@JsonProperty(ENTRY)
FilePlanComponentModel filePlanComponentModel;
FilePlanComponent filePlanComponentModel;
}

View File

@@ -84,7 +84,7 @@ public class FilePlanComponentProperties
@JsonProperty(PROPERTIES_REVIEW_PERIOD)
@JsonSerialize (using = ReviewPeriodSerializer.class)
private ReviewPeriod reviewPeriod;
private FilePlanComponentReviewPeriod reviewPeriod;
@JsonProperty(PROPERTIES_LOCATION)
private String location;

View File

@@ -32,7 +32,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
/**
* POJO for the review period
* POJO for the file plan component review period
*
* @author Rodica Sutu
* @since 2.6
@@ -41,7 +41,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ReviewPeriod
public class FilePlanComponentReviewPeriod
{
private String periodType;
private String expression;

View File

@@ -49,7 +49,7 @@ import lombok.NoArgsConstructor;
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class RMSiteModel extends RestSiteModel
public class RMSite extends RestSiteModel
{
@JsonProperty (value = COMPLIANCE, required = true)
private RMSiteCompliance compliance;

View File

@@ -30,7 +30,7 @@ import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.requests.ModelRequest;
/**
* FIXME!!!
* Extends {@link ModelRequest} to set {@link RMRestWrapper}
*
* @author Tuna Aksoy
* @since 2.6

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.requests;
package org.alfresco.rest.rm.community.requests.igCoreAPI;
import static com.jayway.restassured.RestAssured.basic;
import static com.jayway.restassured.RestAssured.given;
@@ -53,22 +53,25 @@ import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.response.Response;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentsCollection;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.utility.model.UserModel;
/**
* FIXME!!!
* File plan component REST API Wrapper
*
* @author Tuna Aksoy
* @since 2.6
*/
public class FilePlanComponents extends RMModelRequest
public class FilePlanComponentAPI extends RMModelRequest
{
/**
* Constructor
*
* @param restWrapper
*/
public FilePlanComponents(RMRestWrapper rmRestWrapper)
public FilePlanComponentAPI(RMRestWrapper rmRestWrapper)
{
super(rmRestWrapper);
}
@@ -77,7 +80,7 @@ public class FilePlanComponents extends RMModelRequest
* Get a file plan component
*
* @param filePlanComponentId The id of the file plan component to get
* @return The {@link FilePlanComponentModel} for the given file plan component id
* @return The {@link FilePlanComponent} for the given file plan component id
* @throws Exception for the following cases:
* <ul>
* <li>{@code fileplanComponentId} is not a valid format</li>
@@ -85,7 +88,7 @@ public class FilePlanComponents extends RMModelRequest
* <li>{@code fileplanComponentId} does not exist</li>
* </ul>
*/
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId) throws Exception
public FilePlanComponent getFilePlanComponent(String filePlanComponentId) throws Exception
{
mandatoryString("filePlanComponentId", filePlanComponentId);
@@ -93,18 +96,23 @@ public class FilePlanComponents extends RMModelRequest
}
/**
* FIXME!!!
* Get a file plan component
*
* @param filePlanComponentId FIXME!!!
* @param parameters FIXME!!!
* @return FIXME!!!
* @throws Exception FIXME!!!
* @param filePlanComponentId The id of the file plan component to get
* @param parameters The URL parameters to add
* @return The {@link FilePlanComponent} for the given file plan component id
* @throws Exception for the following cases:
* <ul>
* <li>{@code fileplanComponentId} is not a valid format</li>
* <li>authentication fails</li>
* <li>{@code fileplanComponentId} does not exist</li>
* </ul>
*/
public FilePlanComponentModel getFilePlanComponent(String filePlanComponentId, String parameters) throws Exception
public FilePlanComponent getFilePlanComponent(String filePlanComponentId, String parameters) throws Exception
{
mandatoryString("filePlanComponentId", filePlanComponentId);
return getRMRestWrapper().processModel(FilePlanComponentModel.class, simpleRequest(
return getRMRestWrapper().processModel(FilePlanComponent.class, simpleRequest(
GET,
"fileplan-components/{fileplanComponentId}?{parameters}",
filePlanComponentId,
@@ -140,7 +148,7 @@ public class FilePlanComponents extends RMModelRequest
*
* @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 FilePlanComponentModel} with the given properties
* @return The {@link FilePlanComponent} with the given properties
* @throws Exception for the following cases:
* <ul>
* <li>{@code fileplanComponentId} is not a valid format</li>
@@ -151,7 +159,7 @@ public class FilePlanComponents extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId) throws Exception
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId) throws Exception
{
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
mandatoryString("parentId", parentId);
@@ -160,26 +168,34 @@ public class FilePlanComponents extends RMModelRequest
}
/**
* FIXME!!!
* Creates a file plan component with the given properties under the parent node with the given id
*
* @param filePlanComponentModel FIXME!!!
* @param parentId FIXME!!!
* @param parameters FIXME!!!
* @return FIXME!!!
* @throws Exception FIXME!!!
* @param filePlanComponentModel The properties of the file plan component to be created
* @param parameters The URL parameters to add
* @param parentId The id of the parent where the new file plan component should be created
* @return The {@link FilePlanComponent} with the given properties
* @throws Exception for the following cases:
* <ul>
* <li>{@code fileplanComponentId} is not a valid format</li>
* <li>authentication fails</li>
* <li>current user does not have permission to add children to {@code fileplanComponentId}</li>
* <li>{@code fileplanComponentId} does not exist</li>
* <li>new name clashes with an existing node in the current parent container</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public FilePlanComponentModel createFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String parentId, String parameters) throws Exception
public FilePlanComponent createFilePlanComponent(FilePlanComponent filePlanComponentModel, String parentId, String parameters) throws Exception
{
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
mandatoryString("parentId", parentId);
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
return getRMRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
POST,
toJson(filePlanComponentModel),
"fileplan-components/{fileplanComponentId}/children?{parameters}",
parentId,
parameters
));
));
}
/**
@@ -190,7 +206,7 @@ public class FilePlanComponents extends RMModelRequest
* @return newly created {@link FilePlanComponent}
* @throws Exception if operation failed
*/
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, String fileName, String parentId) throws Exception
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, String fileName, String parentId) throws Exception
{
return createElectronicRecord(electronicRecordModel, new File(Resources.getResource(fileName).getFile()), parentId);
}
@@ -203,7 +219,7 @@ public class FilePlanComponents extends RMModelRequest
* @return newly created {@link FilePlanComponent}
* @throws Exception if operation failed
*/
public FilePlanComponentModel createElectronicRecord(FilePlanComponentModel electronicRecordModel, File recordContent, String parentId) throws Exception
public FilePlanComponent createElectronicRecord(FilePlanComponent electronicRecordModel, File recordContent, String parentId) throws Exception
{
mandatoryObject("electronicRecordModel", electronicRecordModel);
mandatoryString("parentId", parentId);
@@ -245,7 +261,7 @@ public class FilePlanComponents extends RMModelRequest
getRMRestWrapper().setStatusCode(Integer.toString(response.getStatusCode()));
/* return a FilePlanComponent object representing Response */
return response.jsonPath().getObject("entry", FilePlanComponentModel.class);
return response.jsonPath().getObject("entry", FilePlanComponent.class);
}
/**
@@ -264,7 +280,7 @@ public class FilePlanComponents extends RMModelRequest
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponentModel, String filePlanComponentId) throws Exception
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponentModel, String filePlanComponentId) throws Exception
{
mandatoryObject("filePlanComponentProperties", filePlanComponentModel);
mandatoryString("filePlanComponentId", filePlanComponentId);
@@ -272,18 +288,35 @@ public class FilePlanComponents extends RMModelRequest
return updateFilePlanComponent(filePlanComponentModel, filePlanComponentId, EMPTY);
}
public FilePlanComponentModel updateFilePlanComponent(FilePlanComponentModel filePlanComponent, String filePlanComponentId, String parameters) throws Exception
/**
* Updates a file plan component
*
* @param filePlanComponentModel The properties to be updated
* @param parameters The URL parameters to add
* @param filePlanComponentId The id of the file plan component which will be updated
* @param returns The updated {@link FilePlanComponent}
* @throws Exception for the following cases:
* <ul>
* <li>the update request is invalid or {@code fileplanComponentId} is not a valid format or {@code filePlanComponentProperties} is invalid</li>
* <li>authentication fails</li>
* <li>current user does not have permission to update {@code fileplanComponentId}</li>
* <li>{@code fileplanComponentId} does not exist</li>
* <li>the updated name clashes with an existing node in the current parent folder</li>
* <li>model integrity exception, including node name with invalid characters</li>
* </ul>
*/
public FilePlanComponent updateFilePlanComponent(FilePlanComponent filePlanComponent, String filePlanComponentId, String parameters) throws Exception
{
mandatoryObject("filePlanComponentProperties", filePlanComponent);
mandatoryString("filePlanComponentId", filePlanComponentId);
return getRMRestWrapper().processModel(FilePlanComponentModel.class, requestWithBody(
return getRMRestWrapper().processModel(FilePlanComponent.class, requestWithBody(
PUT,
toJson(filePlanComponent),
"fileplan-components/{fileplanComponentId}?{parameters}",
filePlanComponentId,
parameters
));
));
}
/**

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.requests;
package org.alfresco.rest.rm.community.requests.igCoreAPI;
import static org.alfresco.rest.core.RestRequest.requestWithBody;
import static org.alfresco.rest.core.RestRequest.simpleRequest;
@@ -37,20 +37,23 @@ import static org.springframework.http.HttpMethod.PUT;
import static org.springframework.http.HttpStatus.OK;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.model.site.RMSiteModel;
import org.alfresco.rest.rm.community.model.site.RMSite;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
/**
* FIXME!!!
* RM Site REST API Wrapper
*
* @author Tuna Aksoy
* @since 2.6
*/
public class RMSite extends RMModelRequest
public class RMSiteAPI extends RMModelRequest
{
/**
* @param restWrapper
* Constructor
*
* @param rmRestWrapper RM REST Wrapper
*/
public RMSite(RMRestWrapper rmRestWrapper)
public RMSiteAPI(RMRestWrapper rmRestWrapper)
{
super(rmRestWrapper);
}
@@ -58,7 +61,7 @@ public class RMSite extends RMModelRequest
/**
* Get the RM site
*
* @return The {@link RMSiteModel} for the given file plan component id
* @return The {@link RMSite} for the given file plan component id
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: GET request is supported only for the RM site</li>
@@ -67,9 +70,9 @@ public class RMSite extends RMModelRequest
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public RMSiteModel getSite() throws Exception
public RMSite getSite() throws Exception
{
return getRMRestWrapper().processModel(RMSiteModel.class, simpleRequest(
return getRMRestWrapper().processModel(RMSite.class, simpleRequest(
GET,
"ig-sites/rm"
));
@@ -79,7 +82,7 @@ public class RMSite extends RMModelRequest
* Create the RM site
*
* @param rmSite The properties of the rm site to be created
* @return The {@link RMSiteModel} with the given properties
* @return The {@link RMSite} with the given properties
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 Invalid parameter: title, or description exceed the maximum length; or siteBodyCreate invalid</li>
@@ -88,11 +91,11 @@ public class RMSite extends RMModelRequest
* <li>Api Response code default Unexpected error</li>
* </ul>
*/
public RMSiteModel createRMSite(RMSiteModel rmSiteModel) throws Exception
public RMSite createRMSite(RMSite rmSiteModel) throws Exception
{
mandatoryObject("rmSiteModel", rmSiteModel);
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
return getRMRestWrapper().processModel(RMSite.class, requestWithBody(
POST,
toJson(rmSiteModel),
"ig-sites"
@@ -122,7 +125,7 @@ public class RMSite extends RMModelRequest
* Update RM site
*
* @param rmSiteProperties The properties to be updated
* @return The updated {@link RMSiteModel}
* @return The updated {@link RMSite}
* @throws Exception for the following cases:
* <ul>
* <li>Api Response code 400 the update request is invalid {@code rmSiteModel} is invalid</li>
@@ -132,11 +135,11 @@ public class RMSite extends RMModelRequest
* <li>Api Response code default Unexpected error,model integrity exception</li>
* </ul>
*/
public RMSiteModel updateRMSite(RMSiteModel rmSiteModel) throws Exception
public RMSite updateRMSite(RMSite rmSiteModel) throws Exception
{
mandatoryObject("rmSiteProperties", rmSiteModel);
return getRMRestWrapper().processModel(RMSiteModel.class, requestWithBody(
return getRMRestWrapper().processModel(RMSite.class, requestWithBody(
PUT,
toJson(rmSiteModel),
"ig-sites/rm"

View File

@@ -24,7 +24,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.rest.rm.community.requests;
package org.alfresco.rest.rm.community.requests.igCoreAPI;
import static com.jayway.restassured.RestAssured.given;
@@ -40,7 +40,7 @@ import org.alfresco.dataprep.AlfrescoHttpClient;
import org.alfresco.dataprep.AlfrescoHttpClientFactory;
import org.alfresco.dataprep.UserService;
import org.alfresco.rest.core.RestAPI;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentModel;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponent;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.UserModel;
import org.springframework.beans.factory.annotation.Autowired;
@@ -100,7 +100,7 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
* @param user {@link UserModel} for a user to be granted permission
* @param permission {@link UserPermissions} to be granted
*/
public void addUserPermission(FilePlanComponentModel component, UserModel user, String permission)
public void addUserPermission(FilePlanComponent component, UserModel user, String permission)
{
// get an "old-style" REST API client
AlfrescoHttpClient client = alfrescoHttpClientFactory.getObject();
@@ -135,10 +135,10 @@ public class RMUserAPI extends RestAPI<RMUserAPI>
}
/**
* FIXME!!!
* Creates a user with the given name using the old APIs
*
* @param userName FIXME!!!
* @return FIXME!!!
* @param userName The user name
* @return <code>true</code> if the user was created successfully, <code>false</code> otherwise.
*/
public boolean createUser(String userName)
{

View File

@@ -33,9 +33,7 @@ import com.jayway.restassured.RestAssured;
import org.alfresco.rest.core.RMRestProperties;
import org.alfresco.rest.core.RMRestWrapper;
import org.alfresco.rest.rm.community.requests.FilePlanComponents;
import org.alfresco.rest.rm.community.requests.RMModelRequest;
import org.alfresco.rest.rm.community.requests.RMSite;
/**
* Defines the entire IG Core API
@@ -50,10 +48,10 @@ public class RestIGCoreAPI extends RMModelRequest
private RMRestProperties rmRestProperties;
/**
* FIXME!!!
* Constructor
*
* @param rmRestWrapper FIXME!!!
* @param rmRestProperties FIXME!!!
* @param rmRestWrapper RM REST Wrapper
* @param rmRestProperties RM REST Properties
*/
public RestIGCoreAPI(RMRestWrapper rmRestWrapper, RMRestProperties rmRestProperties)
{
@@ -67,20 +65,20 @@ public class RestIGCoreAPI extends RMModelRequest
/**
* Provides DSL on all REST calls under <code>ig-sites/rm/...</code> API path
*
* @return {@link RMSite}
* @return {@link RMSiteAPI}
*/
public RMSite usingRMSite()
public RMSiteAPI usingRMSite()
{
return new RMSite(getRMRestWrapper());
return new RMSiteAPI(getRMRestWrapper());
}
/**
* FIXME!!!
* Provides DSL on all REST calls under <code>fileplan-components/...</code> API path
*
* @return FIXME!!!
* @return {@link FilePlanComponentAPI}
*/
public FilePlanComponents usingFilePlanComponents()
public FilePlanComponentAPI usingFilePlanComponents()
{
return new FilePlanComponents(getRMRestWrapper());
return new FilePlanComponentAPI(getRMRestWrapper());
}
}

View File

@@ -33,7 +33,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
import org.alfresco.rest.rm.community.model.fileplancomponents.FilePlanComponentReviewPeriod;
/**
* Utility class for serializing the Review Period type
@@ -41,7 +41,7 @@ import org.alfresco.rest.rm.community.model.fileplancomponents.ReviewPeriod;
* @author Rodica Sutu
* @since 2.6
*/
public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
public class ReviewPeriodSerializer extends JsonSerializer<FilePlanComponentReviewPeriod>
{
/**
* @param value The Review Period value that is being serialized.
@@ -51,7 +51,7 @@ public class ReviewPeriodSerializer extends JsonSerializer<ReviewPeriod>
* @throws JsonProcessingException
*/
@Override
public void serialize(ReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
public void serialize(FilePlanComponentReviewPeriod value, JsonGenerator gen, SerializerProvider serializers) throws IOException, JsonProcessingException
{
//create the custom string value for the Review Period type
gen.writeString(new StringBuilder().append(value.getPeriodType()).append("|").append(value.getExpression()).toString());