From 9bd554ff7eca9efcf7a2e84625cd3ec868127046 Mon Sep 17 00:00:00 2001 From: Arif Saikat <71465659+arifsaikat-microsoft@users.noreply.github.com> Date: Sat, 12 Jun 2021 21:13:49 -0700 Subject: [PATCH] pr review test fixes --- .../azure-communication-callingserver/pom.xml | 6 + .../CallConnectionRequestConverter.java | 1 - ...java => CallConnectionAsyncLiveTests.java} | 117 ++++++++--------- ...ests.java => CallConnectionLiveTests.java} | 112 ++++++++--------- ... CallingServerClientBuilderUnitTests.java} | 119 +++++++----------- .../callingserver/CallingServerTestBase.java | 79 +++++++++--- .../callingserver/CallingServerTestUtils.java | 8 +- ...ava => DownloadContentAsyncLiveTests.java} | 11 +- ...sts.java => DownloadContentLiveTests.java} | 52 ++++---- ...sts.java => ServerCallAsyncLiveTests.java} | 95 +++++++------- ...allTests.java => ServerCallLiveTests.java} | 118 +++++++++-------- .../callingserver/ServerCallUnitTests.java | 48 +++---- ...reateAddRemoveHangupScenarioAsync[1].json} | 0 ...veHangupScenarioWithResponseAsync[1].json} | 0 ....runCreateJoinHangupScenarioAsync[1].json} | 0 ...inHangupScenarioWithResponseAsync[1].json} | 0 ...eatePlayCancelHangupScenarioAsync[1].json} | 0 ...elHangupScenarioWithResponseAsync[1].json} | 0 ...dRemoveHangupScenarioWithResponse[1].json} | 0 ....runCreateAddRemoveHangupScenario[1].json} | 0 ...ateJoinHangupScenarioWithResponse[1].json} | 0 ...Tests.runCreateJoinHangupScenario[1].json} | 0 ...yCancelHangupScenarioWithResponse[1].json} | 0 ...runCreatePlayCancelHangupScenario[1].json} | 0 ...LiveTests.downloadContent404Async[1].json} | 0 ...ncLiveTests.downloadMetadataAsync[1].json} | 0 ...sts.downloadMetadataRetryingAsync[1].json} | 0 ...sts.downloadMetadataToStreamAsync[1].json} | 0 ...syncLiveTests.downloadToFileAsync[1].json} | 0 ...Tests.downloadToFileRetryingAsync[1].json} | 0 ...AsyncLiveTests.downloadVideoAsync[1].json} | 0 ...ntentLiveTests.downloadContent404[1].json} | 0 ...ests.downloadContentStreamFailure[1].json} | 0 ...LiveTests.downloadContentWrongUrl[1].json} | 0 ...veTests.downloadMetadataStreaming[1].json} | 0 ...ContentLiveTests.downloadMetadata[1].json} | 0 ...oadContentLiveTests.downloadVideo[1].json} | 0 ...veTests.runAddRemoveScenarioAsync[1].json} | 0 ...ddRemoveScenarioWithResponseAsync[1].json} | 0 ...eTests.runAllClientFunctionsAsync[1].json} | 0 ...lClientFunctionsWithResponseAsync[1].json} | 0 ...veTests.runPlayAudioFunctionAsync[1].json} | 0 ...layAudioFunctionWithResponseAsync[1].json} | 0 ...iveTests.startRecordingFailsAsync[1].json} | 0 ....runAddRemoveScenarioWithResponse[1].json} | 0 ...allLiveTests.runAddRemoveScenario[1].json} | 0 ...runAllClientFunctionsWithResponse[1].json} | 0 ...llLiveTests.runAllClientFunctions[1].json} | 0 ....runPlayAudioFunctionWithResponse[1].json} | 0 ...allLiveTests.runPlayAudioFunction[1].json} | 0 ...CallLiveTests.startRecordingFails[1].json} | 0 51 files changed, 378 insertions(+), 388 deletions(-) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{CallConnectionAsyncTests.java => CallConnectionAsyncLiveTests.java} (84%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{CallConnectionTests.java => CallConnectionLiveTests.java} (84%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{CallingServerClientBuilderTests.java => CallingServerClientBuilderUnitTests.java} (71%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{DownloadContentAsyncTests.java => DownloadContentAsyncLiveTests.java} (91%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{DownloadContentTests.java => DownloadContentLiveTests.java} (65%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{ServerCallAsyncTests.java => ServerCallAsyncLiveTests.java} (86%) rename sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/{ServerCallTests.java => ServerCallLiveTests.java} (81%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioAsync[1].json => CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json => CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreateJoinHangupScenarioAsync[1].json => CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreateJoinHangupScenarioWithResponseAsync[1].json => CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioAsync[1].json => CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json => CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreateAddRemoveHangupScenarioWithResponse[1].json => CallConnectionLiveTests.runCreateAddRemoveHangupScenarioWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreateAddRemoveHangupScenario[1].json => CallConnectionLiveTests.runCreateAddRemoveHangupScenario[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreateJoinHangupScenarioWithResponse[1].json => CallConnectionLiveTests.runCreateJoinHangupScenarioWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreateJoinHangupScenario[1].json => CallConnectionLiveTests.runCreateJoinHangupScenario[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreatePlayCancelHangupScenarioWithResponse[1].json => CallConnectionLiveTests.runCreatePlayCancelHangupScenarioWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{CallConnectionTests.runCreatePlayCancelHangupScenario[1].json => CallConnectionLiveTests.runCreatePlayCancelHangupScenario[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadContent404Async[1].json => DownloadContentAsyncLiveTests.downloadContent404Async[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadMetadataAsync[1].json => DownloadContentAsyncLiveTests.downloadMetadataAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadMetadataRetryingAsync[1].json => DownloadContentAsyncLiveTests.downloadMetadataRetryingAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadMetadataToStreamAsync[1].json => DownloadContentAsyncLiveTests.downloadMetadataToStreamAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadToFileAsync[1].json => DownloadContentAsyncLiveTests.downloadToFileAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadToFileRetryingAsync[1].json => DownloadContentAsyncLiveTests.downloadToFileRetryingAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentAsyncTests.downloadVideoAsync[1].json => DownloadContentAsyncLiveTests.downloadVideoAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadContent404[1].json => DownloadContentLiveTests.downloadContent404[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadContentStreamFailure[1].json => DownloadContentLiveTests.downloadContentStreamFailure[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadContentWrongUrl[1].json => DownloadContentLiveTests.downloadContentWrongUrl[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadMetadataStreaming[1].json => DownloadContentLiveTests.downloadMetadataStreaming[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadMetadata[1].json => DownloadContentLiveTests.downloadMetadata[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{DownloadContentTests.downloadVideo[1].json => DownloadContentLiveTests.downloadVideo[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runAddRemoveScenarioAsync[1].json => ServerCallAsyncLiveTests.runAddRemoveScenarioAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runAddRemoveScenarioWithResponseAsync[1].json => ServerCallAsyncLiveTests.runAddRemoveScenarioWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runAllClientFunctionsAsync[1].json => ServerCallAsyncLiveTests.runAllClientFunctionsAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runAllClientFunctionsWithResponseAsync[1].json => ServerCallAsyncLiveTests.runAllClientFunctionsWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runPlayAudioFunctionAsync[1].json => ServerCallAsyncLiveTests.runPlayAudioFunctionAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.runPlayAudioFunctionWithResponseAsync[1].json => ServerCallAsyncLiveTests.runPlayAudioFunctionWithResponseAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallAsyncTests.startRecordingFailsAsync[1].json => ServerCallAsyncLiveTests.startRecordingFailsAsync[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runAddRemoveScenarioWithResponse[1].json => ServerCallLiveTests.runAddRemoveScenarioWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runAddRemoveScenario[1].json => ServerCallLiveTests.runAddRemoveScenario[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runAllClientFunctionsWithResponse[1].json => ServerCallLiveTests.runAllClientFunctionsWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runAllClientFunctions[1].json => ServerCallLiveTests.runAllClientFunctions[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runPlayAudioFunctionWithResponse[1].json => ServerCallLiveTests.runPlayAudioFunctionWithResponse[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.runPlayAudioFunction[1].json => ServerCallLiveTests.runPlayAudioFunction[1].json} (100%) rename sdk/communication/azure-communication-callingserver/src/test/resources/session-records/{ServerCallTests.startRecordingFails[1].json => ServerCallLiveTests.startRecordingFails[1].json} (100%) diff --git a/sdk/communication/azure-communication-callingserver/pom.xml b/sdk/communication/azure-communication-callingserver/pom.xml index 290a35f8c558..869426072694 100644 --- a/sdk/communication/azure-communication-callingserver/pom.xml +++ b/sdk/communication/azure-communication-callingserver/pom.xml @@ -56,6 +56,12 @@ azure-communication-common 1.1.0-beta.1 + + com.azure + azure-communication-identity + 1.1.1 + test + com.azure azure-core-test diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java index a343a3e9b63a..f86af0875092 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/CallConnectionRequestConverter.java @@ -48,7 +48,6 @@ public static CreateCallRequestInternal convert(CommunicationIdentifier source, request.setCallbackUri(createCallOptions.getCallbackUri()); request.setRequestedMediaTypes(requestedModalities); request.setRequestedCallEvents(requestedCallEvents).setAlternateCallerId(sourceAlternateIdentity); - return request; } } diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java similarity index 84% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java index 1244ce34595d..dc882c710903 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java @@ -19,19 +19,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -/** - * Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to determine if tests are playback or - * live. By default, tests are run in playback mode. - */ -public class CallConnectionAsyncTests extends CallingServerTestBase { - - private String from = getRandomUserId(); - private String invitedUser = getRandomUserId(); - private String joinedUser = getRandomUserId(); - private String alternateId = "+11111111111"; - private String to = "+11111111111"; - private String callBackUri = "https://host.app/api/callback/calling"; - private String audioFileUri = "https://host.app/audio/bot-callcenter-intro.wav"; +public class CallConnectionAsyncLiveTests extends CallingServerTestBase { + + private final String fromUser = getNewUserId(); + private final String toUser = getNewUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -42,15 +33,15 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -59,7 +50,7 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { String operationContext = UUID.randomUUID().toString(); assert callConnectionAsync != null; PlayAudioResult playAudioResult = callConnectionAsync.playAudio( - audioFileUri, + AUDIO_FILE_URI, false, UUID.randomUUID().toString(), null, @@ -88,15 +79,15 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -107,7 +98,7 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl String operationContext = UUID.randomUUID().toString(); Response playAudioResponse = callConnectionAsync.playAudioWithResponse( - audioFileUri, + AUDIO_FILE_URI, false, UUID.randomUUID().toString(), null, @@ -137,15 +128,15 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -153,14 +144,14 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { // Invite User String operationContext = UUID.randomUUID().toString(); assert callConnectionAsync != null; - callConnectionAsync.addParticipant(new CommunicationUserIdentifier(invitedUser), null, operationContext).block(); + callConnectionAsync.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext).block(); // Remove Participant - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. */ String participantId = "e3560385-776f-41d1-bf04-07ef738f2fc1"; callConnectionAsync.removeParticipant(participantId).block(); @@ -182,15 +173,15 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -199,16 +190,16 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli // Invite User String operationContext = UUID.randomUUID().toString(); - Response inviteParticipantResponse = callConnectionAsync.addParticipantWithResponse(new CommunicationUserIdentifier(invitedUser), null, operationContext).block(); + Response inviteParticipantResponse = callConnectionAsync.addParticipantWithResponse(new CommunicationUserIdentifier(toUser), null, operationContext).block(); CallingServerTestUtils.validateResponse(inviteParticipantResponse); // Remove Participant - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. + */ String participantId = "80238d5f-9eda-481a-b911-e2e12eba9eda"; Response removeParticipantResponse = callConnectionAsync.removeParticipantWithResponse(participantId).block(); CallingServerTestUtils.validateResponse(removeParticipantResponse); @@ -231,33 +222,33 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); // Join - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3VodHNzZEZ3NFVHX1J4d1lHYWlLRmc_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); CallConnectionAsync joinedCallConnectionAsync = callingServerAsyncClient.join( serverCallId, - new CommunicationUserIdentifier(joinedUser), + new CommunicationUserIdentifier(toUser), joinCallOptions).block(); CallingServerTestUtils.validateCallConnectionAsync(joinedCallConnectionAsync); @@ -281,15 +272,15 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -297,19 +288,19 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) CallConnectionAsync callConnectionAsync = callConnectionAsyncResponse.getValue(); // Join - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() - */ + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() + */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3lKQXY0TnVlOEV5bUpYVm1IYklIeUE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); Response joinedCallConnectionAsyncResponse = callingServerAsyncClient.joinWithResponse( serverCallId, - new CommunicationUserIdentifier(joinedUser), + new CommunicationUserIdentifier(toUser), joinCallOptions).block(); CallingServerTestUtils.validateJoinCallConnectionAsyncResponse(joinedCallConnectionAsyncResponse); assert joinedCallConnectionAsyncResponse != null; diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java similarity index 84% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java index ed415db9f401..e11c66dd61d9 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java @@ -20,20 +20,10 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -/** - * Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to setup if tests are playback or - * live. By default, tests are run in playback mode. - */ -public class CallConnectionTests extends CallingServerTestBase { - - private String from = getRandomUserId(); - private String invitedUser = getRandomUserId(); - private String joinedUser = getRandomUserId(); - private String alternateId = "+11111111111"; - private String to = "+11111111111"; - private String callBackUri = "https://host.app/api/callback/calling"; - private String audioFileUri = "https://host.app/audio/bot-callcenter-intro.wav"; +public class CallConnectionLiveTests extends CallingServerTestBase { + private final String fromUser = getNewUserId(); + private final String toUser = getNewUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -44,15 +34,15 @@ public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options); CallingServerTestUtils.validateCallConnection(callConnection); @@ -60,7 +50,7 @@ public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { // Play Audio String playAudioOperationContext = UUID.randomUUID().toString(); PlayAudioResult playAudioResult = callConnection.playAudio( - audioFileUri, + AUDIO_FILE_URI, false, UUID.randomUUID().toString(), null, @@ -89,15 +79,15 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options, Context.NONE); @@ -108,7 +98,7 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) String operationContext = UUID.randomUUID().toString(); Response playAudioResult = callConnection.playAudioWithResponse( - audioFileUri, + AUDIO_FILE_URI, false, UUID.randomUUID().toString(), null, @@ -139,30 +129,30 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options); CallingServerTestUtils.validateCallConnection(callConnection); // Add User String operationContext = UUID.randomUUID().toString(); - callConnection.addParticipant(new CommunicationUserIdentifier(invitedUser), null, operationContext); + callConnection.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext); // Remove Participant - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. + */ String participantId = "f29f70e3-1eaf-44c0-839c-b4e8a74ffec3"; callConnection.removeParticipant(participantId); @@ -183,38 +173,38 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options, Context.NONE); CallingServerTestUtils.validateCallConnectionResponse(callConnectionResponse); CallConnection callConnection = callConnectionResponse.getValue(); - // Add User + // Add User String operationContext = UUID.randomUUID().toString(); Response inviteParticipantResponse = callConnection .addParticipantWithResponse( - new CommunicationUserIdentifier(invitedUser), + new CommunicationUserIdentifier(toUser), null, operationContext, Context.NONE); CallingServerTestUtils.validateResponse(inviteParticipantResponse); // Remove Participant - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. + */ String participantId = "71ed956b-366e-450c-9a61-3bbccf42baa5"; Response removeParticipantResponse = callConnection.removeParticipantWithResponse(participantId, Context.NONE); CallingServerTestUtils.validateResponse(removeParticipantResponse); @@ -237,31 +227,31 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { try { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, createCallOptions); CallingServerTestUtils.validateCallConnection(callConnection); // Join - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L2RUUjRPVGFxVzAyZ3cxVGpNSUNBdEE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); CallConnection joinedCallConnection = - callingServerClient.join(serverCallId, new CommunicationUserIdentifier(joinedUser), joinCallOptions); + callingServerClient.join(serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions); CallingServerTestUtils.validateCallConnection(joinedCallConnection); //Hangup @@ -282,15 +272,15 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { try { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( - new CommunicationUserIdentifier(from), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationUserIdentifier(fromUser), + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, createCallOptions, null); @@ -300,13 +290,13 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { // Join String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3dXZW9hNjAweGtPZ0d6eHE2eG1tQVE_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); Response joinedCallConnectionResponse = callingServerClient.joinWithResponse( serverCallId, - new CommunicationUserIdentifier(joinedUser), + new CommunicationUserIdentifier(toUser), joinCallOptions, null); CallingServerTestUtils.validateJoinCallConnectionResponse(joinedCallConnectionResponse); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderUnitTests.java similarity index 71% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderUnitTests.java index 4ba0e989aa06..7608722349ab 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerClientBuilderUnitTests.java @@ -2,13 +2,6 @@ // Licensed under the MIT License. package com.azure.communication.callingserver; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertThrows; - -import java.net.MalformedURLException; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; - import com.azure.communication.common.implementation.HmacAuthenticationPolicy; import com.azure.core.credential.AzureKeyCredential; import com.azure.core.credential.TokenCredential; @@ -19,12 +12,13 @@ import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.util.ClientOptions; import com.azure.identity.DefaultAzureCredentialBuilder; - import org.junit.jupiter.api.Test; - import reactor.core.publisher.Mono; -public class CallingServerClientBuilderTests { +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class CallingServerClientBuilderUnitTests { static final String MOCK_URL = "https://REDACTED.communication.azure.com"; static final String MOCK_ACCESS_KEY = "eyKfcHciOiJIUzI1NiIsInR5cCI6IkqXVCJ9eyJzdWIiOiIxMjM0NTY5ODkwIiwibmFtZSI7IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadUs4s5d"; static final String MOCK_CONNECTION_STRING = "endpoint=https://REDACTED.communication.azure.com/;accesskey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c"; @@ -40,75 +34,61 @@ public Mono send(HttpRequest request) { private final CallingServerClientBuilder builder = new CallingServerClientBuilder(); @Test - public void missingTokenCredentialTest() - throws NullPointerException, MalformedURLException, InvalidKeyException, NoSuchAlgorithmException { + public void missingTokenCredentialTest() throws NullPointerException { builder .endpoint(MOCK_URL) .httpClient(new NoOpHttpClient()); - assertThrows(Exception.class, () -> { - builder.buildAsyncClient(); - }); + assertThrows(Exception.class, builder::buildAsyncClient); } @Test public void missingUrlTest() - throws NullPointerException, MalformedURLException { + throws NullPointerException { builder .credential(new AzureKeyCredential(MOCK_ACCESS_KEY)) .httpClient(new NoOpHttpClient()); - assertThrows(Exception.class, () -> { - builder.buildAsyncClient(); - }); + assertThrows(Exception.class, builder::buildAsyncClient); } @Test public void nullPipelineTest() { - assertThrows(NullPointerException.class, () -> { - builder - .connectionString(MOCK_CONNECTION_STRING) - .httpClient(new NoOpHttpClient()) - .pipeline(null); - }); + assertThrows(NullPointerException.class, () -> builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .pipeline(null)); } @Test public void nullCustomPolicyTest() { - assertThrows(NullPointerException.class, () -> { - builder - .connectionString(MOCK_CONNECTION_STRING) - .httpClient(new NoOpHttpClient()) - .addPolicy(null); - }); + assertThrows(NullPointerException.class, () -> builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .addPolicy(null)); } @Test public void nullConfigurationTest() { - assertThrows(NullPointerException.class, () -> { - builder - .connectionString(MOCK_CONNECTION_STRING) - .httpClient(new NoOpHttpClient()) - .configuration(null); - }); + assertThrows(NullPointerException.class, () -> builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .configuration(null)); } @Test public void nullHttpLogOptionsTest() { - assertThrows(NullPointerException.class, () -> { - builder - .connectionString(MOCK_CONNECTION_STRING) - .httpClient(new NoOpHttpClient()) - .httpLogOptions(null); - }); + assertThrows(NullPointerException.class, () -> builder + .connectionString(MOCK_CONNECTION_STRING) + .httpClient(new NoOpHttpClient()) + .httpLogOptions(null)); } @Test public void nullRetryPolicyTest() { - assertThrows(NullPointerException.class, () -> { - builder + assertThrows( + NullPointerException.class, () -> builder .connectionString(MOCK_CONNECTION_STRING) .httpClient(new NoOpHttpClient()) - .retryPolicy(null); - }); + .retryPolicy(null)); } @Test @@ -155,7 +135,8 @@ public void noClientOptionsNoPipeline() { @Test public void addPolicy() { AzureKeyCredential credential = new AzureKeyCredential("key"); - CallingServerAsyncClient callAsyncClient = builder + CallingServerAsyncClient callAsyncClient = + builder .connectionString(MOCK_CONNECTION_STRING) .addPolicy(new HmacAuthenticationPolicy(credential)) .httpClient(new NoOpHttpClient()) @@ -166,50 +147,46 @@ public void addPolicy() { @Test public void argumentExceptionOnConnectionStringAndEndpoint() { - assertThrows(IllegalArgumentException.class, () -> { - builder + assertThrows(IllegalArgumentException.class, + () -> builder .connectionString(MOCK_CONNECTION_STRING) .endpoint(MOCK_URL) .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } @Test public void argumentExceptionOnConnectionStringAndAzureKeyCredential() { AzureKeyCredential credential = new AzureKeyCredential("key"); - assertThrows(IllegalArgumentException.class, () -> { - builder + assertThrows( + IllegalArgumentException.class, () -> builder .connectionString(MOCK_CONNECTION_STRING) .credential(credential) .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } @Test public void argumentExceptionOnConnectionStringAndTokenCredential() { TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); - assertThrows(IllegalArgumentException.class, () -> { - builder + assertThrows( + IllegalArgumentException.class, () -> builder .connectionString(MOCK_CONNECTION_STRING) .credential(tokenCredential) .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } @Test public void argumentExceptionOnAzureKeyCredentialAndTokenCredential() { AzureKeyCredential credential = new AzureKeyCredential("key"); TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); - assertThrows(IllegalArgumentException.class, () -> { - builder + assertThrows( + IllegalArgumentException.class, () -> builder .credential(credential) .credential(tokenCredential) .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } @Test @@ -226,21 +203,19 @@ public void noPipelineWithToken() { @Test public void noCredential() { - assertThrows(IllegalArgumentException.class, () -> { - builder + assertThrows( + IllegalArgumentException.class, () -> builder .endpoint(MOCK_URL) .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } @Test public void noEndpoint() { - assertThrows(NullPointerException.class, () -> { - builder + assertThrows( + NullPointerException.class, () -> builder .httpClient(new NoOpHttpClient()) - .buildAsyncClient(); - }); + .buildAsyncClient()); } } diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java index d7843cebd1ab..8b5dc4a70847 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestBase.java @@ -8,6 +8,8 @@ import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; +import com.azure.communication.identity.CommunicationIdentityClient; +import com.azure.communication.identity.CommunicationIdentityClientBuilder; import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; @@ -36,20 +38,44 @@ public class CallingServerTestBase extends TestBase { protected static final TestMode TEST_MODE = initializeTestMode(); protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration() - .get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", "endpoint=https://acstestbot1.communication.azure.com/;accesskey=E0Oy7HRSLiMFyuXHQA/9nOYZu2Fc0ia9DxhHtsGhtHuc2RTan24ZAmTjxl5etgZW/+O3pGrXiEpazT81u3quzg=="); + .get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", + "endpoint=https://acstestbot1.communication.azure.com/;accesskey=E0Oy7HRSLiMFyuXHQA/9nOYZu2Fc0ia9DxhHtsGhtHuc2RTan24ZAmTjxl5etgZW/+O3pGrXiEpazT81u3quzg=="); protected static final String RESOURCE_IDENTIFIER = Configuration.getGlobalConfiguration() - .get("COMMUNICATION_LIVETEST_STATIC_RESOURCE_IDENTIFIER", "016a7064-0581-40b9-be73-6dde64d69d72"); + .get("COMMUNICATION_LIVETEST_STATIC_RESOURCE_IDENTIFIER", + "016a7064-0581-40b9-be73-6dde64d69d72"); protected static final String GROUP_IDENTIFIER = Configuration.getGlobalConfiguration() - .get("COMMUNICATION_LIVETEST_STATIC_GROUP_IDENTIFIER", "c400789f-e11b-4ceb-88cb-bc8df2a01568"); + .get("COMMUNICATION_LIVETEST_STATIC_GROUP_IDENTIFIER", + "c400789f-e11b-4ceb-88cb-bc8df2a01568"); + + protected static final String FROM_PHONE_NUMBER = Configuration.getGlobalConfiguration() + .get("AZURE_PHONE_NUMBER", "+15551234567"); + + protected static final String TO_PHONE_NUMBER = Configuration.getGlobalConfiguration() + .get("AZURE_PHONE_NUMBER", "+15551234567"); + + protected static final String CALLBACK_URI = Configuration.getGlobalConfiguration() + .get("CALLBACK_URI", "https://host.app/api/callback/calling"); + + protected static final String AUDIO_FILE_URI = Configuration.getGlobalConfiguration() + .get("AUDIO_FILE_URI", "https://host.app/audio/bot-callcenter-intro.wav"); + + protected static final String METADATA_URL = Configuration.getGlobalConfiguration() + .get("METADATA_URL", "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/acsmetadata"); + + protected static final String VIDEO_URL = Configuration.getGlobalConfiguration() + .get("VIDEO_URL", "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/video"); + + protected static final String CONTENT_URL_404 = Configuration.getGlobalConfiguration() + .get("CONTENT_URL_404", "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141d/content/acsmetadata"); private static final StringJoiner JSON_PROPERTIES_TO_REDACT = new StringJoiner("\":\"|\"", "\"", "\":\"") .add("to"); private static final Pattern JSON_PROPERTY_VALUE_REDACTION_PATTERN - = Pattern.compile(String.format("(?:%s)(.*?)(?:\",|\"})", JSON_PROPERTIES_TO_REDACT.toString()), + = Pattern.compile(String.format("(?:%s)(.*?)(?:\",|\"})", JSON_PROPERTIES_TO_REDACT), Pattern.CASE_INSENSITIVE); protected CallingServerClientBuilder getCallClientUsingConnectionString(HttpClient httpClient) { @@ -65,23 +91,34 @@ protected CallingServerClientBuilder getCallClientUsingConnectionString(HttpClie return builder; } - protected String getRandomUserId() { - return "8:acs:" + RESOURCE_IDENTIFIER + "_" + UUID.randomUUID().toString(); + protected String getNewUserId() { + if (getTestMode() == TestMode.LIVE) { + CommunicationIdentityClient communicationIdentityClient = new CommunicationIdentityClientBuilder() + .connectionString(CONNECTION_STRING) + .buildClient(); + CommunicationUserIdentifier user = communicationIdentityClient.createUser(); + return user.getId(); + } + return getRandomUserId(); + } + + private String getRandomUserId() { + return "8:acs:" + RESOURCE_IDENTIFIER + "_" + UUID.randomUUID(); } protected String getGroupId() { - /** - * If tests are running in live mode, we want them to all - * have unique groupId's so they do not conflict with other - * recording tests running in live mode. + /* + If tests are running in live mode, we want them to all + have unique groupId's so they do not conflict with other + recording tests running in live mode. */ if (getTestMode() == TestMode.LIVE) { return UUID.randomUUID().toString(); } - /** - * For recording tests we need to make sure the groupId - * matches the recorded groupId, or the call will fail. + /* + For recording tests we need to make sure the groupId + matches the recorded groupId, or the call will fail. */ return GROUP_IDENTIFIER; } @@ -121,14 +158,18 @@ protected Mono logHeaders(String testName, HttpPipelineNextPolicy .flatMap(httpResponse -> { final HttpResponse bufferedResponse = httpResponse.buffer(); - // Should sanitize printed reponse url + /* Should sanitize printed response url */ System.out.println("Chain-ID header for " + testName + " request " + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("X-Microsoft-Skype-Chain-ID")); return Mono.just(bufferedResponse); }); } - protected List createCall(CallingServerClient callingServerClient, String groupId, String from, String to, String callBackUri) { + protected List createCall(CallingServerClient callingServerClient, + String groupId, + String from, + String to, + String callBackUri) { CallConnection fromCallConnection = null; CallConnection toCallConnection = null; @@ -168,8 +209,12 @@ protected List createCall(CallingServerClient callingServerClien throw e; } } - - protected List createAsyncCall(CallingServerAsyncClient callingServerClient, String groupId, String from, String to, String callBackUri) { + + protected List createAsyncCall(CallingServerAsyncClient callingServerClient, + String groupId, + String from, + String to, + String callBackUri) { CallConnectionAsync fromCallConnection = null; CallConnectionAsync toCallConnection = null; diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestUtils.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestUtils.java index 408eb0b8166b..c12b740b9517 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestUtils.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallingServerTestUtils.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -8,7 +9,6 @@ import static org.junit.jupiter.api.Assertions.assertSame; import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult; -import com.azure.communication.callingserver.models.JoinCallResult; import com.azure.communication.callingserver.models.OperationStatus; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.core.http.rest.Response; @@ -55,12 +55,6 @@ protected static void validateCallConnectionAsync(CallConnectionAsync callConnec assertFalse(callConnectionAsync.getCallConnectionId().isEmpty()); } - protected static void validateJoinCall(JoinCallResult joinCallResult) { - assertNotNull(joinCallResult); - assertNotNull(joinCallResult.getCallConnectionId()); - assertFalse(joinCallResult.getCallConnectionId().isEmpty()); - } - protected static void validatePlayAudioResponse(Response playAudioResponse) { assertNotNull(playAudioResponse); Assertions.assertEquals(202, playAudioResponse.getStatusCode()); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java similarity index 91% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java index 095fb2140bca..a89f93d7384e 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import com.azure.communication.callingserver.models.CallingServerErrorException; @@ -29,15 +30,7 @@ import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.times; -/** - * Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to determine if tests are playback or - * live. By default, tests are run in playback mode. - * These tests will not run in LIVE or RECORD as they cannot get the content url. - */ -public class DownloadContentAsyncTests extends CallingServerTestBase { - private static final String METADATA_URL = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/acsmetadata"; - private static final String VIDEO_URL = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/video"; - private static final String CONTENT_URL_404 = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141d/content/acsmetadata"; +public class DownloadContentAsyncLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java similarity index 65% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java index eda2d92fdc09..1779a89a60a2 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentLiveTests.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import com.azure.communication.callingserver.models.CallingServerErrorException; @@ -22,15 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.doThrow; -/** - * Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to determine if tests are playback or - * live. By default, tests are run in playback mode. - * These tests will not run in LIVE or RECORD as they cannot get the content url. - */ -public class DownloadContentTests extends CallingServerTestBase { - private static final String METADATA_URL = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/acsmetadata"; - private static final String VIDEO_URL = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141c/content/video"; - private static final String CONTENT_URL_404 = "https://storage.asm.skype.com/v1/objects/0-eus-d2-3cca2175891f21c6c9a5975a12c0141d/content/acsmetadata"; +public class DownloadContentLiveTests extends CallingServerTestBase { @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -39,9 +32,9 @@ public void downloadMetadata(HttpClient httpClient) { CallingServerClient conversationClient = setupClient(builder, "downloadMetadata"); try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - conversationClient.downloadTo(METADATA_URL, baos, null); - String metadata = new String(baos.toByteArray(), StandardCharsets.UTF_8); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + conversationClient.downloadTo(METADATA_URL, byteArrayOutputStream, null); + String metadata = byteArrayOutputStream.toString(StandardCharsets.UTF_8); assertThat(metadata.contains("0-eus-d2-3cca2175891f21c6c9a5975a12c0141c"), is(true)); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -56,12 +49,16 @@ public void downloadVideo(HttpClient httpClient) { CallingServerClient conversationClient = setupClient(builder, "downloadVideo"); try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Response response = conversationClient - .downloadToWithResponse(VIDEO_URL, baos, null, null); + .downloadToWithResponse(VIDEO_URL, byteArrayOutputStream, null, null); assertThat(response, is(notNullValue())); - assertThat(response.getHeaders().getValue("Content-Type"), is(equalTo("application/octet-stream"))); - assertThat(Integer.parseInt(response.getHeaders().getValue("Content-Length")), is(equalTo(baos.size()))); + assertThat( + response.getHeaders().getValue("Content-Type"), + is(equalTo("application/octet-stream"))); + assertThat( + Integer.parseInt(response.getHeaders().getValue("Content-Length")), + is(equalTo(byteArrayOutputStream.size()))); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); throw e; @@ -74,10 +71,10 @@ public void downloadContent404(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); CallingServerErrorException ex = assertThrows(CallingServerErrorException.class, () -> conversationClient - .downloadTo(CONTENT_URL_404, baos, null)); + .downloadTo(CONTENT_URL_404, byteArrayOutputStream, null)); assertThat(ex.getResponse().getStatusCode(), is(equalTo(404))); } @@ -87,10 +84,12 @@ public void downloadContentWrongUrl(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - IllegalArgumentException ex = assertThrows(IllegalArgumentException.class, - () -> conversationClient - .downloadTo("wrongurl", baos, null)); + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + IllegalArgumentException ex = + assertThrows( + IllegalArgumentException.class, + () -> conversationClient + .downloadTo("wrongurl", byteArrayOutputStream, null)); assertThat(ex, is(notNullValue())); } @@ -100,11 +99,12 @@ public void downloadContentStreamFailure(HttpClient httpClient) throws IOExcepti CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient conversationClient = setupClient(builder, "downloadContent404"); - ByteArrayOutputStream baos = Mockito.mock(ByteArrayOutputStream.class); - doThrow(IOException.class).when(baos).write(Mockito.any()); - assertThrows(UncheckedIOException.class, + ByteArrayOutputStream byteArrayOutputStream = Mockito.mock(ByteArrayOutputStream.class); + doThrow(IOException.class).when(byteArrayOutputStream).write(Mockito.any()); + assertThrows( + UncheckedIOException.class, () -> conversationClient - .downloadTo(METADATA_URL, baos, null)); + .downloadTo(METADATA_URL, byteArrayOutputStream, null)); } private CallingServerClient setupClient(CallingServerClientBuilder builder, String testName) { diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java similarity index 86% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java index 95661032d9e0..ddd7527a2fbb 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -26,15 +27,11 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -public class ServerCallAsyncTests extends CallingServerTestBase { - // Calling Tests - private String groupId = getGroupId(); - private String fromUser = getRandomUserId(); - private String toUser = getRandomUserId(); - private String alternateId = "+11111111111"; - private String to = "+11111111111"; - private String callBackUri = "https://host.app/api/callback/calling"; - private String audioFileUri = "https://host.app/audio/bot-callcenter-intro.wav"; +public class ServerCallAsyncLiveTests extends CallingServerTestBase { + + private final String groupId = getGroupId(); + private final String fromUser = getNewUserId(); + private final String toUser = getNewUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -46,10 +43,10 @@ public void runAllClientFunctionsAsync(HttpClient httpClient) { ServerCallAsync serverCall = null; try { - callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, callBackUri); + callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, CALLBACK_URI); serverCall = callingServerAsyncClient.initializeServerCall(groupId); - StartCallRecordingResult startCallRecordingResult = serverCall.startRecording(callBackUri).block(); + StartCallRecordingResult startCallRecordingResult = serverCall.startRecording(CALLBACK_URI).block(); assert startCallRecordingResult != null; recordingId = startCallRecordingResult.getRecordingId(); validateCallRecordingState(serverCall, recordingId, CallRecordingState.ACTIVE); @@ -85,10 +82,10 @@ public void runAllClientFunctionsWithResponseAsync(HttpClient httpClient) { ServerCallAsync serverCallAsync = null; try { - callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, callBackUri); + callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, CALLBACK_URI); serverCallAsync = callingServerAsyncClient.initializeServerCall(groupId); - Response startRecordingResponse = serverCallAsync.startRecordingWithResponse(callBackUri).block(); + Response startRecordingResponse = serverCallAsync.startRecordingWithResponse(CALLBACK_URI).block(); assert startRecordingResponse != null; assertEquals(startRecordingResponse.getStatusCode(), 200); StartCallRecordingResult startCallRecordingResult = startRecordingResponse.getValue(); @@ -127,16 +124,16 @@ public void runAllClientFunctionsWithResponseAsync(HttpClient httpClient) { public void runPlayAudioFunctionAsync(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerAsyncClient callingServerAsyncClient = setupAsyncClient(builder, "runPlayAudioFunctionAsync"); - ServerCallAsync serverCallAsync = null; + ServerCallAsync serverCallAsync; List callConnections = new ArrayList<>(); String operationContext = UUID.randomUUID().toString(); try { - callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, callBackUri); + callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, CALLBACK_URI); serverCallAsync = callingServerAsyncClient.initializeServerCall(groupId); - PlayAudioResult playAudioResult = serverCallAsync.playAudio(audioFileUri, operationContext, callBackUri, operationContext).block(); + PlayAudioResult playAudioResult = serverCallAsync.playAudio(AUDIO_FILE_URI, operationContext, CALLBACK_URI, operationContext).block(); CallingServerTestUtils.validatePlayAudioResult(playAudioResult); } catch (Exception e) { @@ -152,16 +149,16 @@ public void runPlayAudioFunctionAsync(HttpClient httpClient) { public void runPlayAudioFunctionWithResponseAsync(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerAsyncClient callingServerAsyncClient = setupAsyncClient(builder, "runPlayAudioFunctionWithResponseAsync"); - ServerCallAsync serverCallAsync = null; + ServerCallAsync serverCallAsync; List callConnections = new ArrayList<>(); String operationContext = UUID.randomUUID().toString(); try { - callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, callBackUri); + callConnections = createAsyncCall(callingServerAsyncClient, groupId, fromUser, toUser, CALLBACK_URI); serverCallAsync = callingServerAsyncClient.initializeServerCall(groupId); - Response playAudioResult = serverCallAsync.playAudioWithResponse(audioFileUri, operationContext, callBackUri, operationContext).block(); + Response playAudioResult = serverCallAsync.playAudioWithResponse(AUDIO_FILE_URI, operationContext, CALLBACK_URI, operationContext).block(); CallingServerTestUtils.validatePlayAudioResponse(playAudioResult); } catch (Exception e) { @@ -181,7 +178,7 @@ public void startRecordingFailsAsync(HttpClient httpClient) { ServerCallAsync serverCallAsync = callingServerAsyncClient.initializeServerCall(invalidServerCallId); try { - Response response = serverCallAsync.startRecordingWithResponse(callBackUri).block(); + Response response = serverCallAsync.startRecordingWithResponse(CALLBACK_URI).block(); assert response != null; assertEquals(response.getStatusCode(), 400); } catch (CallingServerErrorException e) { @@ -193,43 +190,43 @@ public void startRecordingFailsAsync(HttpClient httpClient) { @MethodSource("com.azure.core.test.TestBase#getHttpClients") public void runAddRemoveScenarioAsync(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); - CallingServerAsyncClient callingServerAsyncClient = setupAsyncClient(builder, "runAddRemoveScenarioAsync"); + CallingServerAsyncClient callingServerAsyncClient = setupAsyncClient(builder, "runAddRemoveScenarioAsync"); try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); // Get Server Call - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() - */ + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() + */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3NXdWxkazBmMEVpdnAxWjhiU2NuUHc_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; ServerCallAsync serverCallAsync = callingServerAsyncClient.initializeServerCall(serverCallId); // Add User String operationContext = UUID.randomUUID().toString(); - serverCallAsync.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext, callBackUri).block(); + serverCallAsync.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext, CALLBACK_URI).block(); // Remove User - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. + */ String participantId = "206ac04a-1aae-4d82-9015-9c30cb174888"; serverCallAsync.removeParticipant(participantId).block(); @@ -251,39 +248,39 @@ public void runAddRemoveScenarioWithResponseAsync(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); // Get Server Call - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() - */ + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() + */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L0NUT014YmNIRmttZ1BqbE5kYjExNlE_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; ServerCallAsync serverCallAsync = callingServerAsyncClient.initializeServerCall(serverCallId); // Add User String operationContext = UUID.randomUUID().toString(); - Response addResponse = serverCallAsync.addParticipantWithResponse(new CommunicationUserIdentifier(toUser), null, operationContext, callBackUri).block(); + Response addResponse = serverCallAsync.addParticipantWithResponse(new CommunicationUserIdentifier(toUser), null, operationContext, CALLBACK_URI).block(); CallingServerTestUtils.validateResponse(addResponse); // Remove User - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. + */ String participantId = "b133b1f3-4a11-49e4-abe0-ac9fdd660634"; Response removeResponse = serverCallAsync.removeParticipantWithResponse(participantId).block(); CallingServerTestUtils.validateResponse(removeResponse); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java similarity index 81% rename from sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallTests.java rename to sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java index b32f76741fab..457ab0e6c1ff 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java @@ -1,7 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; +import static com.azure.communication.callingserver.CallingServerTestUtils.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -27,16 +29,11 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -public class ServerCallTests extends CallingServerTestBase { +public class ServerCallLiveTests extends CallingServerTestBase { - // Calling Tests - private String groupId = getGroupId(); - private String fromUser = getRandomUserId(); - private String toUser = getRandomUserId(); - private String alternateId = "+11111111111"; - private String to = "+11111111111"; - private String callBackUri = "https://host.app/api/callback/calling"; - private String audioFileUri = "https://host.app/audio/bot-callcenter-intro.wav"; + private final String groupId = getGroupId(); + private final String fromUser = getNewUserId(); + private final String toUser = getNewUserId(); @ParameterizedTest @MethodSource("com.azure.core.test.TestBase#getHttpClients") @@ -48,10 +45,10 @@ public void runAllClientFunctions(HttpClient httpClient) { ServerCall serverCall = null; try { - callConnections = createCall(callingServerClient, groupId, fromUser, toUser, callBackUri); + callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); serverCall = callingServerClient.initializeServerCall(groupId); - StartCallRecordingResult startCallRecordingResult = serverCall.startRecording(callBackUri); + StartCallRecordingResult startCallRecordingResult = serverCall.startRecording(CALLBACK_URI); recordingId = startCallRecordingResult.getRecordingId(); validateCallRecordingState(serverCall, recordingId, CallRecordingState.ACTIVE); @@ -86,10 +83,11 @@ public void runAllClientFunctionsWithResponse(HttpClient httpClient) { ServerCall serverCall = null; try { - callConnections = createCall(callingServerClient, groupId, fromUser, toUser, callBackUri); + callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); serverCall = callingServerClient.initializeServerCall(groupId); - Response startRecordingResponse = serverCall.startRecordingWithResponse(callBackUri, null); + Response startRecordingResponse = + serverCall.startRecordingWithResponse(CALLBACK_URI, null); assertEquals(startRecordingResponse.getStatusCode(), 200); StartCallRecordingResult startCallRecordingResult = startRecordingResponse.getValue(); recordingId = startCallRecordingResult.getRecordingId(); @@ -124,17 +122,18 @@ public void runAllClientFunctionsWithResponse(HttpClient httpClient) { public void runPlayAudioFunction(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient callingServerClient = setupClient(builder, "runPlayAudioFunction"); - ServerCall serverCall = null; + ServerCall serverCall; List callConnections = new ArrayList<>(); String operationContext = UUID.randomUUID().toString(); try { - callConnections = createCall(callingServerClient, groupId, fromUser, toUser, callBackUri); + callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); serverCall = callingServerClient.initializeServerCall(groupId); - PlayAudioResult playAudioResult = serverCall.playAudio(audioFileUri, UUID.randomUUID().toString(), callBackUri, operationContext); - CallingServerTestUtils.validatePlayAudioResult(playAudioResult); + PlayAudioResult playAudioResult = + serverCall.playAudio(AUDIO_FILE_URI, UUID.randomUUID().toString(), CALLBACK_URI, operationContext); + validatePlayAudioResult(playAudioResult); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -149,17 +148,21 @@ public void runPlayAudioFunction(HttpClient httpClient) { public void runPlayAudioFunctionWithResponse(HttpClient httpClient) { CallingServerClientBuilder builder = getConversationClientUsingConnectionString(httpClient); CallingServerClient callingServerClient = setupClient(builder, "runPlayAudioFunctionWithResponse"); - ServerCall serverCall = null; + ServerCall serverCall; List callConnections = new ArrayList<>(); String operationContext = UUID.randomUUID().toString(); try { - callConnections = createCall(callingServerClient, groupId, fromUser, toUser, callBackUri); + callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); serverCall = callingServerClient.initializeServerCall(groupId); - Response playAudioResult = serverCall.playAudioWithResponse(audioFileUri, operationContext, callBackUri, operationContext, null); - CallingServerTestUtils.validatePlayAudioResponse(playAudioResult); + Response playAudioResult = + serverCall.playAudioWithResponse( + AUDIO_FILE_URI, operationContext, + CALLBACK_URI, operationContext, + null); + validatePlayAudioResponse(playAudioResult); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -178,7 +181,8 @@ public void startRecordingFails(HttpClient httpClient) { ServerCall serverCall = callingServerClient.initializeServerCall(invalidServerCallId); try { - Response response = serverCall.startRecordingWithResponse(callBackUri, Context.NONE); + Response response = + serverCall.startRecordingWithResponse(CALLBACK_URI, Context.NONE); assertEquals(response.getStatusCode(), 400); } catch (CallingServerErrorException e) { assertEquals(e.getResponse().getStatusCode(), 400); @@ -193,37 +197,37 @@ public void runAddRemoveScenario(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options); - CallingServerTestUtils.validateCallConnection(callConnection); + validateCallConnection(callConnection); // Get Server Call - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() - */ + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() + */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L1ktWjZ5dzFzWVVTUUdWX2xPQWk1X2c_aT0xJmU9NjM3NTg0MzkzMzg3ODg3MDI3"; ServerCall serverCall = callingServerClient.initializeServerCall(serverCallId); // Add User String operationContext = UUID.randomUUID().toString(); - serverCall.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext, callBackUri); + serverCall.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext, CALLBACK_URI); // Remove User - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + value needs to be used. */ String participantId = "72647661-033a-4d1a-b858-465375977be0"; serverCall.removeParticipant(participantId); @@ -245,42 +249,47 @@ public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { try { // Establish a call CreateCallOptions options = new CreateCallOptions( - callBackUri, + CALLBACK_URI, new CallModality[] { CallModality.AUDIO }, new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - options.setAlternateCallerId(new PhoneNumberIdentifier(alternateId)); + options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) }, + new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options); - CallingServerTestUtils.validateCallConnection(callConnection); + validateCallConnection(callConnection); // Get Server Call - /** - * Waiting for an upate to beable to get this serverCallId when using - * createCallConnection() - */ + /* + Waiting for an update to be able to get this serverCallId when using + createCallConnection() + */ String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L1lXS2R2TTNRc0Vpc0VNYVUtNlhvSlE_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; ServerCall serverCall = callingServerClient.initializeServerCall(serverCallId); // Add User String operationContext = UUID.randomUUID().toString(); - Response addResponse = serverCall.addParticipantWithResponse(new CommunicationUserIdentifier(toUser), null, operationContext, callBackUri, Context.NONE); - CallingServerTestUtils.validateResponse(addResponse); + Response addResponse = + serverCall.addParticipantWithResponse( + new CommunicationUserIdentifier(toUser), + null, + operationContext, CALLBACK_URI, + Context.NONE); + validateResponse(addResponse); // Remove User - /** - * There is an update that we require to beable to get - * the participantId from the service when a user is - * added to a call. Until that is fixed this recorded - * valuse needs to be used. - */ + /* + There is an update that we require to be able to get + the participantId from the service when a user is + added to a call. Until that is fixed this recorded + values needs to be used. + */ String participantId = "76b33acb-5097-4af0-a646-e07ccee48957"; Response removeResponse = serverCall.removeParticipantWithResponse(participantId, Context.NONE); - CallingServerTestUtils.validateResponse(removeResponse); + validateResponse(removeResponse); // Hangup callConnection.hangup(); @@ -327,7 +336,8 @@ protected void validateCallRecordingStateWithResponse(ServerCall serverCall, // against a live service. sleepIfRunningAgainstService(6000); - Response response = serverCall.getRecordingStateWithResponse(recordingId, Context.NONE); + Response response = + serverCall.getRecordingStateWithResponse(recordingId, Context.NONE); assertNotNull(response); assertEquals(response.getStatusCode(), 200); assertNotNull(response.getValue()); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallUnitTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallUnitTests.java index d879b5136328..fed5de9b498e 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallUnitTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallUnitTests.java @@ -1,28 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package com.azure.communication.callingserver; import static org.junit.jupiter.api.Assertions.assertThrows; - import java.security.InvalidParameterException; - import com.azure.core.test.http.NoOpHttpClient; - import org.junit.jupiter.api.Test; -/** - * Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to determine if tests are playback or - * live. By default, tests are run in playback mode. The runAllClientFunctions and runAllClientFunctionsWithResponse - * test will not run in LIVE or RECORD as they cannot get their own conversationId. - */ public class ServerCallUnitTests { - private String serverCallId = "aHR0cHM6Ly9jb252LXVzd2UtMDguY29udi5za3lwZS5jb20vY29udi8tby1FWjVpMHJrS3RFTDBNd0FST1J3P2k9ODgmZT02Mzc1Nzc0MTY4MDc4MjQyOTM"; - // Calling Tests - static final String MOCK_URL = "https://REDACTED.communication.azure.com"; - static final String MOCK_ACCESS_KEY = "eyKfcHciOiJIUzI1NiIsInR5cCI6IkqXVCJ9eyJzdWIiOiIxMjM0NTY5ODkwIiwibmFtZSI7IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadUs4s5d"; + private final String serverCallId = "aHR0cHM6Ly9jb252LXVzd2UtMDguY29udi5za3lwZS5jb20vY29udi8tby1FWjVpMHJrS3RFTDBNd0FST1J3P2k9ODgmZT02Mzc1Nzc0MTY4MDc4MjQyOTM"; static final String MOCK_CONNECTION_STRING = "endpoint=https://REDACTED.communication.azure.com/;accesskey=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaGfQSflKxwRJSMeKKF2QT4fwpMeJf36POk6yJVadQssw5c"; - private static final String APPLICATION_ID = "833bad32-4432-4d41-8bb4"; @Test public void startRecordingRelativeUriFails() { @@ -32,9 +21,9 @@ public void startRecordingRelativeUriFails() { .buildClient() .initializeServerCall(serverCallId); - assertThrows(InvalidParameterException.class, () -> { - serverCall.startRecording("/not/absolute/uri"); - }); + assertThrows( + InvalidParameterException.class, + () -> serverCall.startRecording("/not/absolute/uri")); } @Test @@ -45,9 +34,9 @@ public void startRecordingWithResponseRelativeUriFails() { .buildClient() .initializeServerCall(serverCallId); - assertThrows(InvalidParameterException.class, () -> { - serverCall.startRecordingWithResponse("/not/absolute/uri", null); - }); + assertThrows( + InvalidParameterException.class, + () -> serverCall.startRecordingWithResponse("/not/absolute/uri", null)); } @Test @@ -58,9 +47,9 @@ public void addParticipantNullParticipantFails() { .buildClient() .initializeServerCall(serverCallId); - assertThrows(NullPointerException.class, () -> { - serverCall.addParticipant(null, null, null, null); - }); + assertThrows( + NullPointerException.class, + () -> serverCall.addParticipant(null, null, null, null)); } @Test @@ -71,9 +60,9 @@ public void removeParticipantNullParticipantFails() { .buildClient() .initializeServerCall(serverCallId); - assertThrows(NullPointerException.class, () -> { - serverCall.removeParticipant(null); - }); + assertThrows( + NullPointerException.class, + () -> serverCall.removeParticipant(null)); } @Test @@ -84,8 +73,9 @@ public void startRecordingAsyncFails() { .buildAsyncClient() .initializeServerCall(serverCallId); - assertThrows(InvalidParameterException.class, () -> { - serverCall.startRecording("/not/absolute/uri").block(); - }); - } + assertThrows( + InvalidParameterException.class, + () -> serverCall.startRecording("/not/absolute/uri") + .block()); + } } diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateAddRemoveHangupScenarioWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateJoinHangupScenarioAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateJoinHangupScenarioAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateJoinHangupScenarioWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreateJoinHangupScenarioWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreateJoinHangupScenarioWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionAsyncLiveTests.runCreatePlayCancelHangupScenarioWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateAddRemoveHangupScenarioWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateAddRemoveHangupScenarioWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateAddRemoveHangupScenarioWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateAddRemoveHangupScenarioWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateAddRemoveHangupScenario[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateAddRemoveHangupScenario[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateAddRemoveHangupScenario[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateAddRemoveHangupScenario[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateJoinHangupScenarioWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateJoinHangupScenarioWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateJoinHangupScenarioWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateJoinHangupScenarioWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateJoinHangupScenario[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateJoinHangupScenario[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreateJoinHangupScenario[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreateJoinHangupScenario[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreatePlayCancelHangupScenarioWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreatePlayCancelHangupScenarioWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreatePlayCancelHangupScenarioWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreatePlayCancelHangupScenarioWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreatePlayCancelHangupScenario[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreatePlayCancelHangupScenario[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionTests.runCreatePlayCancelHangupScenario[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/CallConnectionLiveTests.runCreatePlayCancelHangupScenario[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadContent404Async[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadContent404Async[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadContent404Async[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadContent404Async[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataRetryingAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataRetryingAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataRetryingAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataRetryingAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataToStreamAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataToStreamAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadMetadataToStreamAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadMetadataToStreamAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadToFileAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadToFileAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadToFileAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadToFileAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadToFileRetryingAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadToFileRetryingAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadToFileRetryingAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadToFileRetryingAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadVideoAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadVideoAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncTests.downloadVideoAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentAsyncLiveTests.downloadVideoAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContent404[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContent404[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContent404[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContent404[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContentStreamFailure[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContentStreamFailure[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContentStreamFailure[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContentStreamFailure[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContentWrongUrl[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContentWrongUrl[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadContentWrongUrl[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadContentWrongUrl[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadMetadataStreaming[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadMetadataStreaming[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadMetadataStreaming[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadMetadataStreaming[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadMetadata[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadMetadata[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadMetadata[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadMetadata[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadVideo[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadVideo[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentTests.downloadVideo[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/DownloadContentLiveTests.downloadVideo[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAddRemoveScenarioAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAddRemoveScenarioAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAddRemoveScenarioAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAddRemoveScenarioAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAddRemoveScenarioWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAddRemoveScenarioWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAddRemoveScenarioWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAddRemoveScenarioWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAllClientFunctionsAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAllClientFunctionsAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAllClientFunctionsAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAllClientFunctionsAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAllClientFunctionsWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAllClientFunctionsWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runAllClientFunctionsWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runAllClientFunctionsWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runPlayAudioFunctionAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runPlayAudioFunctionAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runPlayAudioFunctionAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runPlayAudioFunctionAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runPlayAudioFunctionWithResponseAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runPlayAudioFunctionWithResponseAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.runPlayAudioFunctionWithResponseAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.runPlayAudioFunctionWithResponseAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.startRecordingFailsAsync[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.startRecordingFailsAsync[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncTests.startRecordingFailsAsync[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallAsyncLiveTests.startRecordingFailsAsync[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAddRemoveScenarioWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAddRemoveScenarioWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAddRemoveScenarioWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAddRemoveScenarioWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAddRemoveScenario[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAddRemoveScenario[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAddRemoveScenario[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAddRemoveScenario[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAllClientFunctionsWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAllClientFunctionsWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAllClientFunctionsWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAllClientFunctionsWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAllClientFunctions[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAllClientFunctions[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runAllClientFunctions[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runAllClientFunctions[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runPlayAudioFunctionWithResponse[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runPlayAudioFunctionWithResponse[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runPlayAudioFunctionWithResponse[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runPlayAudioFunctionWithResponse[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runPlayAudioFunction[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runPlayAudioFunction[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.runPlayAudioFunction[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.runPlayAudioFunction[1].json diff --git a/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.startRecordingFails[1].json b/sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.startRecordingFails[1].json similarity index 100% rename from sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallTests.startRecordingFails[1].json rename to sdk/communication/azure-communication-callingserver/src/test/resources/session-records/ServerCallLiveTests.startRecordingFails[1].json