4
4
package com .azure .communication .rooms ;
5
5
6
6
import static org .junit .jupiter .api .Assertions .assertEquals ;
7
+ import static org .junit .jupiter .api .Assertions .assertFalse ;
7
8
import static org .junit .jupiter .api .Assertions .assertNotNull ;
8
9
import static org .junit .jupiter .api .Assertions .assertThrows ;
9
10
@@ -80,7 +81,7 @@ public void createRoomFullCycleWithResponseStep(HttpClient httpClient) {
80
81
assertHappyPath (roomResult , 200 );
81
82
}).verifyComplete ();
82
83
83
- Mono <Response <CommunicationRoom >> response4 = roomsAsyncClient .getRoomWithResponse (roomId );
84
+ Mono <Response <CommunicationRoom >> response4 = roomsAsyncClient .getRoomWithResponse (roomId , null );
84
85
85
86
StepVerifier .create (response4 )
86
87
.assertNext (result4 -> {
@@ -140,12 +141,8 @@ public void createRoomFullCycleWithOutResponseStep(HttpClient httpClient) {
140
141
assertEquals (result4 .getRoomId (), roomId );
141
142
}).verifyComplete ();
142
143
143
- Mono <Response <Void >> response5 = roomsAsyncClient .deleteRoomWithResponse (roomId );
144
- StepVerifier .create (response5 )
145
- .assertNext (result5 -> {
146
- assertEquals (result5 .getStatusCode (), 204 );
147
- }).verifyComplete ();
148
-
144
+ Mono <Void > response5 = roomsAsyncClient .deleteRoom (roomId , null );
145
+ StepVerifier .create (response5 ).verifyComplete ();
149
146
}
150
147
151
148
@ ParameterizedTest
@@ -210,7 +207,7 @@ public void createRoomWithOnlyParticipantAttributes(HttpClient httpClient) {
210
207
211
208
String roomId = response1 .block ().getRoomId ();
212
209
213
- Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId );
210
+ Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId , null );
214
211
StepVerifier .create (response2 )
215
212
.assertNext (result2 -> {
216
213
assertEquals (result2 .getStatusCode (), 204 );
@@ -234,9 +231,9 @@ public void createRoomWithValidUntilInPast(HttpClient httpClient) {
234
231
235
232
CommunicationErrorResponseException exception =
236
233
assertThrows (CommunicationErrorResponseException .class , () -> {
237
- roomsAsyncClient .createRoomWithResponse (roomOptions , Context . NONE ).block ();
234
+ roomsAsyncClient .createRoomWithResponse (roomOptions , null ).block ();
238
235
});
239
- assertEquals (400 , exception .getResponse ().getStatusCode ());
236
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
240
237
}
241
238
242
239
@ ParameterizedTest
@@ -255,7 +252,7 @@ public void createRoomWithValidUntilGreaterThan180(HttpClient httpClient) {
255
252
assertThrows (CommunicationErrorResponseException .class , () -> {
256
253
roomsAsyncClient .createRoomWithResponse (createRoomOptions , Context .NONE ).block ();
257
254
});
258
- assertEquals (400 , exception .getResponse ().getStatusCode ());
255
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
259
256
}
260
257
261
258
@ ParameterizedTest
@@ -274,7 +271,7 @@ public void createRoomWithOnlyValidFromGreaterThan180(HttpClient httpClient) {
274
271
assertThrows (CommunicationErrorResponseException .class , () -> {
275
272
roomsAsyncClient .createRoomWithResponse (createRoomOptions , Context .NONE ).block ();
276
273
});
277
- assertEquals (400 , exception .getResponse ().getStatusCode ());
274
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
278
275
}
279
276
280
277
@ ParameterizedTest
@@ -295,7 +292,8 @@ public void createRoomWithBadParticipantMri(HttpClient httpClient) {
295
292
assertThrows (CommunicationErrorResponseException .class , () -> {
296
293
roomsAsyncClient .createRoomWithResponse (roomOptions , Context .NONE ).block ();
297
294
});
298
- assertEquals (400 , exception .getResponse ().getStatusCode ());
295
+ assertEquals ("BadRequest" , exception .getValue ().getError ().getCode ());
296
+ assertFalse (exception .getValue ().getError ().getMessage ().isEmpty ());
299
297
}
300
298
301
299
@ ParameterizedTest
@@ -308,7 +306,8 @@ public void getRoomWithUnexistingRoomIdReturnBadRequest(HttpClient httpClient) {
308
306
assertThrows (CommunicationErrorResponseException .class , () -> {
309
307
roomsAsyncClient .getRoom (nonExistRoomId ).block ();
310
308
});
311
- assertEquals (400 , exception .getResponse ().getStatusCode ());
309
+ assertEquals ("BadRequest" , exception .getValue ().getError ().getCode ());
310
+ assertFalse (exception .getValue ().getError ().getMessage ().isEmpty ());
312
311
}
313
312
314
313
@ ParameterizedTest
@@ -322,7 +321,7 @@ public void updateRoomValidUntilGreaterThan180(HttpClient httpClient) {
322
321
.setValidFrom (VALID_FROM )
323
322
.setValidUntil (VALID_UNTIL );
324
323
325
- Mono <Response <CommunicationRoom >> response1 = roomsAsyncClient .createRoomWithResponse (createRoomOptions );
324
+ Mono <Response <CommunicationRoom >> response1 = roomsAsyncClient .createRoomWithResponse (createRoomOptions , null );
326
325
327
326
StepVerifier .create (response1 )
328
327
.assertNext (roomResult -> {
@@ -338,15 +337,12 @@ public void updateRoomValidUntilGreaterThan180(HttpClient httpClient) {
338
337
339
338
CommunicationErrorResponseException exception =
340
339
assertThrows (CommunicationErrorResponseException .class , () -> {
341
- roomsAsyncClient .updateRoom (roomId , updateRoomOptions ).block ();
340
+ roomsAsyncClient .updateRoom (roomId , updateRoomOptions , null ).block ();
342
341
});
343
- assertEquals (400 , exception .getResponse ().getStatusCode ());
342
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
344
343
345
- Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId );
346
- StepVerifier .create (response2 )
347
- .assertNext (result2 -> {
348
- assertEquals (result2 .getStatusCode (), 204 );
349
- }).verifyComplete ();
344
+ Mono <Void > response5 = roomsAsyncClient .deleteRoom (roomId , null );
345
+ StepVerifier .create (response5 ).verifyComplete ();
350
346
}
351
347
352
348
@ ParameterizedTest
@@ -378,7 +374,7 @@ public void updateRoomValidFromGreaterThan180(HttpClient httpClient) {
378
374
assertThrows (CommunicationErrorResponseException .class , () -> {
379
375
roomsAsyncClient .updateRoom (roomId , updateRoomOptions ).block ();
380
376
});
381
- assertEquals (400 , exception .getResponse ().getStatusCode ());
377
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
382
378
383
379
Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId );
384
380
StepVerifier .create (response2 )
@@ -416,7 +412,7 @@ public void updateRoomValidUntilInPast(HttpClient httpClient) {
416
412
assertThrows (CommunicationErrorResponseException .class , () -> {
417
413
roomsAsyncClient .updateRoom (roomId , updateRoomOptions ).block ();
418
414
});
419
- assertEquals (400 , exception .getResponse ().getStatusCode ());
415
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
420
416
421
417
Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId );
422
418
StepVerifier .create (response2 )
@@ -454,7 +450,7 @@ public void updateRoomWithInvalidRoomId(HttpClient httpClient) {
454
450
assertThrows (CommunicationErrorResponseException .class , () -> {
455
451
roomsAsyncClient .updateRoom (roomId , updateRoomOptions ).block ();
456
452
});
457
- assertEquals (400 , exception .getResponse ().getStatusCode ());
453
+ assertEquals ("BadRequest" , exception .getValue ().getError (). getCode ());
458
454
459
455
Mono <Response <Void >> response2 = roomsAsyncClient .deleteRoomWithResponse (roomId );
460
456
StepVerifier .create (response2 )
@@ -503,10 +499,10 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
503
499
List <RoomParticipant > participants = Arrays .asList (firstParticipant , secondParticipant , thirdParticipant );
504
500
505
501
// Add 3 participants.
506
- AddOrUpdateParticipantsResult addParticipantResponse = roomsAsyncClient .addOrUpdateParticipants (roomId , participants ).block ();
502
+ AddOrUpdateParticipantsResult addParticipantResponse = roomsAsyncClient .addOrUpdateParticipants (roomId , participants , null ).block ();
507
503
508
504
// Check participant count, expected 3
509
- PagedFlux <RoomParticipant > listParticipantsResponse2 = roomsAsyncClient .listParticipants (roomId );
505
+ PagedFlux <RoomParticipant > listParticipantsResponse2 = roomsAsyncClient .listParticipants (roomId , null );
510
506
511
507
StepVerifier .create (listParticipantsResponse2 .count ())
512
508
.expectNext (3L )
@@ -559,12 +555,12 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
559
555
secondParticipant .getCommunicationIdentifier ());
560
556
561
557
// Remove 2 participants
562
- Mono <RemoveParticipantsResult > removeParticipantResponse = roomsAsyncClient .removeParticipants (roomId ,
563
- participantsIdentifiersForParticipants );
558
+ Mono <Response < RemoveParticipantsResult >> removeParticipantResponse = roomsAsyncClient .removeParticipantsWithResponse (roomId ,
559
+ participantsIdentifiersForParticipants , null );
564
560
565
561
StepVerifier .create (removeParticipantResponse )
566
562
.assertNext (result -> {
567
- assertEquals (true , result instanceof RemoveParticipantsResult );
563
+ assertEquals (result . getStatusCode (), 200 );
568
564
})
569
565
.verifyComplete ();
570
566
@@ -582,7 +578,8 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
582
578
assertThrows (CommunicationErrorResponseException .class , () -> {
583
579
roomsAsyncClient .removeParticipants (roomId , participantsIdentifiersForNonExistentParticipant ).block ();
584
580
});
585
- assertEquals (400 , exception .getResponse ().getStatusCode ());
581
+ assertEquals ("BadRequest" , exception .getValue ().getError ().getCode ());
582
+ assertFalse (exception .getValue ().getError ().getMessage ().isEmpty ());
586
583
587
584
// Remove Non-existent participants
588
585
Mono <RemoveParticipantsResult > removeParticipantResponse2 = roomsAsyncClient .removeParticipants (roomId ,
@@ -739,7 +736,7 @@ public void listRoomTestFirstRoomIsNotNullThenDeleteRoomWithOutResponse(HttpClie
739
736
String roomId = createCommunicationRoom .block ().getRoomId ();
740
737
741
738
//Get created rooms
742
- PagedFlux <CommunicationRoom > listRoomResponse = roomsAsyncClient .listRooms ();
739
+ PagedFlux <CommunicationRoom > listRoomResponse = roomsAsyncClient .listRooms (null );
743
740
744
741
StepVerifier .create (listRoomResponse .take (1 ))
745
742
.assertNext (room -> {
@@ -821,7 +818,7 @@ public void updateParticipantsToDefaultRoleWithResponseStep(HttpClient httpClien
821
818
.asList (new RoomParticipant (firstParticipant .getCommunicationIdentifier ()));
822
819
823
820
Mono <Response <AddOrUpdateParticipantsResult >> response2 = roomsAsyncClient
824
- .addOrUpdateParticipantsWithResponse (roomId , participantToUpdate );
821
+ .addOrUpdateParticipantsWithResponse (roomId , participantToUpdate , null );
825
822
826
823
StepVerifier .create (response2 )
827
824
.assertNext (result2 -> {
0 commit comments