public class PactDslResponse
public PactDslResponse(ConsumerPactBuilder consumerPactBuilder, PactDslRequestWithPath request, PactDslRequestWithoutPath defaultRequestValues, PactDslResponse defaultResponseValues)
public PactDslResponse status(int status)
Response status code
status
- HTTP status codepublic PactDslResponse headers(java.util.Map<java.lang.String,java.lang.String> headers)
Response headers to return Provide the headers you want to validate, other headers will be ignored.
headers
- key-value pairs of headerspublic PactDslResponse body(java.lang.String body)
Response body to return
body
- Response body in string formpublic PactDslResponse body(java.lang.String body, java.lang.String contentType)
Response body to return
body
- body in string formcontentType
- the Content-Type response header valuepublic PactDslResponse body(java.lang.String body, org.apache.http.entity.ContentType contentType)
Response body to return
body
- body in string formcontentType
- the Content-Type response header valuepublic PactDslResponse body(java.util.function.Supplier<java.lang.String> body)
The body of the request
body
- Response body in Java Functional Interface Supplier that must return a stringpublic PactDslResponse body(java.util.function.Supplier<java.lang.String> body, java.lang.String contentType)
The body of the request
body
- Response body in Java Functional Interface Supplier that must return a stringcontentType
- the Content-Type response header valuepublic PactDslResponse body(java.util.function.Supplier<java.lang.String> body, org.apache.http.entity.ContentType contentType)
The body of the request
body
- Response body in Java Functional Interface Supplier that must return a stringcontentType
- the Content-Type response header valuepublic PactDslResponse bodyWithSingleQuotes(java.lang.String body)
The body of the request with possible single quotes as delimiters and using
to convert single quotes to double quotes if required.class QuoteUtil
body
- Request body in string formclass QuoteUtil
public PactDslResponse bodyWithSingleQuotes(java.lang.String body, java.lang.String contentType)
The body of the request with possible single quotes as delimiters and using
to convert single quotes to double quotes if required.class QuoteUtil
body
- Request body in string formcontentType
- the Content-Type response header valueclass QuoteUtil
public PactDslResponse bodyWithSingleQuotes(java.lang.String body, org.apache.http.entity.ContentType contentType)
The body of the request with possible single quotes as delimiters and using
to convert single quotes to double quotes if required.class QuoteUtil
body
- Request body in string formcontentType
- the Content-Type response header valueclass QuoteUtil
public PactDslResponse body(org.json.JSONObject body)
Response body to return
body
- Response body in JSON formpublic PactDslResponse body(DslPart body)
Response body to return
body
- Response body built using the Pact body DSLpublic PactDslResponse body(org.w3c.dom.Document body)
Response body to return
body
- Response body as an XML Documentpublic PactDslResponse matchHeader(java.lang.String header, java.lang.String regexp)
Match a response header. A random example header value will be generated from the provided regular expression.
header
- Header to matchregexp
- Regular expression to matchpublic PactDslResponse matchHeader(java.lang.String header, java.lang.String regexp, java.lang.String headerExample)
Match a response header.
header
- Header to matchregexp
- Regular expression to matchheaderExample
- Example value to usepublic au.com.dius.pact.core.model.RequestResponsePact toPact()
Terminates the DSL and builds a pact to represent the interactions
public PactDslRequestWithPath uponReceiving(java.lang.String description)
Description of the request that is expected to be received
description
- request descriptionpublic PactDslWithState given(java.lang.String state)
Adds a provider state to this interaction
state
- Description of the statepublic PactDslWithState given(java.lang.String state, java.util.Map<java.lang.String,java.lang.Object> params)
Adds a provider state to this interaction
state
- Description of the stateparams
- Data parameters for this statepublic PactDslResponse headerFromProviderState(java.lang.String name, java.lang.String expression, java.lang.String example)
Adds a header that will have it's value injected from the provider state
name
- Header Nameexpression
- Expression to be evaluated from the provider stateexample
- Example value to use in the consumer testpublic PactDslResponse matchSetCookie(java.lang.String cookie, java.lang.String regex, java.lang.String example)
Match a set cookie header
cookie
- Cookie name to matchregex
- Regex to match the cookie value withexample
- Example valuepublic PactDslResponse body(PactXmlBuilder xmlBuilder)
XML Response body to return
xmlBuilder
- XML Builder used to construct the XML document