public class PactDslResponse
extends java.lang.Object
| Constructor and Description |
|---|
PactDslResponse(ConsumerPactBuilder consumerPactBuilder,
PactDslRequestWithPath request,
PactDslRequestWithoutPath defaultRequestValues,
PactDslResponse defaultResponseValues) |
| Modifier and Type | Method and Description |
|---|---|
PactDslResponse |
body(org.w3c.dom.Document body)
Response body to return
|
PactDslResponse |
body(DslPart body)
Response body to return
|
PactDslResponse |
body(org.json.JSONObject body)
Response body to return
|
PactDslResponse |
body(au.com.dius.pact.consumer.xml.PactXmlBuilder xmlBuilder)
XML Response body to return
|
PactDslResponse |
body(java.lang.String body)
Response body to return
|
PactDslResponse |
body(java.lang.String body,
org.apache.http.entity.ContentType contentType)
Response body to return
|
PactDslResponse |
body(java.lang.String body,
java.lang.String contentType)
Response body to return
|
PactDslResponse |
body(java.util.function.Supplier<java.lang.String> body)
The body of the request
|
PactDslResponse |
body(java.util.function.Supplier<java.lang.String> body,
org.apache.http.entity.ContentType contentType)
The body of the request
|
PactDslResponse |
body(java.util.function.Supplier<java.lang.String> body,
java.lang.String contentType)
The body of the request
|
PactDslResponse |
bodyWithSingleQuotes(java.lang.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. |
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
QuoteUtil to convert single quotes to double quotes if required. |
PactDslResponse |
bodyWithSingleQuotes(java.lang.String body,
java.lang.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. |
protected java.lang.String |
getContentTypeHeader() |
PactDslWithState |
given(java.lang.String state)
Adds a provider state to this interaction
|
PactDslWithState |
given(java.lang.String state,
java.util.Map<java.lang.String,java.lang.Object> params)
Adds a provider state to this interaction
|
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
|
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.
|
protected boolean |
isContentTypeHeaderNotSet() |
PactDslResponse |
matchHeader(java.lang.String header,
java.lang.String regexp)
Match a response header.
|
PactDslResponse |
matchHeader(java.lang.String header,
java.lang.String regexp,
java.lang.String headerExample)
Match a response header.
|
PactDslResponse |
matchSetCookie(java.lang.String cookie,
java.lang.String regex,
java.lang.String example)
Match a set cookie header
|
PactDslResponse |
status(int status)
Response status code
|
au.com.dius.pact.core.model.RequestResponsePact |
toPact()
Terminates the DSL and builds a pact to represent the interactions
|
PactDslRequestWithPath |
uponReceiving(java.lang.String description)
Description of the request that is expected to be received
|
PactDslResponse |
withBinaryData(byte[] example,
java.lang.String contentType)
Response body as a binary data.
|
public PactDslResponse(ConsumerPactBuilder consumerPactBuilder, PactDslRequestWithPath request, PactDslRequestWithoutPath defaultRequestValues, PactDslResponse defaultResponseValues)
public PactDslResponse status(int status)
status - HTTP status codepublic PactDslResponse headers(java.util.Map<java.lang.String,java.lang.String> headers)
headers - key-value pairs of headerspublic PactDslResponse body(java.lang.String body)
body - Response body in string formpublic PactDslResponse body(java.lang.String body, java.lang.String contentType)
body - body in string formcontentType - the Content-Type response header valuepublic PactDslResponse body(java.lang.String body, org.apache.http.entity.ContentType contentType)
body - body in string formcontentType - the Content-Type response header valuepublic PactDslResponse body(java.util.function.Supplier<java.lang.String> body)
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)
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)
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)
QuoteUtil to convert single quotes to double quotes if required.body - Request body in string formpublic PactDslResponse bodyWithSingleQuotes(java.lang.String body, java.lang.String contentType)
QuoteUtil to convert single quotes to double quotes if required.body - Request body in string formcontentType - the Content-Type response header valuepublic PactDslResponse bodyWithSingleQuotes(java.lang.String body, org.apache.http.entity.ContentType contentType)
QuoteUtil to convert single quotes to double quotes if required.body - Request body in string formcontentType - the Content-Type response header valuepublic PactDslResponse body(org.json.JSONObject body)
body - Response body in JSON formpublic PactDslResponse body(DslPart body)
body - Response body built using the Pact body DSLpublic PactDslResponse body(org.w3c.dom.Document body) throws javax.xml.transform.TransformerException
body - Response body as an XML Documentjavax.xml.transform.TransformerExceptionpublic PactDslResponse withBinaryData(byte[] example, java.lang.String contentType)
example - Example contents to use in the consumer testcontentType - Content type of the datapublic PactDslResponse matchHeader(java.lang.String header, java.lang.String regexp)
header - Header to matchregexp - Regular expression to matchpublic PactDslResponse matchHeader(java.lang.String header, java.lang.String regexp, java.lang.String headerExample)
header - Header to matchregexp - Regular expression to matchheaderExample - Example value to usepublic au.com.dius.pact.core.model.RequestResponsePact toPact()
public PactDslRequestWithPath uponReceiving(java.lang.String description)
description - request descriptionpublic PactDslWithState given(java.lang.String state)
state - Description of the statepublic PactDslWithState given(java.lang.String state, java.util.Map<java.lang.String,java.lang.Object> params)
state - Description of the stateparams - Data parameters for this statepublic PactDslResponse headerFromProviderState(java.lang.String name, java.lang.String expression, java.lang.String example)
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)
cookie - Cookie name to matchregex - Regex to match the cookie value withexample - Example valuepublic PactDslResponse body(au.com.dius.pact.consumer.xml.PactXmlBuilder xmlBuilder)
xmlBuilder - XML Builder used to construct the XML documentprotected boolean isContentTypeHeaderNotSet()
protected java.lang.String getContentTypeHeader()