-
public class PactDslResponse
-
-
Field Summary
Fields Modifier and Type Field Description final static StringDEFAULT_JSON_CONTENT_TYPE_REGEX
-
Constructor Summary
Constructors Constructor Description PactDslResponse(ConsumerPactBuilder consumerPactBuilder, PactDslRequestWithPath request, PactDslRequestWithoutPath defaultRequestValues, PactDslResponse defaultResponseValues)
-
Method Summary
Modifier and Type Method Description PactDslResponsestatus(int status)Response status code PactDslResponseheaders(Map<String, String> headers)Response headers to return Provide the headers you want to validate, other headers will be ignored. PactDslResponsebody(String body)Response body to return PactDslResponsebody(String body, String contentType)Response body to return PactDslResponsebody(String body, ContentType contentType)Response body to return PactDslResponsebody(Supplier<String> body)The body of the request PactDslResponsebody(Supplier<String> body, String contentType)The body of the request PactDslResponsebody(Supplier<String> body, ContentType contentType)The body of the request PactDslResponsebodyWithSingleQuotes(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. PactDslResponsebodyWithSingleQuotes(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. PactDslResponsebodyWithSingleQuotes(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. PactDslResponsebody(JSONObject body)Response body to return PactDslResponsebody(DslPart body)Response body to return PactDslResponsebody(Document body)Response body to return PactDslResponsewithBinaryData(Array<byte> example, String contentType)Response body as a binary data. PactDslResponsematchHeader(String header, String regexp)Match a response header. PactDslResponsematchHeader(String header, String regexp, String headerExample)Match a response header. <P extends Pact> PtoPact(Class<P> pactClass)Terminates the DSL and builds a pact to represent the interactions RequestResponsePacttoPact()Terminates the DSL and builds a pact to represent the interactions PactDslRequestWithPathuponReceiving(String description)Description of the request that is expected to be received PactDslWithStategiven(String state)Adds a provider state to this interaction PactDslWithStategiven(String state, Map<String, Object> params)Adds a provider state to this interaction PactDslResponseheaderFromProviderState(String name, String expression, String example)Adds a header that will have it's value injected from the provider state PactDslResponsematchSetCookie(String cookie, String regex, String example)Match a set cookie header PactDslResponsebody(PactXmlBuilder xmlBuilder)XML Response body to return -
-
Constructor Detail
-
PactDslResponse
PactDslResponse(ConsumerPactBuilder consumerPactBuilder, PactDslRequestWithPath request, PactDslRequestWithoutPath defaultRequestValues, PactDslResponse defaultResponseValues)
-
-
Method Detail
-
status
PactDslResponse status(int status)
Response status code
- Parameters:
status- HTTP status code
-
headers
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
PactDslResponse body(String body)
Response body to return
- Parameters:
body- Response body in string form
-
body
PactDslResponse body(String body, String contentType)
Response body to return
- Parameters:
body- body in string formcontentType- the Content-Type response header value
-
body
PactDslResponse body(String body, ContentType contentType)
Response body to return
- Parameters:
body- body in string formcontentType- the Content-Type response header value
-
body
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
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 stringcontentType- the Content-Type response header value
-
body
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 stringcontentType- the Content-Type response header value
-
bodyWithSingleQuotes
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
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 formcontentType- the Content-Type response header value
-
bodyWithSingleQuotes
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 formcontentType- the Content-Type response header value
-
body
PactDslResponse body(JSONObject body)
Response body to return
- Parameters:
body- Response body in JSON form
-
body
PactDslResponse body(DslPart body)
Response body to return
- Parameters:
body- Response body built using the Pact body DSL
-
body
PactDslResponse body(Document body)
Response body to return
- Parameters:
body- Response body as an XML Document
-
withBinaryData
PactDslResponse withBinaryData(Array<byte> 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 testcontentType- Content type of the data
-
matchHeader
PactDslResponse matchHeader(String header, String regexp)
Match a response header. A random example header value will be generated from the provided regular expression.
- Parameters:
header- Header to matchregexp- Regular expression to match
-
matchHeader
PactDslResponse matchHeader(String header, String regexp, String headerExample)
Match a response header.
- Parameters:
header- Header to matchregexp- Regular expression to matchheaderExample- Example value to use
-
toPact
<P extends Pact> P toPact(Class<P> pactClass)
Terminates the DSL and builds a pact to represent the interactions
-
toPact
RequestResponsePact toPact()
Terminates the DSL and builds a pact to represent the interactions
-
uponReceiving
PactDslRequestWithPath uponReceiving(String description)
Description of the request that is expected to be received
- Parameters:
description- request description
-
given
PactDslWithState given(String state)
Adds a provider state to this interaction
- Parameters:
state- Description of the state
-
given
PactDslWithState given(String state, Map<String, Object> params)
Adds a provider state to this interaction
- Parameters:
state- Description of the stateparams- Data parameters for this state
-
headerFromProviderState
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 Nameexpression- Expression to be evaluated from the provider stateexample- Example value to use in the consumer test
-
matchSetCookie
PactDslResponse matchSetCookie(String cookie, String regex, String example)
Match a set cookie header
- Parameters:
cookie- Cookie name to matchregex- Regex to match the cookie value withexample- Example value
-
body
PactDslResponse body(PactXmlBuilder xmlBuilder)
XML Response body to return
- Parameters:
xmlBuilder- XML Builder used to construct the XML document
-
-
-
-