Package 

Class PactDslResponse

    • Method Detail

      • headers

         final PactDslResponse headers(Map<String, String> headers)

        Response headers to return

        Provide the headers you want to validate, other headers will be ignored.

        Parameters:
        headers - key-value pairs of headers
      • body

         final PactDslResponse body(String body, String contentType)

        Response body to return

        Parameters:
        body - body in string form
        contentType - the Content-Type response header value
      • body

         final PactDslResponse body(String body, ContentType contentType)

        Response body to return

        Parameters:
        body - body in string form
        contentType - the Content-Type response header value
      • body

         final PactDslResponse body(Supplier<String> body)

        The body of the request

        Parameters:
        body - Response body in Java Functional Interface Supplier that must return a string
      • body

         final PactDslResponse body(Supplier<String> body, String contentType)

        The body of the request

        Parameters:
        body - Response body in Java Functional Interface Supplier that must return a string
        contentType - the Content-Type response header value
      • body

         final PactDslResponse body(Supplier<String> body, ContentType contentType)

        The body of the request

        Parameters:
        body - Response body in Java Functional Interface Supplier that must return a string
        contentType - the Content-Type response header value
      • body

         final PactDslResponse body(JSONObject body)

        Response body to return

        Parameters:
        body - Response body in JSON form
      • body

         final PactDslResponse body(DslPart body)

        Response body to return

        Parameters:
        body - Response body built using the Pact body DSL
      • bodyWithSingleQuotes

         final PactDslResponse bodyWithSingleQuotes(String body)

        The body of the request with possible single quotes as delimiters and using QuoteUtil to convert single quotes to double quotes if required.

        Parameters:
        body - Request body in string form
      • bodyWithSingleQuotes

         final PactDslResponse bodyWithSingleQuotes(String body, String contentType)

        The body of the request with possible single quotes as delimiters and using QuoteUtil to convert single quotes to double quotes if required.

        Parameters:
        body - Request body in string form
        contentType - the Content-Type response header value
      • bodyWithSingleQuotes

         final PactDslResponse bodyWithSingleQuotes(String body, ContentType contentType)

        The body of the request with possible single quotes as delimiters and using QuoteUtil to convert single quotes to double quotes if required.

        Parameters:
        body - Request body in string form
        contentType - the Content-Type response header value
      • withBinaryData

         final PactDslResponse withBinaryData(ByteArray example, String contentType)

        Response body as a binary data. It will match any expected bodies against the content type.

        Parameters:
        example - Example contents to use in the consumer test
        contentType - Content type of the data
      • matchHeader

        @JvmOverloads() final PactDslResponse matchHeader(String header, String regexp, String headerExample)

        Match a response header. A random example header value will be generated from the provided regular expression if the example value is not provided.

        Parameters:
        header - Header to match
        regexp - Regular expression to match
        headerExample - Example value to use
      • toPact

         final <P extends BasePact> P toPact(Class<P> pactClass)

        Terminates the DSL and builds a pact to represent the interactions

      • toPact

         final RequestResponsePact toPact()

        Terminates the DSL and builds a pact to represent the interactions

      • given

         final PactDslWithState given(String state)

        Adds a provider state to this interaction

        Parameters:
        state - Description of the state
      • headerFromProviderState

         final PactDslResponse headerFromProviderState(String name, String expression, String example)

        Adds a header that will have it's value injected from the provider state

        Parameters:
        name - Header Name
        expression - Expression to be evaluated from the provider state
        example - Example value to use in the consumer test
      • matchSetCookie

         final PactDslResponse matchSetCookie(String cookie, String regex, String example)

        Match a set cookie header

        Parameters:
        cookie - Cookie name to match
        regex - Regex to match the cookie value with
        example - Example value