Builder DSL for Pact tests
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
HEADER |
| Fields inherited from class | Fields |
|---|---|
class BaseBuilder |
COMPACT_MIME_TYPES |
| Type | Name and description |
|---|---|
au.com.dius.pact.model.Consumer |
consumer |
java.util.List |
interactions |
java.lang.Integer |
port |
au.com.dius.pact.model.Provider |
provider |
java.util.List<au.com.dius.pact.model.ProviderState> |
providerStates |
java.util.List |
requestData |
java.lang.String |
requestDescription |
boolean |
requestState |
java.util.List |
responseData |
au.com.dius.pact.consumer.StatefulMockProvider |
server |
| Type Params | Return Type | Name and description |
|---|---|---|
|
java.lang.Object |
buildInteractions() |
|
au.com.dius.pact.model.PactFragment |
fragment() |
|
PactBuilder |
given(java.lang.String providerState)Defines the provider state the provider needs to be in for the interaction |
|
PactBuilder |
given(java.lang.String providerState, java.util.Map params)Defines the provider state the provider needs to be in for the interaction |
|
PactBuilder |
hasPactWith(java.lang.String provider)Defines the provider the consumer has a pact with |
|
PactBuilder |
port(int port)Defines the port the provider will listen on |
|
au.com.dius.pact.consumer.VerificationResult |
run(java.util.Map options = [:], groovy.lang.Closure closure)Executes the providers closure in the context of the interactions defined on this builder. |
|
au.com.dius.pact.consumer.PactVerificationResult |
runTest(java.util.Map options = [:], groovy.lang.Closure closure)Executes the providers closure in the context of the interactions defined on this builder. |
|
void |
runTestAndVerify(java.util.Map options = [:], groovy.lang.Closure closure)Runs the test (via the runTest method), and throws an exception if it was not successful. |
|
PactBuilder |
serviceConsumer(java.lang.String consumer)Defines the service consumer |
|
PactBuilder |
uponReceiving(java.lang.String requestDescription)Defines the start of an interaction |
|
PactBuilder |
willRespondWith(java.util.Map responseData)Defines the response attributes (body, headers, etc.) that are returned for the request |
|
PactBuilder |
withAttributes(java.util.Map requestData)Defines the request attributes (body, headers, etc.) |
|
PactBuilder |
withBody(java.lang.String mimeType, groovy.lang.Closure closure)Allows the body to be defined using a Groovy builder pattern |
|
PactBuilder |
withBody(java.lang.String mimeType, java.util.List array)Allows the body to be defined using a Groovy builder pattern with an array as the root |
|
PactBuilder |
withBody(java.lang.String mimeType, LikeMatcher matcher)Allows the body to be defined using a Groovy builder pattern with an array as the root using a each like matcher for all elements of the array |
|
PactBuilder |
withBody(java.util.Map options = [:], groovy.lang.Closure closure)Allows the body to be defined using a Groovy builder pattern |
|
PactBuilder |
withBody(java.util.Map options = [:], java.util.List array)Allows the body to be defined using a Groovy builder pattern with an array as the root |
|
PactBuilder |
withBody(java.util.Map options = [:], LikeMatcher matcher)Allows the body to be defined using a Groovy builder pattern with an array as the root |
|
void |
withFileUpload(java.lang.String partName, java.lang.String fileName, java.lang.String fileContentType, byte[] data)Sets up a file upload request. |
| Methods inherited from class | Name |
|---|---|
class BaseBuilder |
build, call |
class Matchers |
and, bool, date, decimal, eachArrayLike, eachLike, equalTo, guid, hexValue, identifier, includesStr, integer, ipAddress, maxLike, minLike, nullValue, numeric, or, real, regexp, regexp, string, time, timestamp, url, uuid |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Defines the provider state the provider needs to be in for the interaction
providerState - provider state descriptionDefines the provider state the provider needs to be in for the interaction
providerState - provider state descriptionparams - Data parameters for the provider stateDefines the provider the consumer has a pact with
provider - provider nameDefines the port the provider will listen on
port - port numberExecutes the providers closure in the context of the interactions defined on this builder.
options - Optional map of options for the runclosure - Test to executeExecutes the providers closure in the context of the interactions defined on this builder.
options - Optional map of options for the runclosure - Test to executeRuns the test (via the runTest method), and throws an exception if it was not successful.
options - Optional map of options for the runDefines the service consumer
consumer - consumer nameDefines the start of an interaction
requestDescription - Description of the interaction. Must be unique.Defines the response attributes (body, headers, etc.) that are returned for the request
responseData - Map of attributesDefines the request attributes (body, headers, etc.)
requestData - Map of attributesAllows the body to be defined using a Groovy builder pattern
mimeType - Optional mimetype for the bodyclosure - Body closureAllows the body to be defined using a Groovy builder pattern with an array as the root
mimeType - Optional mimetype for the bodyarray - bodyAllows the body to be defined using a Groovy builder pattern with an array as the root using a each like matcher for all elements of the array
mimeType - Optional mimetype for the bodymatcher - bodyAllows the body to be defined using a Groovy builder pattern
options - The following options are available:
- mimeType Optional mimetype for the body
- prettyPrint If the body should be pretty printedclosure - Body closureAllows the body to be defined using a Groovy builder pattern with an array as the root
options - The following options are available:
- mimeType Optional mimetype for the body
- prettyPrint If the body should be pretty printedarray - bodyAllows the body to be defined using a Groovy builder pattern with an array as the root
options - The following options are available:
- mimeType Optional mimetype for the body
- prettyPrint If the body should be pretty printedmatcher - bodySets up a file upload request. This will add the correct content type header to the request
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