diff --git a/sdk/communication/azure-communication-callingserver/pom.xml b/sdk/communication/azure-communication-callingserver/pom.xml index e452b3940a8e..71903ce125dc 100644 --- a/sdk/communication/azure-communication-callingserver/pom.xml +++ b/sdk/communication/azure-communication-callingserver/pom.xml @@ -42,7 +42,7 @@ src/test 0.70 0.70 - false + true diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java index 2db6c38022df..d618e563bd28 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnectionAsync.java @@ -165,7 +165,7 @@ public Mono> playAudioWithResponse( audioFileId, callbackUri, operationContext, - Context.NONE); + null); } /** @@ -181,7 +181,7 @@ public Mono> playAudioWithResponse( public Mono> playAudioWithResponse( String audioFileUri, PlayAudioOptions playAudioOptions) { - return playAudioWithResponseInternal(audioFileUri, playAudioOptions, Context.NONE); + return playAudioWithResponseInternal(audioFileUri, playAudioOptions, null); } Mono> playAudioWithResponseInternal( @@ -267,7 +267,7 @@ public Mono hangup() { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> hangupWithResponse() { - return hangupWithResponse(Context.NONE); + return hangupWithResponse(null); } Mono> hangupWithResponse(Context context) { @@ -311,7 +311,7 @@ public Mono cancelAllMediaOperations(String oper */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> cancelAllMediaOperationsWithResponse(String operationContext) { - return cancelAllMediaOperationsWithResponse(operationContext, Context.NONE); + return cancelAllMediaOperationsWithResponse(operationContext, null); } Mono> cancelAllMediaOperationsWithResponse( @@ -374,7 +374,7 @@ public Mono> addParticipantWithResponse( CommunicationIdentifier participant, String alternateCallerId, String operationContext) { - return addParticipantWithResponse(participant, alternateCallerId, operationContext, Context.NONE); + return addParticipantWithResponse(participant, alternateCallerId, operationContext, null); } Mono> addParticipantWithResponse( @@ -407,7 +407,6 @@ Mono> addParticipantWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Mono removeParticipant(String participantId) { try { - Objects.requireNonNull(participantId, "'participantId' cannot be null."); return callConnectionInternal.removeParticipantAsync(callConnectionId, participantId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException); } catch (RuntimeException ex) { @@ -423,12 +422,11 @@ public Mono removeParticipant(String participantId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> removeParticipantWithResponse(String participantId) { - return removeParticipantWithResponse(participantId, Context.NONE); + return removeParticipantWithResponse(participantId, null); } Mono> removeParticipantWithResponse(String participantId, Context context) { try { - Objects.requireNonNull(participantId, "'participantId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return callConnectionInternal diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java index 0560345daeed..eb8a1d240a9d 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerAsyncClient.java @@ -176,7 +176,6 @@ public Mono join( CommunicationIdentifier source, JoinCallOptions joinCallOptions) { try { - Objects.requireNonNull(serverCallId, "'serverCallId' cannot be null."); Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); return serverCallInternal @@ -202,7 +201,6 @@ public Mono join( CommunicationIdentifier source, JoinCallOptions joinCallOptions) { try { - Objects.requireNonNull(serverCallId, "'serverCallId' cannot be null."); Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); return serverCallInternal. @@ -220,7 +218,6 @@ Mono joinInternal( CommunicationIdentifier source, JoinCallOptions joinCallOptions) { try { - Objects.requireNonNull(serverCallId, "'serverCallId' cannot be null."); Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); return serverCallInternal @@ -234,14 +231,12 @@ Mono joinInternal( } } - Mono>joinWithResponseInternal( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions, Context context) { try { - Objects.requireNonNull(serverCallId, "'serverCallId' cannot be null."); Objects.requireNonNull(source, "'source' cannot be null."); Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null."); diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java index 60b20e80b20f..067bec9db3ba 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCallAsync.java @@ -104,7 +104,7 @@ public Mono> addParticipantWithResponse( callBackUri, alternateCallerId, operationContext, - Context.NONE); + null); } Mono> addParticipantWithResponse( @@ -140,7 +140,6 @@ Mono> addParticipantWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Mono removeParticipant(String participantId) { try { - Objects.requireNonNull(participantId, "'participantId' cannot be null."); return serverCallInternal.removeParticipantAsync(serverCallId, participantId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException); } catch (RuntimeException ex) { @@ -156,12 +155,11 @@ public Mono removeParticipant(String participantId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> removeParticipantWithResponse(String participantId) { - return removeParticipantWithResponse(participantId, Context.NONE); + return removeParticipantWithResponse(participantId, null); } Mono> removeParticipantWithResponse(String participantId, Context context) { try { - Objects.requireNonNull(participantId, "'participantId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return serverCallInternal @@ -208,7 +206,7 @@ public Mono startRecording(String recordingStateCallba */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> startRecordingWithResponse(String recordingStateCallbackUri) { - return startRecordingWithResponse(recordingStateCallbackUri, Context.NONE); + return startRecordingWithResponse(recordingStateCallbackUri, null); } Mono> startRecordingWithResponse( @@ -245,7 +243,6 @@ Mono> startRecordingWithResponse( @ServiceMethod(returns = ReturnType.SINGLE) public Mono stopRecording(String recordingId) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return serverCallInternal.stopRecordingAsync(serverCallId, recordingId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException); } catch (RuntimeException ex) { @@ -261,12 +258,11 @@ public Mono stopRecording(String recordingId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> stopRecordingWithResponse(String recordingId) { - return stopRecordingWithResponse(recordingId, Context.NONE); + return stopRecordingWithResponse(recordingId, null); } Mono> stopRecordingWithResponse(String recordingId, Context context) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return serverCallInternal @@ -287,7 +283,6 @@ Mono> stopRecordingWithResponse(String recordingId, Context conte @ServiceMethod(returns = ReturnType.SINGLE) public Mono pauseRecording(String recordingId) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return serverCallInternal.pauseRecordingAsync(serverCallId, recordingId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException); } catch (RuntimeException ex) { @@ -303,12 +298,11 @@ public Mono pauseRecording(String recordingId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> pauseRecordingWithResponse(String recordingId) { - return pauseRecordingWithResponse(recordingId, Context.NONE); + return pauseRecordingWithResponse(recordingId, null); } Mono> pauseRecordingWithResponse(String recordingId, Context context) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return serverCallInternal @@ -329,7 +323,6 @@ Mono> pauseRecordingWithResponse(String recordingId, Context cont @ServiceMethod(returns = ReturnType.SINGLE) public Mono resumeRecording(String recordingId) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return serverCallInternal.resumeRecordingAsync(serverCallId, recordingId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException); } catch (RuntimeException ex) { @@ -345,12 +338,11 @@ public Mono resumeRecording(String recordingId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> resumeRecordingWithResponse(String recordingId) { - return resumeRecordingWithResponse(recordingId, Context.NONE); + return resumeRecordingWithResponse(recordingId, null); } Mono> resumeRecordingWithResponse(String recordingId, Context context) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return serverCallInternal @@ -371,7 +363,6 @@ Mono> resumeRecordingWithResponse(String recordingId, Context con @ServiceMethod(returns = ReturnType.SINGLE) public Mono getRecordingState(String recordingId) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return serverCallInternal.recordingStateAsync(serverCallId, recordingId) .onErrorMap(CommunicationErrorException.class, CallingServerErrorConverter::translateException) .flatMap(result -> Mono.just(new CallRecordingStateResult(result.getRecordingState()))); @@ -388,12 +379,11 @@ public Mono getRecordingState(String recordingId) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> getRecordingStateWithResponse(String recordingId) { - return getRecordingStateWithResponse(recordingId, Context.NONE); + return getRecordingStateWithResponse(recordingId, null); } Mono> getRecordingStateWithResponse(String recordingId, Context context) { try { - Objects.requireNonNull(recordingId, "'recordingId' cannot be null."); return withContext(contextValue -> { contextValue = context == null ? contextValue : context; return serverCallInternal @@ -512,7 +502,7 @@ public Mono> playAudioWithResponse( String audioFileId, String callbackUri, String operationContext) { - return playAudioWithResponseInternal(audioFileUri, audioFileId, callbackUri, operationContext, Context.NONE); + return playAudioWithResponseInternal(audioFileUri, audioFileId, callbackUri, operationContext, null); } /** @@ -528,7 +518,7 @@ public Mono> playAudioWithResponse( public Mono> playAudioWithResponse( String audioFileUri, PlayAudioOptions playAudioOptions) { - return playAudioWithResponseInternal(audioFileUri, playAudioOptions, Context.NONE); + return playAudioWithResponseInternal(audioFileUri, playAudioOptions, null); } Mono> playAudioWithResponseInternal( diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java index c7134324036d..d71de76df9ad 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionLiveTests.java @@ -2,12 +2,10 @@ // Licensed under the MIT License. package com.azure.communication.callingserver; -import java.util.UUID; - import com.azure.communication.callingserver.models.CallModality; import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult; -import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.CreateCallOptions; +import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.common.CommunicationIdentifier; @@ -15,11 +13,11 @@ import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; - import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.UUID; + public class CallConnectionLiveTests extends CallingServerTestBase { private final String fromUser = getNewUserId(); @@ -92,7 +90,7 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) new CommunicationUserIdentifier(fromUser), new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options, - Context.NONE); + null); CallingServerTestUtils.validateCallConnectionResponse(callConnectionResponse); CallConnection callConnection = callConnectionResponse.getValue(); @@ -106,17 +104,17 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) UUID.randomUUID().toString(), null, operationContext, - Context.NONE); + null); CallingServerTestUtils.validatePlayAudioResponse(playAudioResult); // Cancel All Media Operations String cancelMediaOperationContext = UUID.randomUUID().toString(); Response cancelAllMediaOperationsResult = - callConnection.cancelAllMediaOperationsWithResponse(cancelMediaOperationContext, Context.NONE); + callConnection.cancelAllMediaOperationsWithResponse(cancelMediaOperationContext, null); CallingServerTestUtils.validateCancelAllMediaOperationsResult(cancelAllMediaOperationsResult); // Hang up - Response hangupResponse = callConnection.hangupWithResponse(Context.NONE); + Response hangupResponse = callConnection.hangupWithResponse(null); CallingServerTestUtils.validateResponse(hangupResponse); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -189,7 +187,7 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) new CommunicationUserIdentifier(fromUser), new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, options, - Context.NONE); + null); CallingServerTestUtils.validateCallConnectionResponse(callConnectionResponse); CallConnection callConnection = callConnectionResponse.getValue(); @@ -201,7 +199,7 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) new CommunicationUserIdentifier(toUser), null, operationContext, - Context.NONE); + null); CallingServerTestUtils.validateResponse(inviteParticipantResponse); // Remove Participant @@ -213,11 +211,11 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) */ String participantId = "71ed956b-366e-450c-9a61-3bbccf42baa5"; Response removeParticipantResponse = - callConnection.removeParticipantWithResponse(participantId, Context.NONE); + callConnection.removeParticipantWithResponse(participantId, null); CallingServerTestUtils.validateResponse(removeParticipantResponse); // Hang up - Response hangupResponse = callConnection.hangupWithResponse(Context.NONE); + Response hangupResponse = callConnection.hangupWithResponse(null); CallingServerTestUtils.validateResponse(hangupResponse); } catch (Exception e) { System.out.println("Error: " + e.getMessage()); @@ -311,7 +309,7 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { CallConnection joinedCallConnection = joinedCallConnectionResponse.getValue(); //Hangup - Response hangupResponse = callConnection.hangupWithResponse(Context.NONE); + Response hangupResponse = callConnection.hangupWithResponse(null); CallingServerTestUtils.validateResponse(hangupResponse); Response joinCallHangupResponse = joinedCallConnection.hangupWithResponse(null); CallingServerTestUtils.validateResponse(joinCallHangupResponse); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java index 5ae1108e5893..bcd07a3d1008 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallLiveTests.java @@ -3,14 +3,6 @@ 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; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - import com.azure.communication.callingserver.models.CallModality; import com.azure.communication.callingserver.models.CallRecordingState; import com.azure.communication.callingserver.models.CallRecordingStateResult; @@ -24,11 +16,20 @@ import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; import com.azure.core.http.rest.Response; -import com.azure.core.util.Context; - import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import static com.azure.communication.callingserver.CallingServerTestUtils.validateCallConnection; +import static com.azure.communication.callingserver.CallingServerTestUtils.validatePlayAudioResponse; +import static com.azure.communication.callingserver.CallingServerTestUtils.validatePlayAudioResult; +import static com.azure.communication.callingserver.CallingServerTestUtils.validateResponse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + public class ServerCallLiveTests extends CallingServerTestBase { private final String groupId = getGroupId(); @@ -182,7 +183,7 @@ public void startRecordingFails(HttpClient httpClient) { try { Response response = - serverCall.startRecordingWithResponse(CALLBACK_URI, Context.NONE); + serverCall.startRecordingWithResponse(CALLBACK_URI, null); assertEquals(response.getStatusCode(), 400); } catch (CallingServerErrorException e) { assertEquals(e.getResponse().getStatusCode(), 400); @@ -282,7 +283,7 @@ public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { new CommunicationUserIdentifier(toUser), null, operationContext, CALLBACK_URI, - Context.NONE); + null); validateResponse(addResponse); // Remove User @@ -293,7 +294,7 @@ public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { values needs to be used. */ String participantId = "76b33acb-5097-4af0-a646-e07ccee48957"; - Response removeResponse = serverCall.removeParticipantWithResponse(participantId, Context.NONE); + Response removeResponse = serverCall.removeParticipantWithResponse(participantId, null); validateResponse(removeResponse); // Hangup @@ -344,7 +345,7 @@ protected void validateCallRecordingStateWithResponse( sleepIfRunningAgainstService(6000); Response response = - serverCall.getRecordingStateWithResponse(recordingId, Context.NONE); + serverCall.getRecordingStateWithResponse(recordingId, null); 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 fed5de9b498e..e79c9e38217b 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 @@ -52,19 +52,6 @@ public void addParticipantNullParticipantFails() { () -> serverCall.addParticipant(null, null, null, null)); } - @Test - public void removeParticipantNullParticipantFails() { - ServerCall serverCall = new CallingServerClientBuilder() - .httpClient(new NoOpHttpClient()) - .connectionString(MOCK_CONNECTION_STRING) - .buildClient() - .initializeServerCall(serverCallId); - - assertThrows( - NullPointerException.class, - () -> serverCall.removeParticipant(null)); - } - @Test public void startRecordingAsyncFails() { ServerCallAsync serverCall = new CallingServerClientBuilder()