Class RMRestWrapper


  • @Service
    @Scope("prototype")
    public class RMRestWrapper
    extends Object
    Extends RestWrapper in order to call GS APIs with our own properties
    Since:
    2.6
    Author:
    Tuna Aksoy
    • Constructor Summary

      Constructors 
      Constructor Description
      RMRestWrapper()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.alfresco.rest.model.RestErrorModel assertLastError()
      Get the last error thrown (if any).
      void assertStatusCodeIs​(org.springframework.http.HttpStatus statusCode)
      Assert that a specific status code is returned.
      void authenticateUser​(org.alfresco.utility.model.UserModel userModel)
      Authenticate specific user to Alfresco REST API
      io.restassured.builder.RequestSpecBuilder configureRequestSpec()
      You can handle the request sent to server by calling this method.
      org.alfresco.utility.model.StatusModel getLastStatus()
      Get the most recently returned status object.
      String getParameters()  
      org.alfresco.rest.core.RestWrapper getRestWrapper()
      Get the core class that wraps the ReST APIs.
      String getStatusCode()
      Get the most recently returned status code.
      org.alfresco.utility.model.UserModel getTestUser()
      Create a UserModel for a new test user.
      void processEmptyModel​(org.alfresco.rest.core.RestRequest simpleRequest)
      Process a response that has no body - basically will need only the status code from it.
      org.alfresco.rest.model.RestHtmlResponse processHtmlResponse​(org.alfresco.rest.core.RestRequest simpleRequest)
      Process a response that returns a html
      <T> T processModel​(Class<T> classz, org.alfresco.rest.core.RestRequest restRequest)
      Process responses for a single model as RestSiteModel.
      <T> T processModels​(Class<T> classz, org.alfresco.rest.core.RestRequest simpleRequest)
      Process responses for a collection of models as RestSiteModelsCollection.
      void setStatusCode​(String statusCode)
      Set the status code.
      org.alfresco.rest.requests.coreAPI.RestCoreAPI withCoreAPI()
      Get the Alfresco Core API.
      GSCoreAPI withGSCoreAPI()  
      org.alfresco.rest.requests.search.SearchAPI withSearchAPI()
      Get the Alfresco Search API.
    • Constructor Detail

      • RMRestWrapper

        public RMRestWrapper()
    • Method Detail

      • withGSCoreAPI

        public GSCoreAPI withGSCoreAPI()
      • getRestWrapper

        public org.alfresco.rest.core.RestWrapper getRestWrapper()
        Get the core class that wraps the ReST APIs.
      • authenticateUser

        public void authenticateUser​(org.alfresco.utility.model.UserModel userModel)
        Authenticate specific user to Alfresco REST API
      • assertLastError

        public org.alfresco.rest.model.RestErrorModel assertLastError()
        Get the last error thrown (if any).
      • processModels

        public <T> T processModels​(Class<T> classz,
                                   org.alfresco.rest.core.RestRequest simpleRequest)
        Process responses for a collection of models as RestSiteModelsCollection.
      • processModel

        public <T> T processModel​(Class<T> classz,
                                  org.alfresco.rest.core.RestRequest restRequest)
        Process responses for a single model as RestSiteModel.
      • processEmptyModel

        public void processEmptyModel​(org.alfresco.rest.core.RestRequest simpleRequest)
        Process a response that has no body - basically will need only the status code from it.
      • getLastStatus

        public org.alfresco.utility.model.StatusModel getLastStatus()
        Get the most recently returned status object.
      • getStatusCode

        public String getStatusCode()
        Get the most recently returned status code.
      • setStatusCode

        public void setStatusCode​(String statusCode)
        Set the status code. This should only be needed when calling APIs without using the TAS framework.
      • assertStatusCodeIs

        public void assertStatusCodeIs​(org.springframework.http.HttpStatus statusCode)
        Assert that a specific status code is returned.
      • getParameters

        public String getParameters()
        Returns:
        A parameters string that you could pass on the request ?param=value
      • getTestUser

        public org.alfresco.utility.model.UserModel getTestUser()
        Create a UserModel for a new test user.
      • withCoreAPI

        public org.alfresco.rest.requests.coreAPI.RestCoreAPI withCoreAPI()
        Get the Alfresco Core API.
      • withSearchAPI

        public org.alfresco.rest.requests.search.SearchAPI withSearchAPI()
        Get the Alfresco Search API.
      • configureRequestSpec

        public io.restassured.builder.RequestSpecBuilder configureRequestSpec()
        You can handle the request sent to server by calling this method. If for example you want to sent multipart form data you can use:
         restClient.configureRequestSpec()
                      .addMultiPart("filedata", Utility.getResourceTestDataFile("restapi-resource"))
                      .addFormParam("renditions", "doclib")
                      .addFormParam("autoRename", true);
        
         restClient.withCoreAPI().usingNode(ContentModel.my()).createNode();
         
        This will create the node using the multipart data defined.
      • processHtmlResponse

        public org.alfresco.rest.model.RestHtmlResponse processHtmlResponse​(org.alfresco.rest.core.RestRequest simpleRequest)
        Process a response that returns a html
        Throws:
        org.alfresco.rest.exception.EmptyJsonResponseException - If there is no response from the server.