5
5
import static org .mockito .Mockito .*;
6
6
7
7
import au .com .dius .pact .consumer .MockServer ;
8
+ import au .com .dius .pact .consumer .dsl .PactBuilder ;
8
9
import au .com .dius .pact .consumer .dsl .PactDslJsonArray ;
9
10
import au .com .dius .pact .consumer .dsl .PactDslJsonBody ;
10
- import au .com .dius .pact .consumer .dsl .PactDslWithProvider ;
11
11
import au .com .dius .pact .consumer .junit5 .PactConsumerTestExt ;
12
12
import au .com .dius .pact .consumer .junit5 .PactTestFor ;
13
13
import au .com .dius .pact .core .model .RequestResponsePact ;
14
+ import au .com .dius .pact .core .model .V4Pact ;
14
15
import au .com .dius .pact .core .model .annotations .Pact ;
15
16
import bio .terra .policy .model .*;
16
17
import bio .terra .workspace .app .configuration .external .FeatureConfiguration ;
@@ -109,8 +110,9 @@ void setup(MockServer mockServer) throws Exception {
109
110
}
110
111
111
112
@ Pact (consumer = "wsm" , provider = "tps" )
112
- public RequestResponsePact createPaoWithNoExistingPolicy (PactDslWithProvider builder ) {
113
+ public RequestResponsePact createPaoWithNoExistingPolicy (PactBuilder builder ) {
113
114
return builder
115
+ .usingLegacyDsl ()
114
116
.uponReceiving ("A request to create a policy" )
115
117
.method ("POST" )
116
118
.path ("/api/policy/v1alpha1/pao" )
@@ -133,8 +135,9 @@ public void testCreatingAPolicyWithNoExistingPolicy() throws Exception {
133
135
}
134
136
135
137
@ Pact (consumer = "wsm" , provider = "tps" )
136
- public RequestResponsePact createPaoWithAPreexistingPolicy (PactDslWithProvider builder ) {
138
+ public RequestResponsePact createPaoWithAPreexistingPolicy (PactBuilder builder ) {
137
139
return builder
140
+ .usingLegacyDsl ()
138
141
.given (existingPolicyState )
139
142
.uponReceiving ("A request to create a policy that already exists" )
140
143
.method ("POST" )
@@ -163,8 +166,9 @@ public void creatingAPolicyThatAlreadyExists() {
163
166
}
164
167
165
168
@ Pact (consumer = "wsm" , provider = "tps" )
166
- public RequestResponsePact deletePaoThatExists (PactDslWithProvider builder ) {
169
+ public V4Pact deletePaoThatExists (PactBuilder builder ) {
167
170
return builder
171
+ .usingLegacyDsl ()
168
172
.given (existingPolicyState )
169
173
.uponReceiving ("A request to delete a policy" )
170
174
.method ("DELETE" )
@@ -173,7 +177,7 @@ public RequestResponsePact deletePaoThatExists(PactDslWithProvider builder) {
173
177
"/api/policy/v1alpha1/pao/%s" .formatted (existingPolicyId ))
174
178
.willRespondWith ()
175
179
.status (HttpStatus .OK .value ())
176
- .toPact ();
180
+ .toPact (V4Pact . class );
177
181
}
178
182
179
183
@ Test
@@ -183,7 +187,7 @@ public void deletingAnExistingPolicy() throws Exception {
183
187
}
184
188
185
189
@ Pact (consumer = "wsm" , provider = "tps" )
186
- public RequestResponsePact getPaoWithAnExistingPolicy (PactDslWithProvider builder ) {
190
+ public V4Pact getPaoWithAnExistingPolicy (PactBuilder builder ) {
187
191
var policyResponseShape =
188
192
new PactDslJsonBody ()
189
193
.valueFromProviderState ("objectId" , existingPolicyProviderStateValue , existingPolicyId )
@@ -193,6 +197,7 @@ public RequestResponsePact getPaoWithAnExistingPolicy(PactDslWithProvider builde
193
197
.object ("attributes" , tpsPolicyInputsObjectShape );
194
198
195
199
return builder
200
+ .usingLegacyDsl ()
196
201
.given (existingPolicyState )
197
202
.uponReceiving ("A request to retrieve a policy" )
198
203
.method ("GET" )
@@ -202,7 +207,7 @@ public RequestResponsePact getPaoWithAnExistingPolicy(PactDslWithProvider builde
202
207
.willRespondWith ()
203
208
.status (HttpStatus .OK .value ())
204
209
.body (policyResponseShape )
205
- .toPact ();
210
+ .toPact (V4Pact . class );
206
211
}
207
212
208
213
@ Test
@@ -224,14 +229,15 @@ public void retrievingAnExistingPolicy() throws Exception {
224
229
}
225
230
226
231
@ Pact (consumer = "wsm" , provider = "tps" )
227
- public RequestResponsePact getPaoThatDoesNotExist (PactDslWithProvider builder ) {
232
+ public V4Pact getPaoThatDoesNotExist (PactBuilder builder ) {
228
233
return builder
234
+ .usingLegacyDsl ()
229
235
.uponReceiving ("A request to retrieve a policy that doesn't exist" )
230
236
.method ("GET" )
231
237
.matchPath ("/api/policy/v1alpha1/pao/%s" .formatted (UUID_REGEX ))
232
238
.willRespondWith ()
233
239
.status (HttpStatus .NOT_FOUND .value ())
234
- .toPact ();
240
+ .toPact (V4Pact . class );
235
241
}
236
242
237
243
@ Test
@@ -241,7 +247,7 @@ public void retrievingAPolicyThatDoesNotExist() {
241
247
}
242
248
243
249
@ Pact (consumer = "wsm" , provider = "tps" )
244
- public RequestResponsePact linkPaoWhenBothExist (PactDslWithProvider builder ) {
250
+ public V4Pact linkPaoWhenBothExist (PactBuilder builder ) {
245
251
var linkRequestShape =
246
252
new PactDslJsonBody ()
247
253
.valueFromProviderState (
@@ -254,6 +260,7 @@ public RequestResponsePact linkPaoWhenBothExist(PactDslWithProvider builder) {
254
260
.object ("resultingPao" );
255
261
256
262
return builder
263
+ .usingLegacyDsl ()
257
264
.given (existingPolicyState )
258
265
.given (secondPolicyState )
259
266
.uponReceiving ("A request to link the policies" )
@@ -266,7 +273,7 @@ public RequestResponsePact linkPaoWhenBothExist(PactDslWithProvider builder) {
266
273
.willRespondWith ()
267
274
.status (HttpStatus .OK .value ())
268
275
.body (linkResponseShape )
269
- .toPact ();
276
+ .toPact (V4Pact . class );
270
277
}
271
278
272
279
@ Test
@@ -277,7 +284,7 @@ public void linkTwoExistingPaosWithNoConflicts() throws Exception {
277
284
}
278
285
279
286
@ Pact (consumer = "wsm" , provider = "tps" )
280
- public RequestResponsePact mergePaoWhenBothExist (PactDslWithProvider builder ) {
287
+ public V4Pact mergePaoWhenBothExist (PactBuilder builder ) {
281
288
var linkRequestShape =
282
289
new PactDslJsonBody ()
283
290
.valueFromProviderState (
@@ -291,6 +298,7 @@ public RequestResponsePact mergePaoWhenBothExist(PactDslWithProvider builder) {
291
298
.object ("resultingPao" );
292
299
293
300
return builder
301
+ .usingLegacyDsl ()
294
302
.given (existingPolicyState )
295
303
.given (secondPolicyState )
296
304
.uponReceiving ("A request to link the policies" )
@@ -303,7 +311,7 @@ public RequestResponsePact mergePaoWhenBothExist(PactDslWithProvider builder) {
303
311
.willRespondWith ()
304
312
.status (HttpStatus .OK .value ())
305
313
.body (linkResponseShape )
306
- .toPact ();
314
+ .toPact (V4Pact . class );
307
315
}
308
316
309
317
@ Test
@@ -315,7 +323,7 @@ public void mergingTwoExistingPaos() throws Exception {
315
323
}
316
324
317
325
@ Pact (consumer = "wsm" , provider = "tps" )
318
- public RequestResponsePact replacePaoThatExists (PactDslWithProvider builder ) {
326
+ public V4Pact replacePaoThatExists (PactBuilder builder ) {
319
327
var updateRequestShape =
320
328
new PactDslJsonBody ()
321
329
.object ("newAttributes" , tpsPolicyInputsObjectShape )
@@ -326,6 +334,7 @@ public RequestResponsePact replacePaoThatExists(PactDslWithProvider builder) {
326
334
.object ("conflicts" , new PactDslJsonArray ())
327
335
.object ("resultingPao" ); // TpsPaoGetResult
328
336
return builder
337
+ .usingLegacyDsl ()
329
338
.given (existingPolicyState )
330
339
.uponReceiving ("A request to update a policy" )
331
340
.method ("PUT" )
@@ -337,7 +346,7 @@ public RequestResponsePact replacePaoThatExists(PactDslWithProvider builder) {
337
346
.willRespondWith ()
338
347
.status (HttpStatus .OK .value ())
339
348
.body (updateResponseShape )
340
- .toPact ();
349
+ .toPact (V4Pact . class );
341
350
}
342
351
343
352
@ Test
@@ -351,7 +360,7 @@ public void replacingAnExistingPaoWithNoConflicts() throws Exception {
351
360
}
352
361
353
362
@ Pact (consumer = "wsm" , provider = "tps" )
354
- public RequestResponsePact updatePaoPreexistingNoConflicts (PactDslWithProvider builder ) {
363
+ public V4Pact updatePaoPreexistingNoConflicts (PactBuilder builder ) {
355
364
var updateRequestShape =
356
365
new PactDslJsonBody ()
357
366
.object ("addAttributes" , tpsPolicyInputsObjectShape )
@@ -363,6 +372,7 @@ public RequestResponsePact updatePaoPreexistingNoConflicts(PactDslWithProvider b
363
372
.object ("conflicts" , new PactDslJsonArray ())
364
373
.object ("resultingPao" ); // TpsPaoGetResult
365
374
return builder
375
+ .usingLegacyDsl ()
366
376
.given (existingPolicyState )
367
377
.uponReceiving ("A request to update a policy" )
368
378
.method ("PATCH" )
@@ -374,7 +384,7 @@ public RequestResponsePact updatePaoPreexistingNoConflicts(PactDslWithProvider b
374
384
.willRespondWith ()
375
385
.status (HttpStatus .OK .value ())
376
386
.body (updateResponseShape )
377
- .toPact ();
387
+ .toPact (V4Pact . class );
378
388
}
379
389
380
390
@ Test
@@ -391,8 +401,9 @@ public void updatingAnExistingPaoWithNoConflicts() throws Exception {
391
401
}
392
402
393
403
@ Pact (consumer = "wsm" , provider = "tps" )
394
- public RequestResponsePact listValidRegions (PactDslWithProvider builder ) {
404
+ public V4Pact listValidRegions (PactBuilder builder ) {
395
405
return builder
406
+ .usingLegacyDsl ()
396
407
.given (existingPolicyState )
397
408
.uponReceiving ("A request to list the valid regions for a policy using the id" )
398
409
.method ("GET" )
@@ -403,7 +414,7 @@ public RequestResponsePact listValidRegions(PactDslWithProvider builder) {
403
414
.willRespondWith ()
404
415
.status (HttpStatus .OK .value ())
405
416
.body (new PactDslJsonArray ().stringType ())
406
- .toPact ();
417
+ .toPact (V4Pact . class );
407
418
}
408
419
409
420
@ Test
@@ -414,8 +425,9 @@ public void listingValidRegionsOnAWorkspace() throws Exception {
414
425
}
415
426
416
427
@ Pact (consumer = "wsm" , provider = "tps" )
417
- public RequestResponsePact listValidByPolicyInput (PactDslWithProvider builder ) {
428
+ public V4Pact listValidByPolicyInput (PactBuilder builder ) {
418
429
return builder
430
+ .usingLegacyDsl ()
419
431
.given (existingPolicyState )
420
432
.uponReceiving ("A request to list the valid regions for a policy using policy input" )
421
433
.method ("POST" )
@@ -426,7 +438,7 @@ public RequestResponsePact listValidByPolicyInput(PactDslWithProvider builder) {
426
438
.willRespondWith ()
427
439
.status (HttpStatus .OK .value ())
428
440
.body (new PactDslJsonArray ().stringType ())
429
- .toPact ();
441
+ .toPact (V4Pact . class );
430
442
}
431
443
432
444
@ Test
@@ -445,7 +457,7 @@ public void listingValidRegionsOnAPolicy() throws Exception {
445
457
}
446
458
447
459
@ Pact (consumer = "wsm" , provider = "tps" )
448
- public RequestResponsePact explainingAWorkspacePolicy (PactDslWithProvider builder ) {
460
+ public V4Pact explainingAWorkspacePolicy (PactBuilder builder ) {
449
461
var explainResponse =
450
462
new PactDslJsonBody ()
451
463
.numberType ("depth" )
@@ -455,6 +467,7 @@ public RequestResponsePact explainingAWorkspacePolicy(PactDslWithProvider builde
455
467
"policyInput" ,
456
468
new PactDslJsonBody ().stringType ("namespace" ).stringType ("name" ).closeObject ());
457
469
return builder
470
+ .usingLegacyDsl ()
458
471
.given (existingPolicyState )
459
472
.uponReceiving ("A request to explain the policy" )
460
473
.method ("GET" )
@@ -465,7 +478,7 @@ public RequestResponsePact explainingAWorkspacePolicy(PactDslWithProvider builde
465
478
.willRespondWith ()
466
479
.status (HttpStatus .OK .value ())
467
480
.body (explainResponse )
468
- .toPact ();
481
+ .toPact (V4Pact . class );
469
482
}
470
483
471
484
@ Test
@@ -486,7 +499,7 @@ public void explainingAPolicy() throws Exception {
486
499
}
487
500
488
501
@ Pact (consumer = "wsm" , provider = "tps" )
489
- public RequestResponsePact getLocationInfo (PactDslWithProvider builder ) {
502
+ public V4Pact getLocationInfo (PactBuilder builder ) {
490
503
var locationArray =
491
504
new PactDslJsonArray ()
492
505
.eachArrayLike ()
@@ -502,6 +515,7 @@ public RequestResponsePact getLocationInfo(PactDslWithProvider builder) {
502
515
.object ("regions" , new PactDslJsonArray ().stringType ())
503
516
.object ("locations" , locationArray );
504
517
return builder
518
+ .usingLegacyDsl ()
505
519
.uponReceiving ("A request for information about a location" )
506
520
.method ("GET" )
507
521
.path ("/api/policy/v1alpha1/location" )
@@ -510,7 +524,7 @@ public RequestResponsePact getLocationInfo(PactDslWithProvider builder) {
510
524
.willRespondWith ()
511
525
.status (HttpStatus .OK .value ())
512
526
.body (responseShape )
513
- .toPact ();
527
+ .toPact (V4Pact . class );
514
528
}
515
529
516
530
@ Test
@@ -521,7 +535,7 @@ public void retrievingInformationOnALocation() throws Exception {
521
535
}
522
536
523
537
@ Pact (consumer = "wsm" , provider = "tps" )
524
- public RequestResponsePact getLocationInfoWithNullLocation (PactDslWithProvider builder ) {
538
+ public V4Pact getLocationInfoWithNullLocation (PactBuilder builder ) {
525
539
var locationArray =
526
540
new PactDslJsonArray ()
527
541
.eachArrayLike ()
@@ -537,14 +551,15 @@ public RequestResponsePact getLocationInfoWithNullLocation(PactDslWithProvider b
537
551
.object ("regions" , new PactDslJsonArray ().stringType ())
538
552
.object ("locations" , locationArray );
539
553
return builder
554
+ .usingLegacyDsl ()
540
555
.uponReceiving ("A request for information about a null location" )
541
556
.method ("GET" )
542
557
.path ("/api/policy/v1alpha1/location" )
543
558
.matchQuery ("platform" , cloudPlatformTpsRegex )
544
559
.willRespondWith ()
545
560
.status (HttpStatus .OK .value ())
546
561
.body (responseShape )
547
- .toPact ();
562
+ .toPact (V4Pact . class );
548
563
}
549
564
550
565
@ Test
0 commit comments