@java.lang.SuppressWarnings(value: PropertyName) class PactBuilder extends au.com.dius.pact.consumer.groovy.GroovyBuilder
Builder DSL for Pact tests
| Modifiers | Name | Description |
|---|---|---|
static java.lang.String |
TEXT |
| Fields inherited from class | Fields |
|---|---|
class au.com.dius.pact.consumer.groovy.GroovyBuilder |
Companion, CONTENT_TYPE, JSON, BODY, LOCALHOST, HEADER, Companion |
| Type | Name and description |
|---|---|
au.com.dius.pact.core.model.SynchronousRequestResponse |
currentInteraction |
java.util.List |
interactions |
au.com.dius.pact.core.model.BasePact |
pact |
java.lang.Integer |
port |
java.util.List<au.com.dius.pact.core.model.ProviderState> |
providerStates |
boolean |
requestState |
au.com.dius.pact.core.model.PactSpecVersion |
specVersion |
| Constructor and description |
|---|
PactBuilder(au.com.dius.pact.core.model.PactSpecVersion version) |
| Type Params | Return Type | Name and description |
|---|---|---|
|
java.lang.Object |
build(groovy.lang.Closure closure) |
|
java.lang.Object |
call(groovy.lang.Closure closure) |
|
PactBuilder |
comment(java.lang.String comment)Adds a comment to either the request of response |
|
java.lang.Object |
fromProviderState(java.lang.String expression, java.lang.Object exampleValue)Marks a item as to be injected from the provider state |
|
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.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 |
testname(java.lang.String testname)Sets the name of the test |
|
java.lang.Object |
updateInteractions() |
|
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.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, au.com.dius.pact.consumer.groovy.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 using a multipart FORM POST. |
| Methods inherited from class | Name |
|---|---|
class au.com.dius.pact.consumer.groovy.GroovyBuilder |
au.com.dius.pact.consumer.groovy.GroovyBuilder#call(groovy.lang.Closure), au.com.dius.pact.consumer.groovy.GroovyBuilder#build(groovy.lang.Closure), au.com.dius.pact.consumer.groovy.GroovyBuilder#compactMimeTypes(java.util.Map), au.com.dius.pact.consumer.groovy.GroovyBuilder#isCompactMimeType(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#access$getCOMPACT_MIME_TYPES$cp(), au.com.dius.pact.consumer.groovy.GroovyBuilder#datetime(), au.com.dius.pact.consumer.groovy.GroovyBuilder#datetime(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#datetime(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#getDATE_2000(), au.com.dius.pact.consumer.groovy.GroovyBuilder#timeExpression(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#timeExpression(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#dateExpression(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#dateExpression(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#eachLike(int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#eachLike(java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#maxLike(int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#maxLike(int, int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#minLike(int, int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#minLike(int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#minMaxLike(int, int, int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#minMaxLike(int, int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#includesStr(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#eachArrayLike(int, java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#eachArrayLike(java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#informationStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#successStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#redirectStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#clientErrorStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#serverErrorStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#nonErrorStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#errorStatus(), au.com.dius.pact.consumer.groovy.GroovyBuilder#statusCodes(java.util.List), au.com.dius.pact.consumer.groovy.GroovyBuilder#access$getDATE_2000$cp(), au.com.dius.pact.consumer.groovy.GroovyBuilder#regexp(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#regexp(java.util.regex.Pattern), au.com.dius.pact.consumer.groovy.GroovyBuilder#regexp(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#regexp(java.util.regex.Pattern, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#nullValue(), au.com.dius.pact.consumer.groovy.GroovyBuilder#equalTo(java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#numeric(), au.com.dius.pact.consumer.groovy.GroovyBuilder#numeric(java.lang.Number), au.com.dius.pact.consumer.groovy.GroovyBuilder#bool(), au.com.dius.pact.consumer.groovy.GroovyBuilder#bool(java.lang.Boolean), au.com.dius.pact.consumer.groovy.GroovyBuilder#decimal(), au.com.dius.pact.consumer.groovy.GroovyBuilder#decimal(java.lang.Number), au.com.dius.pact.consumer.groovy.GroovyBuilder#integer(java.lang.Long), au.com.dius.pact.consumer.groovy.GroovyBuilder#integer(), au.com.dius.pact.consumer.groovy.GroovyBuilder#or(java.lang.Object, [Ljava.lang.Object;), au.com.dius.pact.consumer.groovy.GroovyBuilder#and(java.lang.Object, [Ljava.lang.Object;), au.com.dius.pact.consumer.groovy.GroovyBuilder#date(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#date(), au.com.dius.pact.consumer.groovy.GroovyBuilder#date(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#hexValue(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#hexValue(), au.com.dius.pact.consumer.groovy.GroovyBuilder#time(java.lang.String, java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#time(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#time(), au.com.dius.pact.consumer.groovy.GroovyBuilder#string(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#string(), au.com.dius.pact.consumer.groovy.GroovyBuilder#identifier(), au.com.dius.pact.consumer.groovy.GroovyBuilder#identifier(java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#ipAddress(), au.com.dius.pact.consumer.groovy.GroovyBuilder#ipAddress(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#uuid(), au.com.dius.pact.consumer.groovy.GroovyBuilder#uuid(java.lang.String), au.com.dius.pact.consumer.groovy.GroovyBuilder#url(java.lang.String, [Ljava.lang.Object;), au.com.dius.pact.consumer.groovy.GroovyBuilder#wait(long), au.com.dius.pact.consumer.groovy.GroovyBuilder#wait(long, int), au.com.dius.pact.consumer.groovy.GroovyBuilder#wait(), au.com.dius.pact.consumer.groovy.GroovyBuilder#equals(java.lang.Object), au.com.dius.pact.consumer.groovy.GroovyBuilder#toString(), au.com.dius.pact.consumer.groovy.GroovyBuilder#hashCode(), au.com.dius.pact.consumer.groovy.GroovyBuilder#getClass(), au.com.dius.pact.consumer.groovy.GroovyBuilder#notify(), au.com.dius.pact.consumer.groovy.GroovyBuilder#notifyAll() |
Adds a comment to either the request of response
Marks a item as to be injected from the provider state
expression - Expression to lookup in the provider state contextexampleValue - Example value to use in the consumer testDefines 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 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 nameSets the name of the test
Defines 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 @return
responseData - Map of attributesDefines the request attributes (body, headers, etc.)
requestData - Map of attributesAllows 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 using a multipart FORM POST. 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 contentsGroovy Documentation