@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,160 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { Executable } from "./execs";
3
+
4
+ import JvmDoIfOrElse = io.gatling.javaapi.core.condition.DoIfOrElse;
5
+ import JvmDoIfEqualsOrElse = io.gatling.javaapi.core.condition.DoIfEqualsOrElse;
6
+ import JvmExecutable = io.gatling.javaapi.core.exec.Executable;
7
+
8
+ interface JvmThen<T> {
9
+ then(executable: JvmExecutable, ...executables: JvmExecutable[]): JvmOrElse<T>;
10
+ }
11
+
12
+ export interface Then<T> {
13
+ then(executable: Executable<any>, ...executables: Executable<any>[]): OrElse<T>;
14
+ }
15
+
16
+ const wrapThen = <J, T>(jvmThen: JvmThen<J>, wrap: (underlying: J) => T): Then<T> => ({
17
+ then: (executable: Executable<any>, ...executables: Executable<any>[]): OrElse<T> =>
18
+ wrapOrElse(jvmThen.then(executable._underlying, ...executables.map((e) => e._underlying)), wrap)
19
+ });
20
+
21
+ interface JvmOrElse<T> {
22
+ orElse(executable: JvmExecutable, ...executables: JvmExecutable[]): T;
23
+ }
24
+
25
+ export interface OrElse<T> {
26
+ orElse(executable: Executable<any>, ...executables: Executable<any>[]): T;
27
+ }
28
+
29
+ const wrapOrElse = <J, T>(jvmOrElse: JvmOrElse<J>, wrap: (underlying: J) => T): OrElse<T> => ({
30
+ orElse: (executable: Executable<any>, ...executables: Executable<any>[]): T =>
31
+ wrap(jvmOrElse.orElse(executable._underlying, ...executables.map((e) => e._underlying)))
32
+ });
33
+
34
+ export interface DoIfOrElseFunction<T extends DoIfOrElse<T>> {
35
+ /**
36
+ * Execute the "then" block only if the condition is true
37
+ *
38
+ * @param condition - the condition expressed as a Gatling Expression Language String that must
39
+ * evaluate to a Boolean
40
+ * @returns a DSL component for defining the "then" block
41
+ */
42
+ (condition: string): Then<T>;
43
+
44
+ /**
45
+ * Execute the "then" block only if the condition is true
46
+ *
47
+ * @param condition - the condition expressed as a function
48
+ * @returns a DSL component for defining the "then" block
49
+ */
50
+ (condition: SessionTo<boolean>): Then<T>;
51
+ }
52
+
53
+ export interface DoIfOrElse<T extends DoIfOrElse<T>> {
54
+ doIfOrElse: DoIfOrElseFunction<T>;
55
+ }
56
+
57
+ export const doIfOrElseImpl =
58
+ <J2, J1 extends JvmDoIfOrElse<J2, any>, T extends DoIfOrElse<T>>(
59
+ jvmDoIfOrElse: J1,
60
+ wrap: (wrapped: J2) => T
61
+ ): DoIfOrElseFunction<T> =>
62
+ (condition: string | SessionTo<boolean>) =>
63
+ wrapThen(
64
+ typeof condition === "function"
65
+ ? jvmDoIfOrElse.doIfOrElse(underlyingSessionTo(condition))
66
+ : jvmDoIfOrElse.doIfOrElse(condition),
67
+ wrap
68
+ );
69
+
70
+ export interface DoIfEqualsOrElseFunction<T extends DoIfEqualsOrElse<T>> {
71
+ /**
72
+ * Execute the "then" block only if the actual value is equal to the expected one
73
+ *
74
+ * @param actual - the actual value expressed as a Gatling Expression Language String
75
+ * @param expected - the expected value expressed as a Gatling Expression Language String
76
+ * @returns a DSL component for defining the "then" block
77
+ */
78
+ (actual: string, expected: string): Then<T>;
79
+
80
+ /**
81
+ * Execute the "then" block only if the actual value is equal to the expected one
82
+ *
83
+ * @param actual - the actual value expressed as a Gatling Expression Language String
84
+ * @param expected - the expected static value
85
+ * @returns a DSL component for defining the "then" block
86
+ */
87
+ (actual: string, expected: unknown): Then<T>;
88
+
89
+ /**
90
+ * Execute the "then" block only if the actual value is equal to the expected one
91
+ *
92
+ * @param actual - the actual value expressed as a function
93
+ * @param expected - the expected value expressed as a Gatling Expression Language String
94
+ * @returns a DSL component for defining the "then" block
95
+ */
96
+ (actual: string, expected: SessionTo<unknown>): Then<T>;
97
+
98
+ /**
99
+ * Execute the "then" block only if the actual value is equal to the expected one
100
+ *
101
+ * @param actual - the actual value expressed as a function
102
+ * @param expected - the expected value expressed as a Gatling Expression Language String
103
+ * @returns a DSL component for defining the "then" block
104
+ */
105
+ (actual: SessionTo<unknown>, expected: string): Then<T>;
106
+
107
+ /**
108
+ * Execute the "then" block only if the actual value is equal to the expected one
109
+ *
110
+ * @param actual - the actual value expressed as a function
111
+ * @param expected - the expected static value
112
+ * @returns a DSL component for defining the "then" block
113
+ */
114
+ (actual: SessionTo<unknown>, expected: unknown): Then<T>;
115
+
116
+ /**
117
+ * Execute the "then" block only if the actual value is equal to the expected one
118
+ *
119
+ * @param actual - the actual value expressed as a function
120
+ * @param expected - the expected value expressed as a function
121
+ * @returns a DSL component for defining the "then" block
122
+ */
123
+ (actual: SessionTo<unknown>, expected: SessionTo<unknown>): Then<T>;
124
+ }
125
+
126
+ export interface DoIfEqualsOrElse<T extends DoIfEqualsOrElse<T>> {
127
+ doIfEqualsOrElse: DoIfEqualsOrElseFunction<T>;
128
+ }
129
+
130
+ export const doIfEqualsOrElseImpl =
131
+ <J2, J1 extends JvmDoIfEqualsOrElse<J2, any>, T extends DoIfEqualsOrElse<T>>(
132
+ jvmDoIfEqualsOrElse: J1,
133
+ wrap: (wrapped: J2) => T
134
+ ): DoIfEqualsOrElseFunction<T> =>
135
+ (actual: string | SessionTo<unknown>, expected: string | SessionTo<unknown> | unknown) => {
136
+ if (typeof actual === "function") {
137
+ const wrappedActual = underlyingSessionTo(actual);
138
+ if (typeof expected === "function") {
139
+ return wrapThen(
140
+ jvmDoIfEqualsOrElse.doIfEqualsOrElse(wrappedActual, underlyingSessionTo(expected as SessionTo<unknown>)),
141
+ wrap
142
+ );
143
+ } else if (typeof expected === "string") {
144
+ return wrapThen(jvmDoIfEqualsOrElse.doIfEqualsOrElse(wrappedActual, expected), wrap);
145
+ } else {
146
+ return wrapThen(jvmDoIfEqualsOrElse.doIfEqualsOrElse(wrappedActual, expected), wrap);
147
+ }
148
+ } else {
149
+ if (typeof expected === "function") {
150
+ return wrapThen(
151
+ jvmDoIfEqualsOrElse.doIfEqualsOrElse(actual, underlyingSessionTo(expected as SessionTo<unknown>)),
152
+ wrap
153
+ );
154
+ } else if (typeof expected === "string") {
155
+ return wrapThen(jvmDoIfEqualsOrElse.doIfEqualsOrElse(actual, expected), wrap);
156
+ } else {
157
+ return wrapThen(jvmDoIfEqualsOrElse.doIfEqualsOrElse(actual, expected), wrap);
158
+ }
159
+ }
160
+ };
@@ -0,0 +1,46 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { ChoiceWithKey } from "./choices";
3
+
4
+ import JvmDoSwitch = io.gatling.javaapi.core.condition.DoSwitch;
5
+ import JvmOn = io.gatling.javaapi.core.condition.DoSwitch$On;
6
+
7
+ export interface On<T> {
8
+ on(...choices: ChoiceWithKey[]): T;
9
+ }
10
+
11
+ const wrapOn = <J, T>(jvmOn: JvmOn<J>, wrap: (underlying: J) => T): On<T> => ({
12
+ on: (...choices: ChoiceWithKey[]): T => wrap(jvmOn.on(choices.map((c) => c._underlying)))
13
+ });
14
+
15
+ export interface DoSwitchFunction<T extends DoSwitch<T>> {
16
+ /**
17
+ * Execute one of the "choices" when the actual value is equal to the possibility's one.
18
+ *
19
+ * @param actual - the actual value expressed as a Gatling Expression Language String
20
+ * @returns a DSL component for defining the "choices"
21
+ */
22
+ (actual: string): On<T>;
23
+
24
+ /**
25
+ * Execute one of the "choices" when the actual value is equal to the possibility's one.
26
+ *
27
+ * @param actual - the actual value expressed as a function
28
+ * @returns a DSL component for defining the "choices"
29
+ */
30
+ (actual: SessionTo<unknown>): On<T>;
31
+ }
32
+
33
+ export interface DoSwitch<T extends DoSwitch<T>> {
34
+ doSwitch: DoSwitchFunction<T>;
35
+ }
36
+
37
+ export const doSwitchImpl =
38
+ <J2, J1 extends JvmDoSwitch<J2, any>, T extends DoSwitch<T>>(
39
+ jvmDoSwitch: J1,
40
+ wrap: (wrapped: J2) => T
41
+ ): DoSwitchFunction<T> =>
42
+ (actual: string | SessionTo<unknown>) =>
43
+ wrapOn(
44
+ typeof actual === "function" ? jvmDoSwitch.doSwitch(underlyingSessionTo(actual)) : jvmDoSwitch.doSwitch(actual),
45
+ wrap
46
+ );
@@ -0,0 +1,61 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { ChoiceWithKey } from "./choices";
3
+ import { Executable } from "./execs";
4
+
5
+ import JvmDoSwitchOrElse = io.gatling.javaapi.core.condition.DoSwitchOrElse;
6
+ import JvmOn = io.gatling.javaapi.core.condition.DoSwitchOrElse$On;
7
+ import JvmOrElse = io.gatling.javaapi.core.condition.DoSwitchOrElse$OrElse;
8
+
9
+ export interface On<T> {
10
+ on(...choices: ChoiceWithKey[]): OrElse<T>;
11
+ }
12
+
13
+ const wrapOn = <J, T>(jvmOn: JvmOn<J>, wrap: (underlying: J) => T): On<T> => ({
14
+ on: (...choices: ChoiceWithKey[]): OrElse<T> => wrapOrElse(jvmOn.on(choices.map((c) => c._underlying)), wrap)
15
+ });
16
+
17
+ interface OrElse<T> {
18
+ orElse(executable: Executable<any>, ...executables: Executable<any>[]): T;
19
+ }
20
+
21
+ const wrapOrElse = <J, T>(jvmOrElse: JvmOrElse<J>, wrap: (underlying: J) => T): OrElse<T> => ({
22
+ orElse: (executable: Executable<any>, ...executables: Executable<any>[]): T =>
23
+ wrap(jvmOrElse.orElse(executable._underlying, ...executables.map((e) => e._underlying)))
24
+ });
25
+
26
+ export interface DoSwitchOrElseFunction<T extends DoSwitchOrElse<T>> {
27
+ /**
28
+ * Execute one of the "choices" when the actual value is equal to the possibility's one, otherwise execute the "else"
29
+ * block.
30
+ *
31
+ * @param actual - the actual value expressed as a Gatling Expression Language String
32
+ * @returns a DSL component for defining the "choices"
33
+ */
34
+ (actual: string): On<T>;
35
+
36
+ /**
37
+ * Execute one of the "choices" when the actual value is equal to the possibility's one, otherwise execute the "else"
38
+ * block.
39
+ *
40
+ * @param actual - the actual value expressed as a function
41
+ * @returns a DSL component for defining the "choices"
42
+ */
43
+ (actual: SessionTo<unknown>): On<T>;
44
+ }
45
+
46
+ export interface DoSwitchOrElse<T extends DoSwitchOrElse<T>> {
47
+ doSwitchOrElse: DoSwitchOrElseFunction<T>;
48
+ }
49
+
50
+ export const doSwitchOrElseImpl =
51
+ <J2, J1 extends JvmDoSwitchOrElse<J2, any>, T extends DoSwitchOrElse<T>>(
52
+ jvmDoSwitchOrElse: J1,
53
+ wrap: (wrapped: J2) => T
54
+ ): DoSwitchOrElseFunction<T> =>
55
+ (actual: string | SessionTo<unknown>) =>
56
+ wrapOn(
57
+ typeof actual === "function"
58
+ ? jvmDoSwitchOrElse.doSwitchOrElse(underlyingSessionTo(actual))
59
+ : jvmDoSwitchOrElse.doSwitchOrElse(actual),
60
+ wrap
61
+ );
@@ -0,0 +1,53 @@
1
+ import { SessionTo, underlyingSessionTo } from "../session";
2
+ import { On, wrapOn } from "./on";
3
+
4
+ import JvmDoWhile = io.gatling.javaapi.core.loop.DoWhile;
5
+
6
+ export interface DoWhileFunction<T extends DoWhile<T>> {
7
+ /**
8
+ * Define a loop that will iterate as long as the condition holds true. The condition is evaluated
9
+ * at the end of the loop.
10
+ *
11
+ * @param condition the condition, expressed as a Gatling Expression Language String
12
+ * @param counterName the name of the loop counter, as stored in the Session
13
+ * @return a DSL component for defining the loop content
14
+ */
15
+ (condition: string, counterName?: string): On<T>;
16
+
17
+ /**
18
+ * Define a loop that will iterate as long as the condition holds true. The condition is evaluated
19
+ * at the end of the loop.
20
+ *
21
+ * @param condition the condition, expressed as a function
22
+ * @param counterName the name of the loop counter, as stored in the Session
23
+ * @return a DSL component for defining the loop content
24
+ */
25
+ (condition: SessionTo<boolean>, counterName?: string): On<T>;
26
+ }
27
+
28
+ export interface DoWhile<T extends DoWhile<T>> {
29
+ doWhile: DoWhileFunction<T>;
30
+ }
31
+
32
+ export const doWhileImpl =
33
+ <J2, J1 extends JvmDoWhile<J2, any>, T extends DoWhile<T>>(
34
+ jvmDoWhile: J1,
35
+ wrap: (wrapped: J2) => T
36
+ ): DoWhileFunction<T> =>
37
+ (condition: SessionTo<boolean> | string, counterName?: string) => {
38
+ if (counterName !== undefined) {
39
+ // doWhile(condition, counterName)
40
+ if (typeof condition === "function") {
41
+ return wrapOn(jvmDoWhile.doWhile(underlyingSessionTo(condition), counterName), wrap);
42
+ } else {
43
+ return wrapOn(jvmDoWhile.doWhile(condition, counterName), wrap);
44
+ }
45
+ } else {
46
+ // doWhile(condition)
47
+ if (typeof condition === "function") {
48
+ return wrapOn(jvmDoWhile.doWhile(underlyingSessionTo(condition)), wrap);
49
+ } else {
50
+ return wrapOn(jvmDoWhile.doWhile(condition), wrap);
51
+ }
52
+ }
53
+ };
@@ -0,0 +1,337 @@
1
+ import { Duration, isDuration, toJvmDuration } from "../utils/duration";
2
+ import { SessionTo, underlyingSessionTo, underlyingSessionToDuration } from "../session";
3
+ import { On, wrapOn } from "./on";
4
+
5
+ import JvmDoWhileDuring = io.gatling.javaapi.core.loop.DoWhileDuring;
6
+
7
+ export interface DoWhileDuringFunction<T extends DoWhileDuring<T>> {
8
+ /**
9
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
10
+ * isn't reached. The condition is evaluated at the end of the loop.
11
+ *
12
+ * @param condition - the condition, expressed as a Gatling Expression Language String
13
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
14
+ * @returns a DSL component for defining the loop content
15
+ */
16
+ (condition: string, duration: Duration): On<T>;
17
+
18
+ /**
19
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
20
+ * isn't reached. The condition is evaluated at the end of the loop.
21
+ *
22
+ * @param condition - the condition, expressed as a Gatling Expression Language String
23
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
24
+ * @param counterName - the name of the loop counter, as stored in the Session
25
+ * @returns a DSL component for defining the loop content
26
+ */
27
+ (condition: string, duration: Duration, counterName: string): On<T>;
28
+
29
+ /**
30
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
31
+ * isn't reached. The condition is evaluated at the end of the loop.
32
+ *
33
+ * @param condition - the condition, expressed as a Gatling Expression Language String
34
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
35
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
36
+ * inside the loop
37
+ * @returns a DSL component for defining the loop content
38
+ */
39
+ (condition: string, duration: Duration, exitASAP: boolean): On<T>;
40
+
41
+ /**
42
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
43
+ * isn't reached. The condition is evaluated at the end of the loop.
44
+ *
45
+ * @param condition - the condition, expressed as a Gatling Expression Language String
46
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
47
+ * @param counterName - the name of the loop counter, as stored in the Session
48
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
49
+ * inside the loop
50
+ * @returns a DSL component for defining the loop content
51
+ */
52
+ (condition: string, duration: Duration, counterName: string, exitASAP: boolean): On<T>;
53
+
54
+ /**
55
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
56
+ * isn't reached. The condition is evaluated at the end of the loop.
57
+ *
58
+ * @param condition - the condition, expressed as a Gatling Expression Language String
59
+ * @param duration - the maximum duration, expressed as a function
60
+ * @returns a DSL component for defining the loop content
61
+ */
62
+ (condition: string, duration: SessionTo<Duration>): On<T>;
63
+
64
+ /**
65
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
66
+ * isn't reached. The condition is evaluated at the end of the loop.
67
+ *
68
+ * @param condition - the condition, expressed as a Gatling Expression Language String
69
+ * @param duration - the maximum duration, expressed as a function
70
+ * @param counterName - the name of the loop counter, as stored in the Session
71
+ * @returns a DSL component for defining the loop content
72
+ */
73
+ (condition: string, duration: SessionTo<Duration>, counterName: string): On<T>;
74
+
75
+ /**
76
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
77
+ * isn't reached. The condition is evaluated at the end of the loop.
78
+ *
79
+ * @param condition - the condition, expressed as a Gatling Expression Language String
80
+ * @param duration - the maximum duration, expressed as a function
81
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
82
+ * inside the loop
83
+ * @returns a DSL component for defining the loop content
84
+ */
85
+ (condition: string, duration: SessionTo<Duration>, exitASAP: boolean): On<T>;
86
+
87
+ /**
88
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
89
+ * isn't reached. The condition is evaluated at the end of the loop.
90
+ *
91
+ * @param condition - the condition, expressed as a Gatling Expression Language String
92
+ * @param duration - the maximum duration, expressed as a function
93
+ * @param counterName - the name of the loop counter, as stored in the Session
94
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
95
+ * inside the loop
96
+ * @returns a DSL component for defining the loop content
97
+ */
98
+ (condition: string, duration: SessionTo<Duration>, counterName: string, exitASAP: boolean): On<T>;
99
+
100
+ /**
101
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
102
+ * isn't reached. The condition is evaluated at the end of the loop.
103
+ *
104
+ * @param condition - the condition, expressed as a Gatling Expression Language String
105
+ * @param duration - the maximum duration, expressed as a Gatling Expression Language String that
106
+ * must either evaluate to an integer number of seconds or an object with an explicit time unit
107
+ * @returns a DSL component for defining the loop content
108
+ */
109
+ (condition: string, duration: string): On<T>;
110
+
111
+ /**
112
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
113
+ * isn't reached. The condition is evaluated at the end of the loop.
114
+ *
115
+ * @param condition - the condition, expressed as a Gatling Expression Language String
116
+ * @param duration - the maximum duration, expressed as a Gatling Expression Language String that
117
+ * must either evaluate to an integer number of seconds or an object with an explicit time unit
118
+ * @param counterName - the name of the loop counter, as stored in the Session
119
+ * @returns a DSL component for defining the loop content
120
+ */
121
+ (condition: string, duration: string, counterName: string): On<T>;
122
+
123
+ /**
124
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
125
+ * isn't reached. The condition is evaluated at the end of the loop.
126
+ *
127
+ * @param condition - the condition, expressed as a Gatling Expression Language String
128
+ * @param duration - the maximum duration, expressed as a Gatling Expression Language String that
129
+ * must either evaluate to an integer number of seconds or an object with an explicit time unit
130
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
131
+ * inside the loop
132
+ * @returns a DSL component for defining the loop content
133
+ */
134
+ (condition: string, duration: string, exitASAP: boolean): On<T>;
135
+
136
+ /**
137
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
138
+ * isn't reached. The condition is evaluated at the end of the loop.
139
+ *
140
+ * @param condition - the condition, expressed as a Gatling Expression Language String
141
+ * @param duration - the maximum duration, expressed as a Gatling Expression Language String that
142
+ * must either evaluate to an integer number of seconds or an object with an explicit time unit
143
+ * @param counterName - the name of the loop counter, as stored in the Session
144
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
145
+ * inside the loop
146
+ * @returns a DSL component for defining the loop content
147
+ */
148
+ (condition: string, duration: string, counterName: string, exitASAP: boolean): On<T>;
149
+
150
+ /**
151
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
152
+ * isn't reached. The condition is evaluated at the end of the loop.
153
+ *
154
+ * @param condition - the condition, expressed as a function
155
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
156
+ * @returns a DSL component for defining the loop content
157
+ */
158
+ (condition: SessionTo<boolean>, duration: Duration): On<T>;
159
+
160
+ /**
161
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
162
+ * isn't reached. The condition is evaluated at the end of the loop.
163
+ *
164
+ * @param condition - the condition, expressed as a function
165
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
166
+ * @param counterName - the name of the loop counter, as stored in the Session
167
+ * @returns a DSL component for defining the loop content
168
+ */
169
+ (condition: SessionTo<boolean>, duration: Duration, counterName: string): On<T>;
170
+
171
+ /**
172
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
173
+ * isn't reached. The condition is evaluated at the end of the loop.
174
+ *
175
+ * @param condition - the condition, expressed as a function
176
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
177
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
178
+ * inside the loop
179
+ * @returns a DSL component for defining the loop content
180
+ */
181
+ (condition: SessionTo<boolean>, duration: Duration, exitASAP: boolean): On<T>;
182
+
183
+ /**
184
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
185
+ * isn't reached. The condition is evaluated at the end of the loop.
186
+ *
187
+ * @param condition - the condition, expressed as a function
188
+ * @param duration - the maximum duration, either an integer number of seconds or an object with an explicit time unit
189
+ * @param counterName - the name of the loop counter, as stored in the Session
190
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
191
+ * inside the loop
192
+ * @returns a DSL component for defining the loop content
193
+ */
194
+ (condition: SessionTo<boolean>, duration: Duration, counterName: string, exitASAP: boolean): On<T>;
195
+
196
+ /**
197
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
198
+ * isn't reached. The condition is evaluated at the end of the loop.
199
+ *
200
+ * @param condition - the condition, expressed as a function
201
+ * @param duration - the maximum duration, expressed as a function
202
+ * @returns a DSL component for defining the loop content
203
+ */
204
+ (condition: SessionTo<boolean>, duration: SessionTo<Duration>): On<T>;
205
+
206
+ /**
207
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
208
+ * isn't reached. The condition is evaluated at the end of the loop.
209
+ *
210
+ * @param condition - the condition, expressed as a function
211
+ * @param duration - the maximum duration, expressed as a function
212
+ * @param counterName - the name of the loop counter, as stored in the Session
213
+ * @returns a DSL component for defining the loop content
214
+ */
215
+ (condition: SessionTo<boolean>, duration: SessionTo<Duration>, counterName: string): On<T>;
216
+
217
+ /**
218
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
219
+ * isn't reached. The condition is evaluated at the end of the loop.
220
+ *
221
+ * @param condition - the condition, expressed as a function
222
+ * @param duration - the maximum duration, expressed as a function
223
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
224
+ * inside the loop
225
+ * @returns a DSL component for defining the loop content
226
+ */
227
+ (condition: SessionTo<boolean>, duration: SessionTo<Duration>, exitASAP: boolean): On<T>;
228
+
229
+ /**
230
+ * Define a loop that will iterate as long as the condition holds true and a maximum duration
231
+ * isn't reached. The condition is evaluated at the end of the loop.
232
+ *
233
+ * @param condition - the condition, expressed as a function
234
+ * @param duration - the maximum duration, expressed as a function
235
+ * @param counterName - the name of the loop counter, as stored in the Session
236
+ * @param exitASAP - if the loop must be interrupted if the condition becomes false or the maximum duration is reached
237
+ * inside the loop
238
+ * @returns a DSL component for defining the loop content
239
+ */
240
+ (condition: SessionTo<boolean>, duration: SessionTo<Duration>, counterName: string, exitASAP: boolean): On<T>;
241
+ }
242
+
243
+ export interface DoWhileDuring<T extends DoWhileDuring<T>> {
244
+ doWhileDuring: DoWhileDuringFunction<T>;
245
+ }
246
+
247
+ export const doWhileDuringImpl =
248
+ <J2, J1 extends JvmDoWhileDuring<J2, any>, T extends DoWhileDuring<T>>(
249
+ jvmDoWhileDuring: J1,
250
+ wrap: (wrapped: J2) => T
251
+ ): DoWhileDuringFunction<T> =>
252
+ (
253
+ condition: SessionTo<boolean> | string,
254
+ duration: Duration | SessionTo<Duration> | string,
255
+ arg2?: string | boolean,
256
+ arg3?: boolean
257
+ ) => {
258
+ if (arg3 !== undefined && typeof arg2 === "string") {
259
+ // doWhileDuring(condition, duration, counterName, exitASAP)
260
+ if (typeof condition === "function") {
261
+ const wrappedCondition = underlyingSessionTo(condition);
262
+ if (isDuration(duration)) {
263
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(wrappedCondition, toJvmDuration(duration), arg2, arg3), wrap);
264
+ } else if (typeof duration === "function") {
265
+ return wrapOn(
266
+ jvmDoWhileDuring.doWhileDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2, arg3),
267
+ wrap
268
+ );
269
+ }
270
+ } else {
271
+ if (isDuration(duration)) {
272
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, toJvmDuration(duration), arg2, arg3), wrap);
273
+ } else if (typeof duration === "function") {
274
+ return wrapOn(
275
+ jvmDoWhileDuring.doWhileDuring(condition, underlyingSessionToDuration(duration), arg2, arg3),
276
+ wrap
277
+ );
278
+ }
279
+ }
280
+ } else if (typeof arg2 === "string") {
281
+ // doWhileDuring(condition, duration, counterName)
282
+ if (typeof condition === "function") {
283
+ const wrappedCondition = underlyingSessionTo(condition);
284
+ if (isDuration(duration)) {
285
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(wrappedCondition, toJvmDuration(duration), arg2), wrap);
286
+ } else if (typeof duration === "function") {
287
+ return wrapOn(
288
+ jvmDoWhileDuring.doWhileDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2),
289
+ wrap
290
+ );
291
+ }
292
+ } else {
293
+ if (isDuration(duration)) {
294
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, toJvmDuration(duration), arg2), wrap);
295
+ } else if (typeof duration === "function") {
296
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, underlyingSessionToDuration(duration), arg2), wrap);
297
+ }
298
+ }
299
+ } else if (typeof arg2 === "boolean") {
300
+ // doWhileDuring(condition, duration, exitASAP)
301
+ if (typeof condition === "function") {
302
+ const wrappedCondition = underlyingSessionTo(condition);
303
+ if (isDuration(duration)) {
304
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(wrappedCondition, toJvmDuration(duration), arg2), wrap);
305
+ } else if (typeof duration === "function") {
306
+ return wrapOn(
307
+ jvmDoWhileDuring.doWhileDuring(wrappedCondition, underlyingSessionToDuration(duration), arg2),
308
+ wrap
309
+ );
310
+ }
311
+ } else {
312
+ if (isDuration(duration)) {
313
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, toJvmDuration(duration), arg2), wrap);
314
+ } else if (typeof duration === "function") {
315
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, underlyingSessionToDuration(duration), arg2), wrap);
316
+ }
317
+ }
318
+ } else if (arg2 === undefined) {
319
+ // doWhileDuring(condition, duration)
320
+ if (typeof condition === "function") {
321
+ const wrappedCondition = underlyingSessionTo(condition);
322
+ if (isDuration(duration)) {
323
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(wrappedCondition, toJvmDuration(duration)), wrap);
324
+ } else if (typeof duration === "function") {
325
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(wrappedCondition, underlyingSessionToDuration(duration)), wrap);
326
+ }
327
+ } else {
328
+ if (isDuration(duration)) {
329
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, toJvmDuration(duration)), wrap);
330
+ } else if (typeof duration === "function") {
331
+ return wrapOn(jvmDoWhileDuring.doWhileDuring(condition, underlyingSessionToDuration(duration)), wrap);
332
+ }
333
+ }
334
+ }
335
+
336
+ throw Error(`doWhileDuring() called with invalid arguments ${condition}, ${duration}, ${arg2}, ${arg3}`);
337
+ };