PostServeActions and ServeEventListeners
Webhooks
Java DSL
These inspections perform various static code analysis on Webhooks.webhook()
call chains and the related outer .withServeEventListener()
calls. Currently, they check the following:
Missing withUrl()
call
If there is no URL specified, there is no target to send the webhook request to.
Usage of the ANY
request method
ANY is designed for request matching, so using it may not be valid.
Listener name not specified as webhook
when using a webhook definition
When a webhook definition is specified in .withServeEventListener()
, the listener name must be webhook
.
Duplicate configuration
This inspection reports duplicate withBody()
and withBinaryBody()
calls in WebhookDefinition
call chains. When a body is specified in multiple calls/ways, the body’s value would be overridden.
A quick fix is also available to remove duplicate calls for the selected body. It keeps the call that the user invokes the quick fix on.
JSON DSL
These inspections perform various static code analysis on serveEventListener.parameters
properties. Currently, they check the following:
Missing url
property
If there is no URL specified, there is no target to send the webhook request to.
Usage of the ANY
request method
ANY is designed for request matching, so using it may not be valid.
headers
property value is not an object
The value of the headers
property must be an object, essentially of a map of header name-value pairs.
Duplicate configuration
This inspection reports duplicate body configuration in the serveEventListener.parameters
property. Validated properties are body
and base64Body
.
Regardless of if multiple of the same property, or different properties are specified, they are all reported and highlighted if duplicates are found.
Also, the related quick fix removes duplicate properties, keeping the property that the user invokes the quick fix on:
Code completion of serveEventListeners
To aid the work with serve event listeners, this code completion performs the following:
- shows the listeners available in the project (including where the listeners come from)
- completes the listener name in the
serveEventListener.name
property - generates the
parameters
property with all mandatory parameters. Note: it doesn’t override any existing parameters.
Currently, the following ones are supported:
- the built-in
webhook
listener, recordState
anddeleteState
from the wiremock-state-extension.- These items are shown only when the extension is available in the project.
WireMock State Extension
The documentation of this extension is available under the wiremock/wiremock-state-extension GitHub repository.
recordState listener
The following items are various validations that are performed on the listener’s configuration in JSON stub mapping files.
Criteria | Screenshot |
---|---|
The recordState listener requires the context property to be specified. | |
The value of the context property must be non-blank. | |
Either state or list or both are required to specify. | |
This listener has a fixed set of property names that it supports: – inside parameters : context , state and list | |
This listener has a fixed set of property names that it supports: – inside parameters.list : addFirst and addLast |
deleteState listener
The following items are various validations that are performed on the listener’s configuration in JSON stub mapping files.
Criteria | Screenshot |
---|---|
In case of context deletion, either context , contexts or contextsMatching must be specified. | |
In case of list entry deletion, context must be specified. | |
The value of the context property must be non-blank. | |
When performing list entry deletion one deletion type must be specified. | |
When performing list entry deletion only one deletion type must be specified. | |
When performing deleteWhere basedlist entry deletion both its property and value sub-properties must be specified. |