You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding state delete + migrate to new event system (#4)
* Adding state delete + migrate to new event system
- bump wiremock version to 3.0.0-beta-11
- use new event system + new interfaces for everything
- use ExtensionFactory for registering everything
- adding state deleting event listener
- use Store for caching + provide caffeine store
- ensure that context interactions are synchronized to avoid race
conditions
- updated documentation
The state is stored in `postServeActions` of a stub. The following parameters have to be provided:
79
+
The state is recorded in `withServeEventListener` of a stub. The following parameters have to be provided:
84
80
85
81
<table>
86
82
<tr>
@@ -134,7 +130,7 @@ Full example:
134
130
{
135
131
"request": {},
136
132
"response": {},
137
-
"postServeActions": [
133
+
"withServeEventListener": [
138
134
{
139
135
"name": "recordState",
140
136
"parameters": {
@@ -151,14 +147,63 @@ Full example:
151
147
152
148
```
153
149
150
+
## Deleting a state
151
+
152
+
Similar to recording a state, its deletion can be initiated in `withServeEventListener` of a stub. The following parameters have to be provided:
153
+
154
+
<table>
155
+
<tr>
156
+
<th>Parameter</th>
157
+
<th>Type</th>
158
+
<th>Example</th>
159
+
</tr>
160
+
<tr>
161
+
<td>
162
+
163
+
`context`
164
+
165
+
</td>
166
+
<td>String</td>
167
+
<td>
168
+
169
+
-`"context": "{{jsonPath response.body '$.id'}}"`
170
+
-`"context": "{{request.pathSegments.[3]}}"`
171
+
172
+
</td>
173
+
</tr>
174
+
</table>
175
+
176
+
Templating (as in [Response Templating](https://wiremock.org/docs/response-templating/)) is supported for these. The following models are exposed:
177
+
178
+
-`request`: All model elements of as in [Response Templating](https://wiremock.org/docs/response-templating/)
179
+
-`response`: `body` and `headers`
180
+
181
+
Full example:
182
+
183
+
```json
184
+
{
185
+
"request": {},
186
+
"response": {},
187
+
"withServeEventListener": [
188
+
{
189
+
"name": "deleteState",
190
+
"parameters": {
191
+
"context": "{{jsonPath response.body '$.id'}}"
192
+
}
193
+
}
194
+
]
195
+
}
196
+
197
+
```
198
+
154
199
### state expiration
155
200
156
-
This extension uses [caffeine](https://github.com/ben-manes/caffeine) to store the current state and to achieve an expiration (to avoid memory leaks).
201
+
This extension provides a `CaffeineStore` which uses [caffeine](https://github.com/ben-manes/caffeine) to store the current state and to achieve an expiration (to avoid memory leaks).
157
202
The default expiration is 60 minutes. The default value can be overwritten (`0` = default = 60 minutes):
0 commit comments