Class PactDslRequestWithPath
-
- All Implemented Interfaces:
public class PactDslRequestWithPath extends PactDslRequestBase
-
-
Field Summary
Fields Modifier and Type Field Description public Consumer
consumer
public Provider
provider
public List<ProviderState>
state
public String
description
private String
path
public String
requestMethod
public Map<String, List<String>>
requestHeaders
public Map<String, List<String>>
query
public OptionalBody
requestBody
public MatchingRules
requestMatchers
public Generators
requestGenerators
private MultipartEntityBuilder
multipartBuilder
private List<String>
comments
private PactSpecVersion
version
-
Method Summary
Modifier and Type Method Description final String
getPath()
final Unit
setPath(String path)
final PactDslRequestWithPath
method(String method)
The HTTP method for the request final PactDslRequestWithPath
headers(String firstHeaderName, String firstHeaderValue, String headerNameValuePairs)
Headers to be included in the request final PactDslRequestWithPath
headers(Map<String, String> headers)
Headers to be included in the request final PactDslRequestWithPath
query(String query)
The query string for the request final PactDslRequestWithPath
encodedQuery(String query)
The encoded query string for the request final PactDslRequestWithPath
body(String body)
The body of the request final PactDslRequestWithPath
body(String body, String contentType)
The body of the request final PactDslRequestWithPath
body(String body, ContentType contentType)
The body of the request final PactDslRequestWithPath
body(Supplier<String> body)
The body of the request final PactDslRequestWithPath
body(Supplier<String> body, String contentType)
The body of the request final PactDslRequestWithPath
body(Supplier<String> body, ContentType contentType)
The body of the request final PactDslRequestWithPath
body(JSONObject body)
The body of the request final PactDslRequestWithPath
body(DslPart body)
The body of the request final PactDslRequestWithPath
body(Document body)
The body of the request final PactDslRequestWithPath
body(PactXmlBuilder xmlBuilder)
XML body to return PactDslRequestWithPath
body(MultipartEntityBuilder body)
The body of the request final PactDslRequestWithPath
body(BodyBuilder builder)
Sets the body using the builder final PactDslRequestWithPath
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. final PactDslRequestWithPath
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. final PactDslRequestWithPath
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. PactDslRequestWithPath
bodyMatchingContentType(String contentType, String exampleContents)
Sets up a content type matcher to match any body of the given content type final PactDslRequestWithPath
withBinaryData(ByteArray example, String contentType)
Request body as a binary data. final PactDslRequestWithPath
path(String path)
The path of the request final PactDslRequestWithPath
matchPath(String pathRegex, String path)
The path of the request. final PactDslRequestWithPath
matchPath(String pathRegex)
The path of the request. final PactDslRequestWithPath
matchHeader(String header, String regex, String headerExample)
Match a request header. final PactDslRequestWithPath
matchHeader(String header, String regex)
Match a request header. final PactDslResponse
willRespondWith()
Define the response to return final PactDslResponse
willRespondWith(Function1<PactDslResponse, PactDslResponse> addResponseMatchers)
Variant of PactDslRequestWithPath.willRespondWith that introduces a Lambda DSL syntax to better visually separate request and response in a pact. final PactDslRequestWithPath
matchQuery(String parameter, String regex, String example)
Match a query parameter with a regex. final PactDslRequestWithPath
matchQuery(String parameter, String regex)
Match a query parameter with a regex. final PactDslRequestWithPath
matchQuery(String parameter, String regex, List<String> example)
Match a repeating query parameter with a regex. final PactDslRequestWithPath
withFileUpload(String partName, String fileName, String fileContentType, ByteArray data)
Sets up a file upload request. final PactDslRequestWithPath
headerFromProviderState(String name, String expression, String example)
Adds a header that will have it's value injected from the provider state final PactDslRequestWithPath
queryParameterFromProviderState(String name, String expression, String example)
Adds a query parameter that will have it's value injected from the provider state final PactDslRequestWithPath
pathFromProviderState(String expression, String example)
Sets the path to have it's value injected from the provider state final PactDslRequestWithPath
queryMatchingDate(String field, String pattern, String example)
Matches a date field using the provided date pattern final PactDslRequestWithPath
queryMatchingDate(String field, String pattern)
Matches a date field using the provided date pattern. final PactDslRequestWithPath
queryMatchingTime(String field, String pattern, String example)
Matches a time field using the provided time pattern final PactDslRequestWithPath
queryMatchingTime(String field, String pattern)
Matches a time field using the provided time pattern. final PactDslRequestWithPath
queryMatchingTime(String field)
Matches a time field using the ISO time pattern. final PactDslRequestWithPath
queryMatchingDatetime(String field, String pattern, String example)
Matches a datetime field using the provided pattern final PactDslRequestWithPath
queryMatchingDatetime(String field, String pattern)
Matches a datetime field using the provided pattern. final PactDslRequestWithPath
queryMatchingISODate(String field, String example)
Matches a date field using the ISO date pattern. final PactDslRequestWithPath
queryMatchingISODate(String field)
Matches a date field using the ISO date pattern. final PactDslRequestWithPath
queryMatchingISOTime(String field, String example)
Matches a time field using the ISO time pattern final PactDslRequestWithPath
queryMatchingISODatetime(String field, String example)
Matches a datetime field using the ISO pattern. final PactDslRequestWithPath
queryMatchingISODatetime(String field)
Matches a datetime field using the ISO pattern. final PactDslRequestWithPath
comment(String comment)
Adds a comment to this interaction final PactDslRequestWithPath
addMetadataValue(String key, String value)
Adds additional values to the metadata section of the Pact file final PactDslRequestWithPath
addMetadataValue(String key, JsonValue value)
Adds additional values to the metadata section of the Pact file -
Methods inherited from class au.com.dius.pact.consumer.dsl.PactDslRequestBase
getComments, getMultipartBuilder, getVersion, setComments, setMultipartBuilder, setVersion, setupMultipart
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
method
final PactDslRequestWithPath method(String method)
The HTTP method for the request
- Parameters:
method
- Valid HTTP method
-
headers
final PactDslRequestWithPath headers(String firstHeaderName, String firstHeaderValue, String headerNameValuePairs)
Headers to be included in the request
- Parameters:
firstHeaderName
- The name of the first headerfirstHeaderValue
- The value of the first headerheaderNameValuePairs
- Additional headers in name-value pairs.
-
headers
final PactDslRequestWithPath headers(Map<String, String> headers)
Headers to be included in the request
- Parameters:
headers
- Key-value pairs
-
query
final PactDslRequestWithPath query(String query)
The query string for the request
- Parameters:
query
- query string
-
encodedQuery
final PactDslRequestWithPath encodedQuery(String query)
The encoded query string for the request
- Parameters:
query
- query string
-
body
final PactDslRequestWithPath body(String body)
The body of the request
- Parameters:
body
- Request body in string form
-
body
final PactDslRequestWithPath body(String body, String contentType)
The body of the request
- Parameters:
body
- Request body in string form
-
body
final PactDslRequestWithPath body(String body, ContentType contentType)
The body of the request
- Parameters:
body
- Request body in string form
-
body
final PactDslRequestWithPath body(Supplier<String> body)
The body of the request
- Parameters:
body
- Request body in Java Functional Interface Supplier that must return a string
-
body
final PactDslRequestWithPath body(Supplier<String> body, String contentType)
The body of the request
- Parameters:
body
- Request body in Java Functional Interface Supplier that must return a string
-
body
final PactDslRequestWithPath body(Supplier<String> body, ContentType contentType)
The body of the request
- Parameters:
body
- Request body in Java Functional Interface Supplier that must return a string
-
body
final PactDslRequestWithPath body(JSONObject body)
The body of the request
- Parameters:
body
- Request body in JSON form
-
body
final PactDslRequestWithPath body(DslPart body)
The body of the request
- Parameters:
body
- Built using the Pact body DSL
-
body
final PactDslRequestWithPath body(Document body)
The body of the request
- Parameters:
body
- XML Document
-
body
final PactDslRequestWithPath body(PactXmlBuilder xmlBuilder)
XML body to return
- Parameters:
xmlBuilder
- XML Builder used to construct the XML document
-
body
PactDslRequestWithPath body(MultipartEntityBuilder body)
The body of the request
- Parameters:
body
- Built using MultipartEntityBuilder
-
body
final PactDslRequestWithPath body(BodyBuilder builder)
Sets the body using the builder
- Parameters:
builder
- Body Builder
-
bodyWithSingleQuotes
final PactDslRequestWithPath 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 PactDslRequestWithPath 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
-
bodyWithSingleQuotes
final PactDslRequestWithPath 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
-
bodyMatchingContentType
PactDslRequestWithPath bodyMatchingContentType(String contentType, String exampleContents)
Sets up a content type matcher to match any body of the given content type
-
withBinaryData
final PactDslRequestWithPath withBinaryData(ByteArray example, String contentType)
Request 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
-
path
final PactDslRequestWithPath path(String path)
The path of the request
- Parameters:
path
- string path
-
matchPath
@JvmOverloads() final PactDslRequestWithPath matchPath(String pathRegex, String path)
The path of the request. This will generate a random path to use when generating requests if the example value is not provided.
- Parameters:
pathRegex
- regular expression to use to match pathspath
- string path to use when generating requests
-
matchPath
@JvmOverloads() final PactDslRequestWithPath matchPath(String pathRegex)
The path of the request. This will generate a random path to use when generating requests if the example value is not provided.
- Parameters:
pathRegex
- regular expression to use to match paths
-
matchHeader
@JvmOverloads() final PactDslRequestWithPath matchHeader(String header, String regex, String headerExample)
Match a request 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 matchregex
- Regular expression to matchheaderExample
- Example value to use
-
matchHeader
@JvmOverloads() final PactDslRequestWithPath matchHeader(String header, String regex)
Match a request 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 matchregex
- Regular expression to match
-
willRespondWith
final PactDslResponse willRespondWith()
Define the response to return
-
willRespondWith
final PactDslResponse willRespondWith(Function1<PactDslResponse, PactDslResponse> addResponseMatchers)
Variant of PactDslRequestWithPath.willRespondWith that introduces a Lambda DSL syntax to better visually separate request and response in a pact.
-
matchQuery
@JvmOverloads() final PactDslRequestWithPath matchQuery(String parameter, String regex, String example)
Match a query parameter with a regex. A random query parameter value will be generated from the regex if the example value is not provided.
- Parameters:
parameter
- Query parameterregex
- Regular expression to match withexample
- Example value to use for the query parameter (unencoded)
-
matchQuery
@JvmOverloads() final PactDslRequestWithPath matchQuery(String parameter, String regex)
Match a query parameter with a regex. A random query parameter value will be generated from the regex if the example value is not provided.
- Parameters:
parameter
- Query parameterregex
- Regular expression to match with
-
matchQuery
final PactDslRequestWithPath matchQuery(String parameter, String regex, List<String> example)
Match a repeating query parameter with a regex.
- Parameters:
parameter
- Query parameterregex
- Regular expression to match with each elementexample
- Example value list to use for the query parameter (unencoded)
-
withFileUpload
final PactDslRequestWithPath withFileUpload(String partName, String fileName, String fileContentType, ByteArray data)
Sets up a file upload request. This will add the correct content type header to the request
- Parameters:
partName
- This is the name of the part in the multipart body.fileName
- This is the name of the file that was uploadedfileContentType
- This is the content type of the uploaded filedata
- This is the actual file contents
-
headerFromProviderState
final PactDslRequestWithPath 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
-
queryParameterFromProviderState
final PactDslRequestWithPath queryParameterFromProviderState(String name, String expression, String example)
Adds a query parameter that will have it's value injected from the provider state
- Parameters:
name
- Nameexpression
- Expression to be evaluated from the provider stateexample
- Example value to use in the consumer test
-
pathFromProviderState
final PactDslRequestWithPath pathFromProviderState(String expression, String example)
Sets the path to have it's value injected from the provider state
- Parameters:
expression
- Expression to be evaluated from the provider stateexample
- Example value to use in the consumer test
-
queryMatchingDate
final PactDslRequestWithPath queryMatchingDate(String field, String pattern, String example)
Matches a date field using the provided date pattern
- Parameters:
field
- field namepattern
- pattern to matchexample
- Example value
-
queryMatchingDate
final PactDslRequestWithPath queryMatchingDate(String field, String pattern)
Matches a date field using the provided date pattern. The current system date will be used for the example value.
- Parameters:
field
- field namepattern
- pattern to match
-
queryMatchingTime
final PactDslRequestWithPath queryMatchingTime(String field, String pattern, String example)
Matches a time field using the provided time pattern
- Parameters:
field
- field namepattern
- pattern to matchexample
- Example value
-
queryMatchingTime
final PactDslRequestWithPath queryMatchingTime(String field, String pattern)
Matches a time field using the provided time pattern. The current system time will be used for the example value.
- Parameters:
field
- field namepattern
- pattern to match
-
queryMatchingTime
final PactDslRequestWithPath queryMatchingTime(String field)
Matches a time field using the ISO time pattern. The current system time will be used for the example value.
- Parameters:
field
- field name
-
queryMatchingDatetime
final PactDslRequestWithPath queryMatchingDatetime(String field, String pattern, String example)
Matches a datetime field using the provided pattern
- Parameters:
field
- field namepattern
- pattern to matchexample
- Example value
-
queryMatchingDatetime
final PactDslRequestWithPath queryMatchingDatetime(String field, String pattern)
Matches a datetime field using the provided pattern. The current system date and time will be used for the example value.
- Parameters:
field
- field namepattern
- pattern to match
-
queryMatchingISODate
@JvmOverloads() final PactDslRequestWithPath queryMatchingISODate(String field, String example)
Matches a date field using the ISO date pattern. The current system date will be used for the example value.
- Parameters:
field
- field name
-
queryMatchingISODate
@JvmOverloads() final PactDslRequestWithPath queryMatchingISODate(String field)
Matches a date field using the ISO date pattern. The current system date will be used for the example value.
- Parameters:
field
- field name
-
queryMatchingISOTime
final PactDslRequestWithPath queryMatchingISOTime(String field, String example)
Matches a time field using the ISO time pattern
- Parameters:
field
- field nameexample
- Example value
-
queryMatchingISODatetime
@JvmOverloads() final PactDslRequestWithPath queryMatchingISODatetime(String field, String example)
Matches a datetime field using the ISO pattern. The current system date and time will be used for the example value if not provided.
- Parameters:
field
- field nameexample
- Example value
-
queryMatchingISODatetime
@JvmOverloads() final PactDslRequestWithPath queryMatchingISODatetime(String field)
Matches a datetime field using the ISO pattern. The current system date and time will be used for the example value if not provided.
- Parameters:
field
- field name
-
comment
final PactDslRequestWithPath comment(String comment)
Adds a comment to this interaction
-
addMetadataValue
final PactDslRequestWithPath addMetadataValue(String key, String value)
Adds additional values to the metadata section of the Pact file
-
addMetadataValue
final PactDslRequestWithPath addMetadataValue(String key, JsonValue value)
Adds additional values to the metadata section of the Pact file
-
-
-
-