Skip to content

Commit

Permalink
port the state change request filter to the maven plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Feb 5, 2015
1 parent 3f59fdb commit 247f5ac
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 3 additions & 0 deletions pact-jvm-provider-maven/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ These values can be set at the provider level, or for a specific consumer. Consu
If the `stateChangeUsesBody` is not specified, or is set to true, then the provider state description will be sent as
JSON in the body of the request. If it is set to false, it will passed as a query parameter.

As for normal requests (see Modifying the requests before they are sent), a state change request can be modified before
it is sent. Set `stateChangeRequestFilter` to a Groovy script on the provider that will be called before the request is made.

## Filtering the interactions that are verified

You can filter the interactions that are run using three properties: `pact.filter.consumers`, `pact.filter.description` and `pact.filter.providerState`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,8 @@ class PactProviderMojo extends AbstractMojo {
stateChangeUrl = provider.stateChangeUrl
stateChangeUsesBody = provider.stateChangeUsesBody
}
def client = new RESTClient(stateChangeUrl.toString())
if (stateChangeUsesBody) {
client.post(body: [state: state], requestContentType: 'application/json')
} else {
client.post(query: [state: state])
}
ProviderClient client = new ProviderClient(provider: provider)
client.makeStateChangeRequest(stateChangeUrl.toString(), state, stateChangeUsesBody)
}
return true
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ class Provider {
File pactFileDirectory
URL stateChangeUrl
boolean stateChangeUsesBody = true
def stateChangeRequestFilter
}

0 comments on commit 247f5ac

Please sign in to comment.