Class OperationRequestFactory

java.lang.Object
org.springframework.restdocs.operation.OperationRequestFactory

public class OperationRequestFactory extends Object
A factory for creating OperationRequests.
Author:
Andy Wilkinson
  • Constructor Details

    • OperationRequestFactory

      public OperationRequestFactory()
  • Method Details

    • create

      public OperationRequest create(URI uri, org.springframework.http.HttpMethod method, byte[] content, org.springframework.http.HttpHeaders headers, Parameters parameters, Collection<OperationRequestPart> parts, Collection<RequestCookie> cookies)
      Creates a new OperationRequest. The given headers will be augmented to ensure that they always include a Content-Length header if the request has any content and a Host header.
      Parameters:
      uri - the request's uri
      method - the request method
      content - the content of the request
      headers - the request's headers
      parameters - the request's parameters
      parts - the request's parts
      cookies - the request's cookies
      Returns:
      the OperationRequest
    • create

      public OperationRequest create(URI uri, org.springframework.http.HttpMethod method, byte[] content, org.springframework.http.HttpHeaders headers, Parameters parameters, Collection<OperationRequestPart> parts)
      Creates a new OperationRequest. The given headers will be augmented to ensure that they always include a Content-Length header if the request has any content and a Host header.
      Parameters:
      uri - the request's uri
      method - the request method
      content - the content of the request
      headers - the request's headers
      parameters - the request's parameters
      parts - the request's parts
      Returns:
      the OperationRequest
    • createFrom

      public OperationRequest createFrom(OperationRequest original, byte[] newContent)
      Creates a new OperationRequest based on the given original but with the given newContent. If the original request had a Content-Length header it will be modified to match the length of the new content.
      Parameters:
      original - the original request
      newContent - the new content
      Returns:
      the new request with the new content
    • createFrom

      public OperationRequest createFrom(OperationRequest original, org.springframework.http.HttpHeaders newHeaders)
      Creates a new OperationRequest based on the given original but with the given newHeaders.
      Parameters:
      original - the original request
      newHeaders - the new headers
      Returns:
      the new request with the new headers
    • createFrom

      public OperationRequest createFrom(OperationRequest original, Parameters newParameters)
      Creates a new OperationRequest based on the given original but with the given newParameters applied. The query string of a GET request will be updated to reflect the new parameters.
      Parameters:
      original - the original request
      newParameters - the new parameters
      Returns:
      the new request with the parameters applied