@gatling.io/core 3.11.7 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/jest.config.js +5 -0
  2. package/package.json +3 -3
  3. package/src/assertions.ts +305 -0
  4. package/src/body.ts +211 -0
  5. package/src/checks/builder.ts +14 -0
  6. package/src/checks/captureGroup.ts +22 -0
  7. package/src/checks/condition.ts +24 -0
  8. package/src/checks/final.ts +31 -0
  9. package/src/checks/find.ts +23 -0
  10. package/src/checks/index.ts +540 -0
  11. package/src/checks/jsonOfTypeFind.ts +81 -0
  12. package/src/checks/jsonOfTypeMultipleFind.ts +84 -0
  13. package/src/checks/multipleFind.ts +87 -0
  14. package/src/checks/validate.ts +336 -0
  15. package/src/closedInjection.ts +182 -0
  16. package/src/common.ts +3 -0
  17. package/src/feeders.ts +279 -0
  18. package/src/filters.ts +49 -0
  19. package/src/gatlingJvm/app.ts +5 -0
  20. package/src/gatlingJvm/byteArrays.ts +14 -0
  21. package/src/gatlingJvm/collections.ts +28 -0
  22. package/src/globalStore.ts +104 -0
  23. package/src/index.test.ts +543 -0
  24. package/src/index.ts +158 -0
  25. package/src/openInjection.ts +286 -0
  26. package/src/parameters.ts +38 -0
  27. package/src/population.ts +105 -0
  28. package/src/protocol.ts +5 -0
  29. package/src/scenario.ts +37 -0
  30. package/src/session.ts +182 -0
  31. package/src/structure/asLongAs.ts +121 -0
  32. package/src/structure/asLongAsDuring.ts +337 -0
  33. package/src/structure/choices.ts +41 -0
  34. package/src/structure/doIf.ts +140 -0
  35. package/src/structure/doIfOrElse.ts +160 -0
  36. package/src/structure/doSwitch.ts +46 -0
  37. package/src/structure/doSwitchOrElse.ts +61 -0
  38. package/src/structure/doWhile.ts +53 -0
  39. package/src/structure/doWhileDuring.ts +337 -0
  40. package/src/structure/during.ts +182 -0
  41. package/src/structure/errors.ts +266 -0
  42. package/src/structure/execs.ts +66 -0
  43. package/src/structure/feeds.ts +62 -0
  44. package/src/structure/forEach.ts +68 -0
  45. package/src/structure/forever.ts +25 -0
  46. package/src/structure/groups.ts +23 -0
  47. package/src/structure/index.ts +130 -0
  48. package/src/structure/jvmStructureBuilder.ts +52 -0
  49. package/src/structure/on.ts +20 -0
  50. package/src/structure/paces.ts +156 -0
  51. package/src/structure/pauses.ts +211 -0
  52. package/src/structure/randomSwitch.ts +34 -0
  53. package/src/structure/randomSwitchOrElse.ts +45 -0
  54. package/src/structure/rendezVous.ts +23 -0
  55. package/src/structure/repeat.ts +64 -0
  56. package/src/structure/roundRobinSwitch.ts +34 -0
  57. package/src/structure/uniformRandomSwitch.ts +34 -0
  58. package/src/throttling.ts +67 -0
  59. package/src/utils/duration.ts +28 -0
  60. package/target/structure/errors.d.ts +70 -10
  61. package/target/structure/errors.js +29 -8
  62. package/target/structure/index.d.ts +4 -2
  63. package/target/structure/index.js +5 -3
  64. package/tsconfig.json +18 -0
@@ -0,0 +1,540 @@
1
+ import { CoreDsl as JvmCoreDsl } from "@gatling.io/jvm-types";
2
+
3
+ import { Expression, Session, SessionTo, underlyingSessionTo } from "../session";
4
+ import { CheckBuilderCaptureGroup, wrapCheckBuilderCaptureGroup } from "./captureGroup";
5
+ import { asByteArray, asByteArrayFunction } from "../gatlingJvm/byteArrays";
6
+ import { wrapCheckBuilderFinal } from "./final";
7
+ import { CheckBuilderFind, wrapCheckBuilderFind } from "./find";
8
+ import { CheckBuilderJsonOfTypeFind, wrapCheckBuilderJsonOfTypeFind } from "./jsonOfTypeFind";
9
+ import { CheckBuilderJsonOfTypeMultipleFind, wrapCheckBuilderJsonOfTypeMultipleFind } from "./jsonOfTypeMultipleFind";
10
+ import { CheckBuilderMultipleFind, wrapCheckBuilderMultipleFind } from "./multipleFind";
11
+
12
+ import JvmCheckBuilderFind = io.gatling.javaapi.core.CheckBuilder$Find;
13
+ import JvmCheckBuilderMultipleFind = io.gatling.javaapi.core.CheckBuilder$MultipleFind;
14
+
15
+ export * from "./builder";
16
+ export * from "./captureGroup";
17
+ export * from "./condition";
18
+ export * from "./final";
19
+ export * from "./find";
20
+ export * from "./jsonOfTypeFind";
21
+ export * from "./jsonOfTypeMultipleFind";
22
+ export * from "./multipleFind";
23
+ export * from "./validate";
24
+
25
+ /**
26
+ * Bootstrap a new bodyString check that extracts the full response message body as a String.
27
+ * Encoding is either the one provided in the message (eg Content-Type charset attribute in HTTP),
28
+ * or the one defined in gatling.conf.
29
+ *
30
+ * Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
31
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
32
+ * error.
33
+ *
34
+ * @returns the next DSL step
35
+ */
36
+ export const bodyString = (): CheckBuilderFind<string> => wrapCheckBuilderFind(JvmCoreDsl.bodyString());
37
+
38
+ /**
39
+ * Bootstrap a new bodyBytes check that extracts the full response message body as a byte array.
40
+ *
41
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
42
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
43
+ * error.
44
+ *
45
+ * @returns the next DSL step
46
+ */
47
+ export const bodyBytes = (): CheckBuilderFind<number[]> => ({
48
+ ...wrapCheckBuilderFind(JvmCoreDsl.bodyBytes()),
49
+ is: (expected: number[] | SessionTo<number[]>) =>
50
+ wrapCheckBuilderFinal(
51
+ typeof expected === "function"
52
+ ? JvmCoreDsl.bodyBytes().is(asByteArrayFunction(underlyingSessionTo(expected)))
53
+ : JvmCoreDsl.bodyBytes().is(asByteArray(expected))
54
+ ),
55
+ not: (expected: number[] | SessionTo<number[]>) =>
56
+ wrapCheckBuilderFinal(
57
+ typeof expected === "function"
58
+ ? JvmCoreDsl.bodyBytes().not(asByteArrayFunction(underlyingSessionTo(expected)))
59
+ : JvmCoreDsl.bodyBytes().not(asByteArray(expected))
60
+ )
61
+ });
62
+
63
+ /**
64
+ * Bootstrap a new bodyLength check that extracts the full response message body's binary length.
65
+ *
66
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
67
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
68
+ * error.
69
+ *
70
+ * @returns the next DSL step
71
+ */
72
+ export const bodyLength = (): CheckBuilderFind<number> =>
73
+ wrapCheckBuilderFind(JvmCoreDsl.bodyLength() as JvmCheckBuilderFind<number>);
74
+
75
+ // TODO see if we do something for bodyStream - likely too complex for v1
76
+ // /**
77
+ // * Bootstrap a new bodyStream check that extracts the full response message body as an {@link
78
+ // * InputStream}.
79
+ // *
80
+ // * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
81
+ // * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
82
+ // * error
83
+ // *
84
+ // * @returns the next DSL step
85
+ // */
86
+ // @NonNull
87
+ // public static CheckBuilder.Find<InputStream> bodyStream() {
88
+ // return new CheckBuilder.Find.Default<>(
89
+ // io.gatling.core.Predef.bodyStream(), CoreCheckType.BodyStream, InputStream.class, null);
90
+ // }
91
+
92
+ export interface SubstringFunction {
93
+ /**
94
+ * Bootstrap a new substring check that extracts the indexes of the occurrences of a pattern in
95
+ * the response's body String. Encoding is either the one provided in the message (eg Content-Type
96
+ * charset attribute in HTTP), or the one defined in gatling.conf.
97
+ *
98
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
99
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
100
+ * error
101
+ *
102
+ * @param pattern - the searched pattern, expressed as a Gatling Expression Language String
103
+ * @returns the next DSL step
104
+ */
105
+ (pattern: string): CheckBuilderMultipleFind<number>;
106
+
107
+ /**
108
+ * Bootstrap a new substring check that extracts the indexes of the occurrences of a pattern in
109
+ * the response's body String. Encoding is either the one provided in the message (eg Content-Type
110
+ * charset attribute in HTTP), or the one defined in gatling.conf.
111
+ *
112
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
113
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
114
+ * error
115
+ *
116
+ * @param pattern - the searched pattern, expressed as a function
117
+ * @returns the next DSL step
118
+ */
119
+ (pattern: SessionTo<string>): CheckBuilderMultipleFind<number>;
120
+ }
121
+
122
+ export const substring: SubstringFunction = (pattern: string | SessionTo<string>): CheckBuilderMultipleFind<number> =>
123
+ wrapCheckBuilderMultipleFind(
124
+ (typeof pattern === "function"
125
+ ? JvmCoreDsl.substring(underlyingSessionTo(pattern))
126
+ : JvmCoreDsl.substring(pattern)) as JvmCheckBuilderMultipleFind<number>
127
+ );
128
+
129
+ export interface XpathFunction {
130
+ /**
131
+ * Bootstrap a new xpath check that extracts nodes with a <a
132
+ * href="https://en.wikipedia.org/wiki/XPath">XPath</a> from response's body <a
133
+ * href="https://en.wikipedia.org/wiki/XML">XML</a> document. Encoding is either the one provided
134
+ * in the message (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
135
+ *
136
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
137
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
138
+ * error
139
+ *
140
+ * @param path - the searched path, expressed as a Gatling Expression Language String
141
+ * @returns the next DSL step
142
+ */
143
+ (path: string): CheckBuilderMultipleFind<string>;
144
+
145
+ /**
146
+ * Bootstrap a new xpath check that extracts nodes with a <a
147
+ * href="https://en.wikipedia.org/wiki/XPath">XPath</a> from response's body <a
148
+ * href="https://en.wikipedia.org/wiki/XML">XML</a> document. Encoding is either the one provided
149
+ * in the message (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
150
+ *
151
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
152
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
153
+ * error
154
+ *
155
+ * @param path - the searched path, expressed as a function
156
+ * @returns the next DSL step
157
+ */
158
+ (path: SessionTo<string>): CheckBuilderMultipleFind<string>;
159
+
160
+ /**
161
+ * Bootstrap a new xpath check that extracts nodes with a <a
162
+ * href="https://en.wikipedia.org/wiki/XPath">XPath</a> from response's body <a
163
+ * href="https://en.wikipedia.org/wiki/XML">XML</a> document. Encoding is either the one provided
164
+ * in the message (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
165
+ *
166
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
167
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
168
+ * error
169
+ *
170
+ * @param path - the searched path, expressed as a Gatling Expression Language String
171
+ * @param namespaces - the XML <a href="https://en.wikipedia.org/wiki/XML_namespace">namespaces</a>
172
+ * used in the document
173
+ * @returns the next DSL step
174
+ */
175
+ (path: string, namespaces: Record<string, string>): CheckBuilderMultipleFind<string>;
176
+
177
+ /**
178
+ * Bootstrap a new xpath check that extracts nodes with a <a
179
+ * href="https://en.wikipedia.org/wiki/XPath">XPath</a> from response's body <a
180
+ * href="https://en.wikipedia.org/wiki/XML">XML</a> document. Encoding is either the one provided
181
+ * in the message (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
182
+ *
183
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
184
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
185
+ * error
186
+ *
187
+ * @param path - the searched path, expressed as a function
188
+ * @param namespaces - the XML <a href="https://en.wikipedia.org/wiki/XML_namespace">namespaces</a>
189
+ * used in the document
190
+ * @returns the next DSL step
191
+ */
192
+ (path: SessionTo<string>, namespaces: Record<string, string>): CheckBuilderMultipleFind<string>;
193
+ }
194
+
195
+ export const xpath: XpathFunction = (path: string | SessionTo<string>, namespaces?: Record<string, string>) => {
196
+ if (typeof path === "function") {
197
+ if (namespaces !== undefined) {
198
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.xpath(underlyingSessionTo(path), namespaces)); // TODO change type of java.util.Map in java2typescript
199
+ } else {
200
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.xpath(underlyingSessionTo(path)));
201
+ }
202
+ } else {
203
+ if (namespaces !== undefined) {
204
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.xpath(path, namespaces)); // TODO change type of java.util.Map in java2typescript
205
+ } else {
206
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.xpath(path));
207
+ }
208
+ }
209
+ };
210
+
211
+ export interface CssFunction {
212
+ /**
213
+ * Bootstrap a new css check that extracts nodes with a <a
214
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
215
+ * response's body HTML document. Encoding is either the one provided in the message (eg
216
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
217
+ *
218
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
219
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
220
+ * error
221
+ *
222
+ * @param selector - the searched selector, expressed as a Gatling Expression Language String
223
+ * @returns the next DSL step
224
+ */
225
+ (selector: string): CheckBuilderMultipleFind<string>;
226
+
227
+ /**
228
+ * Bootstrap a new css check that extracts nodes with a <a
229
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
230
+ * response's body HTML document. Encoding is either the one provided in the message (eg
231
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
232
+ *
233
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
234
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
235
+ * error
236
+ *
237
+ * @param selector - the searched selector, expressed as a function
238
+ * @returns the next DSL step
239
+ */
240
+ (selector: SessionTo<string>): CheckBuilderMultipleFind<string>;
241
+
242
+ /**
243
+ * Bootstrap a new css check that extracts nodes with a <a
244
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
245
+ * response's body HTML document. Encoding is either the one provided in the message (eg
246
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
247
+ *
248
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
249
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
250
+ * error
251
+ *
252
+ * @param selector - the searched selector, expressed as a Gatling Expression Language String
253
+ * @param nodeAttribute - the attribute of the selected nodes to capture, if not the node itself
254
+ * @returns the next DSL step
255
+ */
256
+ (selector: string, nodeAttribute: string): CheckBuilderMultipleFind<string>;
257
+
258
+ /**
259
+ * Bootstrap a new css check that extracts nodes with a <a
260
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
261
+ * response's body HTML document. Encoding is either the one provided in the message (eg
262
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
263
+ *
264
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
265
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
266
+ * error
267
+ *
268
+ * @param selector - the searched selector, expressed as a function
269
+ * @param nodeAttribute - the attribute of the selected nodes to capture, if not the node itself
270
+ * @returns the next DSL step
271
+ */
272
+ (selector: SessionTo<string>, nodeAttribute: string): CheckBuilderMultipleFind<string>;
273
+ }
274
+
275
+ export const css: CssFunction = (selector: string | SessionTo<string>, nodeAttribute?: string) => {
276
+ if (typeof selector === "function") {
277
+ if (nodeAttribute !== undefined) {
278
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.css(underlyingSessionTo(selector), nodeAttribute));
279
+ } else {
280
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.css(underlyingSessionTo(selector)));
281
+ }
282
+ } else {
283
+ if (nodeAttribute !== undefined) {
284
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.css(selector, nodeAttribute));
285
+ } else {
286
+ return wrapCheckBuilderMultipleFind(JvmCoreDsl.css(selector));
287
+ }
288
+ }
289
+ };
290
+
291
+ export interface FormFunction {
292
+ /**
293
+ * Bootstrap a new form check that extracts an HTML form's input nodes with a <a
294
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
295
+ * response's body HTML document. Encoding is either the one provided in the message (eg
296
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
297
+ *
298
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
299
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
300
+ * error
301
+ *
302
+ * @param selector - the searched selector, expressed as a Gatling Expression Language String
303
+ * @returns the next DSL step
304
+ */
305
+ (selector: string): CheckBuilderMultipleFind<Record<string, unknown>>;
306
+
307
+ /**
308
+ * Bootstrap a new form check that extracts an HTML form's input nodes with a <a
309
+ * href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors">CSS Selector</a> from
310
+ * response's body HTML document. Encoding is either the one provided in the message (eg
311
+ * Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
312
+ *
313
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
314
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
315
+ * error
316
+ *
317
+ * @param selector - the searched selector, expressed as a function
318
+ * @returns the next DSL step
319
+ */
320
+ (selector: SessionTo<string>): CheckBuilderMultipleFind<Record<string, unknown>>;
321
+ }
322
+
323
+ // TODO check what type the values in the Map actually have, and if they are usable in Javascript
324
+ export const form: FormFunction = (selector: string | SessionTo<string>) =>
325
+ wrapCheckBuilderMultipleFind(
326
+ (typeof selector === "function"
327
+ ? JvmCoreDsl.form(underlyingSessionTo(selector))
328
+ : JvmCoreDsl.form(selector)) as JvmCheckBuilderMultipleFind<any> // TODO change type of java.util.Map in java2typescript
329
+ );
330
+
331
+ export interface JsonPathFunction {
332
+ /**
333
+ * Bootstrap a new jsonPath check that extracts nodes with a <a
334
+ * href="https://goessner.net/articles/JsonPath/">JsonPath</a> path from response's body JSON
335
+ * tree.
336
+ *
337
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
338
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
339
+ * {@link IllegalArgumentException}
340
+ *
341
+ * @param path - the searched path, expressed as a Gatling Expression Language String
342
+ * @returns the next DSL step
343
+ */
344
+ (path: string): CheckBuilderJsonOfTypeMultipleFind;
345
+
346
+ /**
347
+ * Bootstrap a new jsonPath check that extracts nodes with a <a
348
+ * href="https://goessner.net/articles/JsonPath/">JsonPath</a> path from response's body JSON
349
+ * tree.
350
+ *
351
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
352
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
353
+ * {@link IllegalArgumentException}
354
+ *
355
+ * @param path - the searched path, expressed as a function
356
+ * @returns the next DSL step
357
+ */
358
+ (path: (session: Session) => string): CheckBuilderJsonOfTypeMultipleFind;
359
+ }
360
+
361
+ export const jsonPath: JsonPathFunction = (path: Expression<string>): CheckBuilderJsonOfTypeMultipleFind =>
362
+ wrapCheckBuilderJsonOfTypeMultipleFind(
363
+ typeof path === "function" ? JvmCoreDsl.jsonPath(underlyingSessionTo(path)) : JvmCoreDsl.jsonPath(path)
364
+ );
365
+
366
+ export interface JmesPathFunction {
367
+ /**
368
+ * Bootstrap a new jmesPath check that extracts nodes with a <a
369
+ * href="https://jmespath.org/">JMESPath</a> path from response's body JSON tree.
370
+ *
371
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
372
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
373
+ * {@link IllegalArgumentException}
374
+ *
375
+ * @param path - the searched path, expressed as a Gatling Expression Language String
376
+ * @returns the next DSL step
377
+ */
378
+ (path: string): CheckBuilderJsonOfTypeFind;
379
+
380
+ /**
381
+ * Bootstrap a new jmesPath check that extracts nodes with a <a
382
+ * href="https://jmespath.org/">JMESPath</a> path from response's body JSON tree.
383
+ *
384
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
385
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
386
+ * {@link IllegalArgumentException}
387
+ *
388
+ * @param path - the searched path, expressed as a function
389
+ * @returns the next DSL step
390
+ */
391
+ (path: (session: Session) => string): CheckBuilderJsonOfTypeFind;
392
+ }
393
+
394
+ export const jmesPath: JmesPathFunction = (path: Expression<string>): CheckBuilderJsonOfTypeFind =>
395
+ wrapCheckBuilderJsonOfTypeFind(
396
+ typeof path === "function" ? JvmCoreDsl.jmesPath(underlyingSessionTo(path)) : JvmCoreDsl.jmesPath(path)
397
+ );
398
+
399
+ export interface JsonpJsonPathFunction {
400
+ /**
401
+ * Bootstrap a new jsonpJsonPath check that extracts nodes with a <a
402
+ * href="https://goessner.net/articles/JsonPath/">JsonPath</a> path from response's body <a
403
+ * href="https://en.wikipedia.org/wiki/JSONP">JSONP</a> payload.
404
+ *
405
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
406
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
407
+ * {@link IllegalArgumentException}
408
+ *
409
+ * @param path - the searched path, expressed as a Gatling Expression Language String
410
+ * @returns the next DSL step
411
+ */
412
+ (path: string): CheckBuilderJsonOfTypeMultipleFind;
413
+
414
+ /**
415
+ * Bootstrap a new jsonpJsonPath check that extracts nodes with a <a
416
+ * href="https://goessner.net/articles/JsonPath/">JsonPath</a> path from response's body <a
417
+ * href="https://en.wikipedia.org/wiki/JSONP">JSONP</a> payload.
418
+ *
419
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
420
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
421
+ * {@link IllegalArgumentException}
422
+ *
423
+ * @param path - the searched path, expressed as a function
424
+ * @returns the next DSL step
425
+ */
426
+ (path: (session: Session) => string): CheckBuilderJsonOfTypeMultipleFind;
427
+ }
428
+
429
+ export const jsonpJsonPath: JsonpJsonPathFunction = (path: Expression<string>): CheckBuilderJsonOfTypeMultipleFind =>
430
+ wrapCheckBuilderJsonOfTypeMultipleFind(
431
+ typeof path === "function" ? JvmCoreDsl.jsonpJsonPath(underlyingSessionTo(path)) : JvmCoreDsl.jsonpJsonPath(path)
432
+ );
433
+
434
+ export interface JsonpJmesPathFunction {
435
+ /**
436
+ * Bootstrap a new jsonpJmesPath check that extracts nodes with a <a
437
+ * href="https://jmespath.org/">JMESPath</a> path from response's body JSON <a
438
+ * href="https://en.wikipedia.org/wiki/JSONP">JSONP</a> payload.
439
+ *
440
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
441
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
442
+ * {@link IllegalArgumentException}
443
+ *
444
+ * @param path - the searched path, expressed as a Gatling Expression Language String
445
+ * @returns the next DSL step
446
+ */
447
+ (path: string): CheckBuilderJsonOfTypeFind;
448
+
449
+ /**
450
+ * Bootstrap a new jsonpJmesPath check that extracts nodes with a <a
451
+ * href="https://jmespath.org/">JMESPath</a> path from response's body JSON <a
452
+ * href="https://en.wikipedia.org/wiki/JSONP">JSONP</a> payload.
453
+ *
454
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
455
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
456
+ * {@link IllegalArgumentException}
457
+ *
458
+ * @param path - the searched path, expressed as a function
459
+ * @returns the next DSL step
460
+ */
461
+ (path: (session: Session) => string): CheckBuilderJsonOfTypeFind;
462
+ }
463
+
464
+ export const jsonpJmesPath: JsonpJmesPathFunction = (path: Expression<string>): CheckBuilderJsonOfTypeFind =>
465
+ wrapCheckBuilderJsonOfTypeFind(
466
+ typeof path === "function" ? JvmCoreDsl.jsonpJmesPath(underlyingSessionTo(path)) : JvmCoreDsl.jsonpJmesPath(path)
467
+ );
468
+
469
+ export interface RegexFunction {
470
+ /**
471
+ * Bootstrap a new regex check that extracts capture groups with a <a
472
+ * href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">Java Regular
473
+ * Expression</a> from response's body String. Encoding is either the one provided in the message
474
+ * (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
475
+ *
476
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
477
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
478
+ * {@link IllegalArgumentException}
479
+ *
480
+ * @param pattern the searched pattern, expressed as a Gatling Expression Language String
481
+ * @return the next DSL step
482
+ */
483
+ (pattern: string): CheckBuilderCaptureGroup;
484
+
485
+ /**
486
+ * Bootstrap a new regex check that extracts capture groups with a <a
487
+ * href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">Java Regular
488
+ * Expression</a> from response's body String. Encoding is either the one provided in the message
489
+ * (eg Content-Type charset attribute in HTTP), or the one defined in gatling.conf.
490
+ *
491
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
492
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
493
+ * {@link IllegalArgumentException}
494
+ *
495
+ * @param pattern the searched pattern, expressed as a function
496
+ * @return the next DSL step
497
+ */
498
+ (pattern: (session: Session) => string): CheckBuilderCaptureGroup;
499
+ }
500
+
501
+ export const regex: RegexFunction = (pattern: Expression<string>): CheckBuilderCaptureGroup =>
502
+ wrapCheckBuilderCaptureGroup(
503
+ typeof pattern === "function" ? JvmCoreDsl.regex(underlyingSessionTo(pattern)) : JvmCoreDsl.regex(pattern)
504
+ );
505
+
506
+ /**
507
+ * Bootstrap a new md5 check that extracts the <a href="https://en.wikipedia.org/wiki/MD5">MD5</a>
508
+ * checksum of the response's body.
509
+ *
510
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
511
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
512
+ * error
513
+ *
514
+ * @returns the next DSL step
515
+ */
516
+ export const md5 = (): CheckBuilderFind<string> => wrapCheckBuilderFind(JvmCoreDsl.md5());
517
+
518
+ /**
519
+ * Bootstrap a new sha1 check that extracts the <a
520
+ * href="https://en.wikipedia.org/wiki/SHA-1">SHA-1</a> checksum of the response's body.
521
+ *
522
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
523
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
524
+ * error
525
+ *
526
+ * @returns the next DSL step
527
+ */
528
+ export const sha1 = (): CheckBuilderFind<string> => wrapCheckBuilderFind(JvmCoreDsl.sha1());
529
+
530
+ /**
531
+ * Bootstrap a new responseTimeInMillis check that extracts the response time of the request.
532
+ *
533
+ * <p>Note: On contrary to the Scala DSL, the compiler can't check the availability of this check
534
+ * type for your protocol. If the protocol you're using doesn't support it, you'll get a runtime
535
+ * error
536
+ *
537
+ * @returns the next DSL step
538
+ */
539
+ export const responseTimeInMillis = (): CheckBuilderFind<number> =>
540
+ wrapCheckBuilderFind(JvmCoreDsl.responseTimeInMillis() as JvmCheckBuilderFind<number>);
@@ -0,0 +1,81 @@
1
+ import { CheckBuilderFind, wrapCheckBuilderFind } from "./find";
2
+
3
+ import JvmCheckBuilderFind = io.gatling.javaapi.core.CheckBuilder$Find;
4
+ import JvmCheckBuilderJsonOfTypeFind = io.gatling.javaapi.core.CheckBuilder$JsonOfTypeFind;
5
+
6
+ /**
7
+ * A special {@link CheckBuilderFind<string>} that works on JSON
8
+ */
9
+ export interface CheckBuilderJsonOfTypeFind extends CheckBuilderFind<string> {
10
+ /**
11
+ * Define that the extracted value is a String
12
+ *
13
+ * @returns a new CheckBuilderFind
14
+ */
15
+ ofString(): CheckBuilderFind<string>;
16
+
17
+ /**
18
+ * Define that the extracted value is a Boolean
19
+ *
20
+ * @returns a new CheckBuilderFind
21
+ */
22
+ ofBoolean(): CheckBuilderFind<boolean>;
23
+
24
+ /**
25
+ * Define that the extracted value is an Integer
26
+ *
27
+ * @returns a new CheckBuilderFind
28
+ */
29
+ ofInt(): CheckBuilderFind<number>;
30
+
31
+ /**
32
+ * Define that the extracted value is a Long
33
+ *
34
+ * @returns a new CheckBuilderFind
35
+ */
36
+ ofLong(): CheckBuilderFind<number>;
37
+
38
+ /**
39
+ * Define that the extracted value is a Double
40
+ *
41
+ * @returns a new CheckBuilderFind
42
+ */
43
+ ofDouble(): CheckBuilderFind<number>;
44
+
45
+ /**
46
+ * Define that the extracted value is a List (a JSON array)
47
+ *
48
+ * @returns a new CheckBuilderFind
49
+ */
50
+ ofList(): CheckBuilderFind<unknown[]>;
51
+
52
+ /**
53
+ * Define that the extracted value is a Map (a JSON object)
54
+ *
55
+ * @returns a new CheckBuilderFind
56
+ */
57
+ ofMap(): CheckBuilderFind<Record<string, unknown>>;
58
+
59
+ /**
60
+ * Define that the extracted value is an untyped object
61
+ *
62
+ * @returns a new CheckBuilderFind
63
+ */
64
+ ofObject(): CheckBuilderFind<unknown>;
65
+ }
66
+
67
+ export const wrapCheckBuilderJsonOfTypeFind = (
68
+ _underlying: JvmCheckBuilderJsonOfTypeFind
69
+ ): CheckBuilderJsonOfTypeFind => ({
70
+ ...wrapCheckBuilderFind<string>(_underlying),
71
+ ofString: (): CheckBuilderFind<string> => wrapCheckBuilderFind(_underlying.ofString()),
72
+ ofBoolean: (): CheckBuilderFind<boolean> =>
73
+ wrapCheckBuilderFind(_underlying.ofBoolean() as JvmCheckBuilderFind<boolean>),
74
+ ofInt: (): CheckBuilderFind<number> => wrapCheckBuilderFind(_underlying.ofInt() as JvmCheckBuilderFind<number>),
75
+ ofLong: (): CheckBuilderFind<number> => wrapCheckBuilderFind(_underlying.ofLong() as JvmCheckBuilderFind<number>),
76
+ ofDouble: (): CheckBuilderFind<number> => wrapCheckBuilderFind(_underlying.ofDouble() as JvmCheckBuilderFind<number>),
77
+ ofList: (): CheckBuilderFind<unknown[]> => wrapCheckBuilderFind(_underlying.ofList()),
78
+ ofMap: (): CheckBuilderFind<Record<string, unknown>> =>
79
+ wrapCheckBuilderFind(_underlying.ofMap() as JvmCheckBuilderFind<any>),
80
+ ofObject: (): CheckBuilderFind<unknown> => wrapCheckBuilderFind(_underlying.ofObject())
81
+ });