From 54d4194125c76a248c33e45515a743872c0a0c11 Mon Sep 17 00:00:00 2001 From: Arif Saikat <71465659+arifsaikat-microsoft@users.noreply.github.com> Date: Wed, 16 Jun 2021 18:53:55 -0700 Subject: [PATCH] apiview feedback fix (#22337) * apiview feedback fixes * apiview feedback fixes --- .../README.md | 17 +++-- .../callingserver/CallConnection.java | 33 ---------- .../callingserver/CallConnectionAsync.java | 29 --------- .../CallingServerAsyncClient.java | 13 ++-- .../callingserver/CallingServerClient.java | 9 +-- .../callingserver/ServerCall.java | 29 --------- .../callingserver/ServerCallAsync.java | 21 ------ .../CallConnectionRequestConverter.java | 8 +-- .../converters/JoinCallRequestConverter.java | 15 +---- .../models/CreateCallOptions.java | 25 ++++--- .../callingserver/models/JoinCallOptions.java | 33 +++++----- .../events/ParticipantsUpdatedEvent.java | 13 ++-- ...gServerAsyncClientJavaDocCodeSnippets.java | 12 ++-- ...allingServerClientJavaDocCodeSnippets.java | 12 ++-- .../callingserver/ReadmeSamples.java | 14 ++-- .../CallConnectionAsyncLiveTests.java | 64 +++++++++--------- .../CallConnectionLiveTests.java | 65 ++++++++++--------- .../callingserver/CallingServerTestBase.java | 25 +++---- .../ServerCallAsyncLiveTests.java | 14 ++-- .../callingserver/ServerCallLiveTests.java | 25 +++---- 20 files changed, 181 insertions(+), 295 deletions(-) diff --git a/sdk/communication/azure-communication-callingserver/README.md b/sdk/communication/azure-communication-callingserver/README.md index 8b5d665635f24..d18624c692423 100644 --- a/sdk/communication/azure-communication-callingserver/README.md +++ b/sdk/communication/azure-communication-callingserver/README.md @@ -46,7 +46,7 @@ Based on if the Contoso app join a call or not, APIs can be divided into two cat You can provide the connection string using the connectionString() function of `CallingServerClientBuilder`. Once you initialized a `CallingServerClient` class, you can do the different server calling operations. - + ```java // Your connectionString retrieved from your Azure Communication Service String connectionString = "endpoint=https://.communication.azure.com/;accesskey="; @@ -60,22 +60,21 @@ CallingServerClient callingServerClient = builder.buildClient(); ### Create call, Add participant and Hangup a call #### Create a Call: - + ```java CommunicationIdentifier source = new CommunicationUserIdentifier(""); CommunicationIdentifier firstCallee = new CommunicationUserIdentifier(""); CommunicationIdentifier secondCallee = new CommunicationUserIdentifier(""); -CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; +List targets = Arrays.asList(firstCallee, secondCallee); String callbackUri = ""; -MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; +List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); -EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { +List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED -}; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, @@ -86,14 +85,14 @@ CallConnection callConnection = callingServerClient.createCallConnection(source, ``` #### Add a participant to a Call: - + ```java CommunicationIdentifier thirdCallee = new CommunicationUserIdentifier(""); callConnection.addParticipant(thirdCallee, "ACS User 3", ""); ``` #### Hangup a Call: - + ```java callConnection.hangup(); ``` diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java index add9b7e100c13..1390a0fd02608 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallConnection.java @@ -72,39 +72,6 @@ public PlayAudioResult playAudio(String audioFileUri, PlayAudioOptions playAudio return callConnectionAsync.playAudioInternal(audioFileUri, playAudioOptions).block(); } - /** - * Play audio in a call. - * - * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format - * audio prompts are supported. More specifically, the audio content in the wave file must - * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. - * @param loop The flag indicating whether audio file needs to be played in loop or not. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri call back uri to receive notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @param context A {@link Context} representing the request context. - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response playAudioWithResponse( - String audioFileUri, - boolean loop, - String audioFileId, - String callbackUri, - String operationContext, - final Context context) { - return callConnectionAsync - .playAudioWithResponseInternal( - audioFileUri, - loop, - audioFileId, - callbackUri, - operationContext, - context) - .block(); - } - /** * Play audio in a call. * 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 9aa425bbfdc47..c4cdba971d845 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 @@ -139,35 +139,6 @@ Mono playAudioInternal(PlayAudioRequest playAudioRequest) { } } - /** - * Play audio in a call. - * - * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format - * audio prompts are supported. More specifically, the audio content in the wave file must - * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. - * @param loop The flag indicating whether audio file needs to be played in loop or not. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri call back uri to receive notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> playAudioWithResponse( - String audioFileUri, - boolean loop, - String audioFileId, - String callbackUri, - String operationContext) { - return playAudioWithResponseInternal( - audioFileUri, - loop, - audioFileId, - callbackUri, - operationContext, - null); - } - /** * Play audio in a call. * 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 d82f0c541b0a9..c306dd7aeac41 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 @@ -34,6 +34,7 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.HashSet; +import java.util.List; import java.util.Objects; import java.util.Set; @@ -82,7 +83,7 @@ public final class CallingServerAsyncClient { @ServiceMethod(returns = ReturnType.SINGLE) public Mono createCallConnection( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -108,7 +109,7 @@ public Mono createCallConnection( @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createCallConnectionWithResponse( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -125,7 +126,7 @@ public Mono> createCallConnectionWithResponse( Mono createCallConnectionInternal( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { try { Objects.requireNonNull(source, "'source' cannot be null."); @@ -142,7 +143,7 @@ Mono createCallConnectionInternal( Mono> createCallConnectionWithResponseInternal( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions, Context context) { try { @@ -171,7 +172,7 @@ Mono> createCallConnectionWithResponseInternal( * @return response for a successful join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono join( + public Mono joinCall( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { @@ -196,7 +197,7 @@ public Mono join( * @return response for a successful join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono>joinWithResponse( + public Mono> joinCallWithResponse( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java index 1ab8665d967ed..cd2adcb7ccb70 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/CallingServerClient.java @@ -16,6 +16,7 @@ import java.io.OutputStream; import java.nio.file.Path; +import java.util.List; import java.util.Objects; @@ -51,7 +52,7 @@ public final class CallingServerClient { @ServiceMethod(returns = ReturnType.SINGLE) public CallConnection createCallConnection( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { return callingServerAsyncClient.createCallConnectionInternal(source, targets, createCallOptions).block(); } @@ -68,7 +69,7 @@ public CallConnection createCallConnection( @ServiceMethod(returns = ReturnType.SINGLE) public Response createCallConnectionWithResponse( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions, final Context context) { return callingServerAsyncClient @@ -84,7 +85,7 @@ public Response createCallConnectionWithResponse( * @return CallConnection for a successful Join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public CallConnection join( + public CallConnection joinCall( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions) { @@ -101,7 +102,7 @@ public CallConnection join( * @return response for a successful Join request. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Response joinWithResponse( + public Response joinCallWithResponse( String serverCallId, CommunicationIdentifier source, JoinCallOptions joinCallOptions, diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java index a572ded3d9b9a..9d10dbec1945c 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/ServerCall.java @@ -249,35 +249,6 @@ public PlayAudioResult playAudio(String audioFileUri, PlayAudioOptions playAudio return serverCallAsync.playAudioInternal(audioFileUri, playAudioOptions).block(); } - /** - * Play audio in a call. - * - * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format - * audio prompts are supported. More specifically, the audio content in the wave file must - * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. - * @param audioFileId An id for the media in the AudioFileUri, using which we cache the media. - * @param callbackUri The callback Uri to receive PlayAudio status notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @param context A {@link Context} representing the request context. - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Response playAudioWithResponse( - String audioFileUri, - String audioFileId, - String callbackUri, - String operationContext, - final Context context) { - return serverCallAsync - .playAudioWithResponseInternal( - audioFileUri, - audioFileId, - callbackUri, - operationContext, - context).block(); - } - /** * Play audio in a call. * 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 43e6af1eabea0..2fb09da097c96 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 @@ -492,27 +492,6 @@ Mono playAudioInternal(PlayAudioRequest playAudioRequest) { } } - /** - * Play audio in a call. - * - * @param audioFileUri The media resource uri of the play audio request. Currently only Wave file (.wav) format - * audio prompts are supported. More specifically, the audio content in the wave file must - * be mono (single-channel), 16-bit samples with a 16,000 (16KHz) sampling rate. - * @param audioFileId Tne id for the media in the AudioFileUri, using which we cache the media resource. - * @param callbackUri The callback Uri to receive PlayAudio status notifications. - * @param operationContext The value to identify context of the operation. This is used to co-relate other - * communications related to this operation - * @return the response payload for play audio operation. - */ - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> playAudioWithResponse( - String audioFileUri, - String audioFileId, - String callbackUri, - String operationContext) { - return playAudioWithResponseInternal(audioFileUri, audioFileId, callbackUri, operationContext, null); - } - /** * Play audio in a call. * 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 02b870911de19..b3ec70ff82d94 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 @@ -10,8 +10,6 @@ import com.azure.communication.callingserver.models.MediaType; import com.azure.communication.common.CommunicationIdentifier; -import java.util.ArrayList; -import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -26,16 +24,16 @@ public final class CallConnectionRequestConverter { */ public static CreateCallRequest convert( CommunicationIdentifier source, - CommunicationIdentifier[] targets, + List targets, CreateCallOptions createCallOptions) { - if (source == null || targets == null || targets.length == 0) { + if (source == null || targets == null || targets.size() == 0) { return null; } CreateCallRequest createCallRequest = new CreateCallRequest() .setSource(CommunicationIdentifierConverter.convert(source)) - .setTargets(new ArrayList<>(Arrays.asList(targets)) + .setTargets(targets .stream() .map(CommunicationIdentifierConverter::convert) .collect(Collectors.toList())); diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java index 22f8a1f30602f..4ee6108841ec2 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/implementation/converters/JoinCallRequestConverter.java @@ -4,14 +4,10 @@ package com.azure.communication.callingserver.implementation.converters; import com.azure.communication.callingserver.implementation.models.JoinCallRequest; -import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; -import com.azure.communication.callingserver.models.MediaType; import com.azure.communication.common.CommunicationIdentifier; import java.util.ArrayList; -import java.util.Collections; -import java.util.List; /** * A converter for {@link JoinCallRequest} @@ -35,15 +31,8 @@ public static JoinCallRequest convert(CommunicationIdentifier source, JoinCallOp joinCallRequest.setSubject(joinCallOptions.getSubject()); joinCallRequest.setCallbackUri(joinCallOptions.getCallbackUri()); - - List requestedModalities = new ArrayList<>(); - Collections.addAll(requestedModalities, joinCallOptions.getRequestedMediaTypes()); - joinCallRequest.setRequestedMediaTypes(requestedModalities); - - List requestedCallEvents = new ArrayList<>(); - Collections.addAll(requestedCallEvents, joinCallOptions.getRequestedCallEvents()); - joinCallRequest.setRequestedCallEvents(requestedCallEvents); - + joinCallRequest.setRequestedMediaTypes(new ArrayList<>(joinCallOptions.getRequestedMediaTypes())); + joinCallRequest.setRequestedCallEvents(new ArrayList<>(joinCallOptions.getRequestedCallEvents())); return joinCallRequest; } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java index 60447786dfec2..6e0742597ed29 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/CreateCallOptions.java @@ -6,6 +6,8 @@ import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.annotation.Fluent; +import java.util.List; + /** * The options for creating a call. */ @@ -30,12 +32,12 @@ public final class CreateCallOptions { /** * The requested media types. */ - private final MediaType[] requestedMediaTypes; + private final List requestedMediaTypes; /** * The requested call events to subscribe to. */ - private final EventSubscriptionType[] requestedCallEvents; + private final List requestedCallEvents; /** * Get the alternate caller id of the source. @@ -91,8 +93,8 @@ public String getCallbackUri() { * * @return the requested modalities object itself. */ - public MediaType[] getRequestedMediaTypes() { - return this.requestedMediaTypes == null ? new MediaType[0] : this.requestedMediaTypes.clone(); + public List getRequestedMediaTypes() { + return requestedMediaTypes; } /** @@ -100,8 +102,8 @@ public MediaType[] getRequestedMediaTypes() { * * @return the requested call events to subscribe to object itself. */ - public EventSubscriptionType[] getRequestedCallEvents() { - return requestedCallEvents.clone(); + public List getRequestedCallEvents() { + return requestedCallEvents; } /** @@ -114,22 +116,19 @@ public EventSubscriptionType[] getRequestedCallEvents() { */ public CreateCallOptions( String callbackUri, - MediaType[] requestedMediaTypes, - EventSubscriptionType[] requestedCallEvents) { + List requestedMediaTypes, + List requestedCallEvents) { if (callbackUri == null) { throw new IllegalArgumentException("object callbackUri cannot be null"); } - if (requestedMediaTypes == null) { throw new IllegalArgumentException("object requestedMediaTypes cannot be null"); } if (requestedCallEvents == null) { throw new IllegalArgumentException("object requestedCallEvents cannot be null"); } - this.callbackUri = callbackUri; - - this.requestedMediaTypes = requestedMediaTypes.clone(); - this.requestedCallEvents = requestedCallEvents.clone(); + this.requestedMediaTypes = requestedMediaTypes; + this.requestedCallEvents = requestedCallEvents; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java index 7a2fa269c4c0b..dfc2621c0ddc1 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/JoinCallOptions.java @@ -6,6 +6,8 @@ import com.azure.core.annotation.Fluent; import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + /** The options for join call. */ @Fluent public final class JoinCallOptions { @@ -25,13 +27,13 @@ public final class JoinCallOptions { * The requested MediaTypes. */ @JsonProperty(value = "requestedMediaTypes", required = true) - private MediaType[] requestedMediaTypes; + private List requestedMediaTypes; /* * The requested call events to subscribe to. */ @JsonProperty(value = "requestedCallEvents", required = true) - private EventSubscriptionType[] requestedCallEvents; + private List requestedCallEvents; /** * Get the subject property: The subject. @@ -78,8 +80,8 @@ public JoinCallOptions setCallbackUri(String callbackUri) { * * @return the requestedMediaTypes value. */ - public MediaType[] getRequestedMediaTypes() { - return requestedMediaTypes == null ? new MediaType[0] : requestedMediaTypes.clone(); + public List getRequestedMediaTypes() { + return requestedMediaTypes; } /** @@ -88,8 +90,8 @@ public MediaType[] getRequestedMediaTypes() { * @param requestedMediaTypes the requestedModalities value to set. * @return the JoinCallOptions object itself. */ - public JoinCallOptions setRequestedMediaTypes(MediaType[] requestedMediaTypes) { - this.requestedMediaTypes = requestedMediaTypes == null ? new MediaType[0] : requestedMediaTypes.clone(); + public JoinCallOptions setRequestedMediaTypes(List requestedMediaTypes) { + this.requestedMediaTypes = requestedMediaTypes; return this; } @@ -99,8 +101,8 @@ public JoinCallOptions setRequestedMediaTypes(MediaType[] requestedMediaTypes) { * * @return the requestedCallEvents value. */ - public EventSubscriptionType[] getRequestedCallEvents() { - return requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone(); + public List getRequestedCallEvents() { + return requestedCallEvents; } /** @@ -110,8 +112,8 @@ public EventSubscriptionType[] getRequestedCallEvents() { * @param requestedCallEvents the requestedCallEvents value to set. * @return the JoinCallOptions object itself. */ - public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedCallEvents) { - this.requestedCallEvents = requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone(); + public JoinCallOptions setRequestedCallEvents(List requestedCallEvents) { + this.requestedCallEvents = requestedCallEvents; return this; } @@ -125,22 +127,19 @@ public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedC */ public JoinCallOptions( String callbackUri, - MediaType[] requestedMediaTypes, - EventSubscriptionType[] requestedCallEvents) { + List requestedMediaTypes, + List requestedCallEvents) { if (callbackUri == null) { throw new IllegalArgumentException("object callbackUri cannot be null"); } - if (requestedMediaTypes == null) { throw new IllegalArgumentException("object requestedMediaTypes cannot be null"); } if (requestedCallEvents == null) { throw new IllegalArgumentException("object requestedCallEvents cannot be null"); } - this.callbackUri = callbackUri; - - this.requestedMediaTypes = requestedMediaTypes.clone(); - this.requestedCallEvents = requestedCallEvents.clone(); + this.requestedMediaTypes = requestedMediaTypes; + this.requestedCallEvents = requestedCallEvents; } } diff --git a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java index 30e81b39c9fba..0029e0b26b33b 100644 --- a/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java +++ b/sdk/communication/azure-communication-callingserver/src/main/java/com/azure/communication/callingserver/models/events/ParticipantsUpdatedEvent.java @@ -26,7 +26,7 @@ public final class ParticipantsUpdatedEvent extends CallingServerEventBase { /** * The participants. */ - private final CallParticipant[] participants; + private final List participants; /** * Get the callConnectionId property: The call connection id. @@ -43,8 +43,8 @@ public String getCallConnectionId() { * * @return the list of participants value. */ - public CallParticipant[] getParticipants() { - return participants == null ? new CallParticipant[0] : participants.clone(); + public List getParticipants() { + return participants; } /** @@ -54,7 +54,7 @@ public CallParticipant[] getParticipants() { * @param participants The participants * @throws IllegalArgumentException if any parameter is null or empty. */ - public ParticipantsUpdatedEvent(String callConnectionId, CallParticipant[] participants) { + public ParticipantsUpdatedEvent(String callConnectionId, List participants) { if (callConnectionId == null || callConnectionId.isEmpty()) { throw new IllegalArgumentException("object callConnectionId cannot be null or empty"); } @@ -62,7 +62,7 @@ public ParticipantsUpdatedEvent(String callConnectionId, CallParticipant[] parti throw new IllegalArgumentException("object participants cannot be null"); } this.callConnectionId = callConnectionId; - this.participants = participants.clone(); + this.participants = participants; } /** @@ -85,7 +85,6 @@ public static ParticipantsUpdatedEvent deserialize(BinaryData eventData) { callParticipantInternal.isMuted())); } - return new ParticipantsUpdatedEvent(internalEvent.getCallConnectionId(), - participants.toArray(new CallParticipant[0])); + return new ParticipantsUpdatedEvent(internalEvent.getCallConnectionId(), participants); } } diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java index 7e672afa8a342..798a78e2f6c9e 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerAsyncClientJavaDocCodeSnippets.java @@ -11,6 +11,9 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; +import java.util.Arrays; +import java.util.List; + public class CallingServerAsyncClientJavaDocCodeSnippets { public CallingServerAsyncClient createCallingServerAsyncClientWithPipeline() { @@ -44,12 +47,11 @@ public void createCallConnectionAsync() { String callbackUri = ""; // BEGIN: com.azure.communication.callingserver.CallingServerAsyncClient.create.call.connection.async - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List targets = Arrays.asList(firstCallee, secondCallee); + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, requestedMediaTypes, diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java index edd91a97c3887..c42cb9ec5617c 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/CallingServerClientJavaDocCodeSnippets.java @@ -11,6 +11,9 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; +import java.util.Arrays; +import java.util.List; + public class CallingServerClientJavaDocCodeSnippets { public CallingServerClient createCallingServerClientWithPipeline() { @@ -44,12 +47,11 @@ public void createCallConnection() { String callbackUri = ""; // BEGIN: com.azure.communication.callingserver.CallingServerClient.create.call.connection - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List targets = Arrays.asList(firstCallee, secondCallee); + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, requestedMediaTypes, diff --git a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java index 71f3cbd6554ac..06eb88a4e0eef 100644 --- a/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java +++ b/sdk/communication/azure-communication-callingserver/src/samples/java/com/azure/communication/callingserver/ReadmeSamples.java @@ -3,12 +3,15 @@ package com.azure.communication.callingserver; -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.MediaType; import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; +import java.util.Arrays; +import java.util.List; + /** * WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS * ARE USED TO EXTRACT APPROPRIATE CODE SEGMENTS FROM THIS FILE. ADD NEW CODE AT THE BOTTOM TO AVOID CHANGING @@ -47,16 +50,15 @@ public void createCallConnection() { CommunicationIdentifier firstCallee = new CommunicationUserIdentifier(""); CommunicationIdentifier secondCallee = new CommunicationUserIdentifier(""); - CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee, secondCallee }; + List targets = Arrays.asList(firstCallee, secondCallee); String callbackUri = ""; - MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO }; + List requestedMediaTypes = Arrays.asList(MediaType.AUDIO, MediaType.VIDEO); - EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] { + List requestedCallEvents = Arrays.asList( EventSubscriptionType.DTMF_RECEIVED, - EventSubscriptionType.PARTICIPANTS_UPDATED - }; + EventSubscriptionType.PARTICIPANTS_UPDATED); CreateCallOptions createCallOptions = new CreateCallOptions( callbackUri, diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java index f2f56f02a7264..925588b992b31 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallConnectionAsyncLiveTests.java @@ -8,8 +8,8 @@ import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.MediaType; +import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -18,6 +18,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.Collections; import java.util.UUID; public class CallConnectionAsyncLiveTests extends CallingServerTestBase { @@ -40,14 +41,14 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -92,15 +93,15 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -109,13 +110,14 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl // Play Audio String operationContext = UUID.randomUUID().toString(); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(null) + .setOperationContext(operationContext); Response playAudioResponse = - callConnectionAsync.playAudioWithResponse( - AUDIO_FILE_URI, - false, - UUID.randomUUID().toString(), - null, - operationContext).block(); + callConnectionAsync.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions).block(); CallingServerTestUtils.validatePlayAudioResponse(playAudioResponse); // Cancel All Media Operations @@ -148,14 +150,14 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -195,15 +197,15 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -249,14 +251,14 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -269,10 +271,10 @@ public void runCreateJoinHangupScenarioAsync(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3VodHNzZEZ3NFVHX1J4d1lHYWlLRmc_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); CallConnectionAsync joinedCallConnectionAsync = - callingServerAsyncClient.join( + callingServerAsyncClient.joinCall( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions).block(); @@ -304,15 +306,15 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionAsyncResponse = callingServerAsyncClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsyncResponse(callConnectionAsyncResponse); @@ -327,10 +329,10 @@ public void runCreateJoinHangupScenarioWithResponseAsync(HttpClient httpClient) String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3lKQXY0TnVlOEV5bUpYVm1IYklIeUE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); Response joinedCallConnectionAsyncResponse = - callingServerAsyncClient.joinWithResponse( + callingServerAsyncClient.joinCallWithResponse( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions).block(); 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 4f3b5003bc763..d500490d1a775 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 @@ -8,8 +8,8 @@ import com.azure.communication.callingserver.models.EventSubscriptionType; import com.azure.communication.callingserver.models.JoinCallOptions; import com.azure.communication.callingserver.models.MediaType; +import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -18,6 +18,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import java.util.Collections; import java.util.UUID; public class CallConnectionLiveTests extends CallingServerTestBase { @@ -39,14 +40,14 @@ public void runCreatePlayCancelHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); CallingServerTestUtils.validateCallConnection(callConnection); @@ -90,15 +91,15 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options, null); @@ -107,14 +108,14 @@ public void runCreatePlayCancelHangupScenarioWithResponse(HttpClient httpClient) // Play Audio String operationContext = UUID.randomUUID().toString(); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(null) + .setOperationContext(operationContext); Response playAudioResult = - callConnection.playAudioWithResponse( - AUDIO_FILE_URI, - false, - UUID.randomUUID().toString(), - null, - operationContext, - null); + callConnection.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions, null); CallingServerTestUtils.validatePlayAudioResponse(playAudioResult); // Cancel All Media Operations @@ -146,14 +147,14 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); CallingServerTestUtils.validateCallConnection(callConnection); @@ -188,15 +189,15 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options, null); @@ -241,14 +242,14 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), createCallOptions); CallingServerTestUtils.validateCallConnection(callConnection); @@ -261,10 +262,10 @@ public void runCreateJoinHangupScenario(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L2RUUjRPVGFxVzAyZ3cxVGpNSUNBdEE_aT0wJmU9NjM3NTg0MzkwMjcxMzg0MTc3"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); CallConnection joinedCallConnection = - callingServerClient.join(serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions); + callingServerClient.joinCall(serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions); CallingServerTestUtils.validateCallConnection(joinedCallConnection); //Hangup @@ -291,14 +292,14 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { // Establish a call CreateCallOptions createCallOptions = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); createCallOptions.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); Response callConnectionResponse = callingServerClient.createCallConnectionWithResponse( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), createCallOptions, null); @@ -309,10 +310,10 @@ public void runCreateJoinHangupScenarioWithResponse(HttpClient httpClient) { String serverCallId = "aHR0cHM6Ly94LWNvbnYtdXN3ZS0wMS5jb252LnNreXBlLmNvbS9jb252L3dXZW9hNjAweGtPZ0d6eHE2eG1tQVE_aT0yJmU9NjM3NTg0Mzk2NDM5NzQ5NzY4"; JoinCallOptions joinCallOptions = new JoinCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); Response joinedCallConnectionResponse = - callingServerClient.joinWithResponse( + callingServerClient.joinCallWithResponse( serverCallId, new CommunicationUserIdentifier(toUser), joinCallOptions, 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 7307e021cff6a..66c0810cea417 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 @@ -23,6 +23,7 @@ import java.time.OffsetDateTime; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.StringJoiner; @@ -176,18 +177,18 @@ protected List createCall(CallingServerClient callingServerClien JoinCallOptions fromCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - fromCallConnection = callingServerClient.join(groupId, fromParticipant, fromCallOptions); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); + fromCallConnection = callingServerClient.joinCall(groupId, fromParticipant, fromCallOptions); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnection(fromCallConnection); JoinCallOptions joinCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); - toCallConnection = callingServerClient.join(groupId, toParticipant, joinCallOptions); + toCallConnection = callingServerClient.joinCall(groupId, toParticipant, joinCallOptions); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnection(toCallConnection); @@ -221,18 +222,18 @@ protected List createAsyncCall(CallingServerAsyncClient cal JoinCallOptions fromCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); - fromCallConnection = callingServerClient.join(groupId, fromParticipant, fromCallOptions).block(); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); + fromCallConnection = callingServerClient.joinCall(groupId, fromParticipant, fromCallOptions).block(); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnectionAsync(fromCallConnection); JoinCallOptions joinCallOptions = new JoinCallOptions( callBackUri, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); - toCallConnection = callingServerClient.join(groupId, toParticipant, joinCallOptions).block(); + toCallConnection = callingServerClient.joinCall(groupId, toParticipant, joinCallOptions).block(); sleepIfRunningAgainstService(1000); CallingServerTestUtils.validateCallConnectionAsync(toCallConnection); diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java index f6c5c62a50c60..99fabcd52c8b8 100644 --- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java +++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/ServerCallAsyncLiveTests.java @@ -13,7 +13,6 @@ import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -23,6 +22,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -221,14 +221,14 @@ public void runAddRemoveScenarioAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); @@ -278,14 +278,14 @@ public void runAddRemoveScenarioWithResponseAsync(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnectionAsync callConnectionAsync = callingServerAsyncClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options).block(); CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync); 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 bd98c67c09beb..890d677f2e5b6 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 @@ -13,7 +13,6 @@ import com.azure.communication.callingserver.models.PlayAudioOptions; import com.azure.communication.callingserver.models.PlayAudioResult; import com.azure.communication.callingserver.models.StartCallRecordingResult; -import com.azure.communication.common.CommunicationIdentifier; import com.azure.communication.common.CommunicationUserIdentifier; import com.azure.communication.common.PhoneNumberIdentifier; import com.azure.core.http.HttpClient; @@ -24,6 +23,7 @@ import org.junit.jupiter.params.provider.MethodSource; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -167,13 +167,16 @@ public void runPlayAudioFunctionWithResponse(HttpClient httpClient) { try { callConnections = createCall(callingServerClient, groupId, fromUser, toUser, CALLBACK_URI); + PlayAudioOptions playAudioOptions = + new PlayAudioOptions() + .setLoop(false) + .setAudioFileId(UUID.randomUUID().toString()) + .setCallbackUri(CALLBACK_URI) + .setOperationContext(operationContext); serverCall = callingServerClient.initializeServerCall(groupId); Response playAudioResult = - serverCall.playAudioWithResponse( - AUDIO_FILE_URI, operationContext, - CALLBACK_URI, operationContext, - Context.NONE); + serverCall.playAudioWithResponse(AUDIO_FILE_URI, playAudioOptions, Context.NONE); validatePlayAudioResponse(playAudioResult); } catch (Exception e) { @@ -214,14 +217,14 @@ public void runAddRemoveScenario(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); validateCallConnection(callConnection); @@ -268,14 +271,14 @@ public void runAddRemoveScenarioWithResponse(HttpClient httpClient) { // Establish a call CreateCallOptions options = new CreateCallOptions( CALLBACK_URI, - new MediaType[] { MediaType.AUDIO }, - new EventSubscriptionType[] { EventSubscriptionType.PARTICIPANTS_UPDATED }); + Collections.singletonList(MediaType.AUDIO), + Collections.singletonList(EventSubscriptionType.PARTICIPANTS_UPDATED)); options.setAlternateCallerId(new PhoneNumberIdentifier(FROM_PHONE_NUMBER)); CallConnection callConnection = callingServerClient.createCallConnection( new CommunicationUserIdentifier(fromUser), - new CommunicationIdentifier[] { new PhoneNumberIdentifier(TO_PHONE_NUMBER) }, + Collections.singletonList(new PhoneNumberIdentifier(TO_PHONE_NUMBER)), options); validateCallConnection(callConnection);