Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr review fix (#22131)
Browse files Browse the repository at this point in the history
arifsaikat-microsoft authored Jun 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 85472c8 commit 4459456
Showing 10 changed files with 79 additions and 155 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Release History

## 1.0.0-beta.1 (Unreleased)
This is the first release of Azure Communication CallingServer Service. For more information, please see the [README][read_me].
This is the first release of Azure Communication Calling Server Service. For more information, please see the [README][read_me].

This is a Public Preview version, so breaking changes are possible in subsequent releases as we improve the product. To provide feedback, please submit an issue in our [Azure SDK for .NET GitHub repo](https://github.com/Azure/azure-sdk-for-net/issues).

9 changes: 3 additions & 6 deletions sdk/communication/azure-communication-callingserver/README.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ This package contains a Java SDK for Azure Communication CallingServer Service.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-callingserver</artifactId>
<version>1.0.0-preview.1</version>
<version>1.0.0-beta.1</version>
</dependency>
```
[//]: # ({x-version-update-end})
@@ -91,8 +91,6 @@ CreateCallOptions createCallOptions = new CreateCallOptions(
requestedCallEvents);

CreateCallResponse createCallResult = callClient.createCall(source, targets, createCallOptions);

String callId = createCallResult.getCallLegId();
```

Add a participant to a Call:
@@ -137,7 +135,6 @@ Start a Recording:
String conversationId = "<conversationId recieved from starting call>";
String recordingStateCallbackUri = "<webhook endpoint to which calling service can report status>";
StartCallRecordingResponse response = conversationClient.startRecording(conversationId, recordingStateCallbackUri);
String recordingId = response.getRecordingId();
```

Pause a Recording:
@@ -180,8 +177,8 @@ Play Audio:
String audioFileUri = "<uri of the file to play>";
String audioFileId = "<a name to use for caching the audio file>";
String callbackUri = "<webhook endpoint to which calling service can report status>";
String context = "<Identifier for correlating responses>";
PlayAudioResponse playAudioResponse = conversationClient.playAudio(conversationId, audioFileUri, audioFileId, callbackUri, context);
String context = "<identifier for correlating responses>";
PlayAudioResponse playAudioResponse = conversationClient.playAudio(conversationId, audioFileUri, audioFileId, callbackUri, context);
```

## Troubleshooting
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;

@@ -67,11 +66,9 @@ public Mono<CreateCallResponse> createCall(CommunicationIdentifier source,
try {
Objects.requireNonNull(source, "'source' cannot be null.");
Objects.requireNonNull(targets, "'targets' cannot be null.");
Objects.requireNonNull(createCallOptions, "'CreateCallOptions' cannot be null.");
Objects.requireNonNull(createCallOptions, "'createCallOptions' cannot be null.");
CreateCallRequestInternal request = createCreateCallRequest(source, targets, createCallOptions);
return this.callClient
.createCallAsync(request)
.flatMap(response -> Mono.just(response));
return this.callClient.createCallAsync(request);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -103,9 +100,7 @@ Mono<Response<CreateCallResponse>> createCallWithResponse(CommunicationIdentifie
CreateCallRequestInternal request = createCreateCallRequest(source, targets, createCallOptions);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.callClient
.createCallWithResponseAsync(request, contextValue)
.flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue())));
return this.callClient.createCallWithResponseAsync(request, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -132,15 +127,9 @@ public Mono<PlayAudioResponse> playAudio(String callId,
String audioFileId,
String callbackUri,
String operationContext) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
PlayAudioRequest playAudioRequest =
PlayAudioConverter.convert(audioFileUri, loop, audioFileId, callbackUri, operationContext);
return playAudio(callId, playAudioRequest);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
PlayAudioRequest playAudioRequest =
PlayAudioConverter.convert(audioFileUri, loop, audioFileId, callbackUri, operationContext);
return playAudio(callId, playAudioRequest);
}

/**
@@ -157,24 +146,16 @@ public Mono<PlayAudioResponse> playAudio(String callId,
public Mono<PlayAudioResponse> playAudio(String callId,
String audioFileUri,
PlayAudioOptions playAudioOptions) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");
PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions);
return playAudio(callId, playAudioRequest);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions);
return playAudio(callId, playAudioRequest);

}

Mono<PlayAudioResponse> playAudio(String callId, PlayAudioRequest playAudioRequest) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null.");

return this.callClient
.playAudioAsync(callId, playAudioRequest)
.flatMap(response -> Mono.just(response));
Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null.");
return this.callClient.playAudioAsync(callId, playAudioRequest);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -223,15 +204,15 @@ public Mono<Response<PlayAudioResponse>> playAudioWithResponse(String callId,
return playAudioWithResponse(callId, playAudioRequest, Context.NONE);
}

Mono<Response<PlayAudioResponse>> playAudioWithResponse(String callId, PlayAudioRequest playAudioRequest, Context context) {
Mono<Response<PlayAudioResponse>> playAudioWithResponse(String callId,
PlayAudioRequest playAudioRequest,
Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null.");
Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null.");
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.callClient
.playAudioWithResponseAsync(callId, playAudioRequest, contextValue)
.flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue())));
return this.callClient.playAudioWithResponseAsync(callId, playAudioRequest, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -287,7 +268,6 @@ Mono<Response<Void>> hangupCallWithResponse(String callId, Context context) {
public Mono<Void> deleteCall(String callId) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");

return this.callClient.deleteCallAsync(callId);
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -328,12 +308,9 @@ Mono<Response<Void>> deleteCallWithResponse(String callId, Context context) {
public Mono<CancelAllMediaOperationsResponse> cancelAllMediaOperations(String callId, String operationContext) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");

CancelAllMediaOperationsRequest request = new CancelAllMediaOperationsRequest();
request.setOperationContext(operationContext);
return this.callClient
.cancelAllMediaOperationsAsync(callId, request)
.flatMap(response -> Mono.just(response));
return this.callClient.cancelAllMediaOperationsAsync(callId, request);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -361,9 +338,7 @@ Mono<Response<CancelAllMediaOperationsResponse>> cancelAllMediaOperationsWithRes
request.setOperationContext(operationContext);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.callClient
.cancelAllMediaOperationsWithResponseAsync(callId, request, contextValue)
.flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue())));
return this.callClient.cancelAllMediaOperationsWithResponseAsync(callId, request, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -386,7 +361,7 @@ public Mono<Void> addParticipant(String callId,
String operationContext) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(participant, "'request' cannot be null.");
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request = AddParticipantConverter.convert(participant,
alternateCallerId,
operationContext,
@@ -447,7 +422,7 @@ Mono<Response<Void>> addParticipantWithResponse(String callId,
public Mono<Void> removeParticipant(String callId, String participantId) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(participantId, "'request' cannot be null.");
Objects.requireNonNull(participantId, "'participantId' cannot be null.");
return this.callClient.removeParticipantAsync(callId, participantId);
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -472,7 +447,7 @@ public Mono<Response<Void>> removeParticipantWithResponse(String callId, String
Mono<Response<Void>> removeParticipantWithResponse(String callId, String participantId, Context context) {
try {
Objects.requireNonNull(callId, "'callId' cannot be null.");
Objects.requireNonNull(participantId, "'request' cannot be null.");
Objects.requireNonNull(participantId, "'participantId' cannot be null.");
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.callClient.removeParticipantWithResponseAsync(callId, participantId, contextValue);
Original file line number Diff line number Diff line change
@@ -218,9 +218,7 @@ public CancelAllMediaOperationsResponse cancelAllMediaOperations(String callId,
public Response<CancelAllMediaOperationsResponse> cancelAllMediaOperationsWithResponse(String callId,
String operationContext,
Context context) {
return callAsyncClient.cancelAllMediaOperationsWithResponse(callId,
operationContext,
context).block();
return callAsyncClient.cancelAllMediaOperationsWithResponse(callId, operationContext, context).block();
}

/**
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;
@@ -63,8 +62,8 @@ public Mono<JoinCallResponse> joinCall(String conversationId,
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(source, "'source' cannot be null.");
Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null.");
return this.conversationsClient.joinCallAsync(conversationId,
JoinCallConverter.convert(source, joinCallOptions));
return this.conversationsClient
.joinCallAsync(conversationId, JoinCallConverter.convert(source, joinCallOptions));
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -91,11 +90,12 @@ Mono<Response<JoinCallResponse>> joinCallWithResponse(String conversationId,
Context context) {
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(source, "'request' cannot be null.");
Objects.requireNonNull(source, "'source' cannot be null.");
Objects.requireNonNull(joinCallOptions, "'joinCallOptions' cannot be null.");
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient.joinCallWithResponseAsync(conversationId,
return this.conversationsClient.
joinCallWithResponseAsync(conversationId,
JoinCallConverter.convert(source, joinCallOptions),
contextValue);
});
@@ -123,10 +123,11 @@ public Mono<Void> addParticipant(String conversationId,
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request = AddParticipantConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
InviteParticipantsRequest request =
AddParticipantConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
return this.conversationsClient.inviteParticipantsAsync(conversationId, request);
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -166,14 +167,14 @@ Mono<Response<Void>> addParticipantWithResponse(String conversationId,
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(participant, "'participant' cannot be null.");
InviteParticipantsRequest request = AddParticipantConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
InviteParticipantsRequest request =
AddParticipantConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient
.inviteParticipantsWithResponseAsync(conversationId, request, contextValue);
return this.conversationsClient.inviteParticipantsWithResponseAsync(conversationId, request, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -219,8 +220,7 @@ Mono<Response<Void>> removeParticipantWithResponse(String conversationId, String
Objects.requireNonNull(participantId, "'participantId' cannot be null.");
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient
.removeParticipantWithResponseAsync(conversationId, participantId, contextValue);
return this.conversationsClient.removeParticipantWithResponseAsync(conversationId, participantId, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -245,8 +245,7 @@ public Mono<StartCallRecordingResponse> startRecording(String conversationId, St
}
StartCallRecordingRequest request = new StartCallRecordingRequest();
request.setRecordingStateCallbackUri(recordingStateCallbackUri);
return this.conversationsClient.startRecordingAsync(conversationId, request)
.flatMap((StartCallRecordingResponse response) -> Mono.just(response));
return this.conversationsClient.startRecordingAsync(conversationId, request);
} catch (RuntimeException ex) {
return monoError(logger, ex);
} catch (URISyntaxException ex) {
@@ -265,9 +264,7 @@ public Mono<StartCallRecordingResponse> startRecording(String conversationId, St
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<StartCallRecordingResponse>> startRecordingWithResponse(String conversationId,
String recordingStateCallbackUri) {
return startRecordingWithResponse(conversationId,
recordingStateCallbackUri,
Context.NONE);
return startRecordingWithResponse(conversationId, recordingStateCallbackUri, Context.NONE);
}

Mono<Response<StartCallRecordingResponse>> startRecordingWithResponse(String conversationId,
@@ -283,10 +280,7 @@ Mono<Response<StartCallRecordingResponse>> startRecordingWithResponse(String con
request.setRecordingStateCallbackUri(recordingStateCallbackUri);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient
.startRecordingWithResponseAsync(conversationId, request, contextValue)
.flatMap((Response<StartCallRecordingResponse> response)
-> Mono.just(new SimpleResponse<>(response, response.getValue())));
return this.conversationsClient.startRecordingWithResponseAsync(conversationId, request, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -439,8 +433,7 @@ public Mono<CallRecordingStateResponse> getRecordingState(String conversationId,
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(recordingId, "'recordingId' cannot be null.");
return this.conversationsClient.recordingStateAsync(conversationId, recordingId)
.flatMap((CallRecordingStateResponse response) -> Mono.just(response));
return this.conversationsClient.recordingStateAsync(conversationId, recordingId);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -468,8 +461,7 @@ Mono<Response<CallRecordingStateResponse>> getRecordingStateWithResponse(String
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient
.recordingStateWithResponseAsync(conversationId, recordingId, contextValue)
.flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue())));
.recordingStateWithResponseAsync(conversationId, recordingId, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
@@ -521,24 +513,15 @@ public Mono<PlayAudioResponse> playAudio(String conversationId,
public Mono<PlayAudioResponse> playAudio(String conversationId,
String audioFileUri,
PlayAudioOptions playAudioOptions) {
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(audioFileUri, "'audioFileUri' cannot be null.");

//Currently we do not support loop on the audio media for out-call, thus setting the loop to false
PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions);
return playAudio(conversationId, playAudioRequest);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions);
return playAudio(conversationId, playAudioRequest);
}

Mono<PlayAudioResponse> playAudio(String conversationId, PlayAudioRequest playAudioRequest) {
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null.");
return this.conversationsClient.playAudioAsync(conversationId, playAudioRequest)
.flatMap(response -> Mono.just(response));
Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null.");
return this.conversationsClient.playAudioAsync(conversationId, playAudioRequest);
} catch (RuntimeException ex) {
return monoError(logger, ex);
}
@@ -557,7 +540,11 @@ Mono<PlayAudioResponse> playAudio(String conversationId, PlayAudioRequest playAu
* @return the response payload for play audio operation.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<PlayAudioResponse>> playAudioWithResponse(String conversationId, String audioFileUri, String audioFileId, String callbackUri, String operationContext) {
public Mono<Response<PlayAudioResponse>> playAudioWithResponse(String conversationId,
String audioFileUri,
String audioFileId,
String callbackUri,
String operationContext) {
//Currently we do not support loop on the audio media for out-call, thus setting the loop to false
PlayAudioRequest playAudioRequest =
PlayAudioConverter.convert(audioFileUri, false, audioFileId, callbackUri, operationContext);
@@ -578,7 +565,6 @@ public Mono<Response<PlayAudioResponse>> playAudioWithResponse(String conversati
public Mono<Response<PlayAudioResponse>> playAudioWithResponse(String conversationId,
String audioFileUri,
PlayAudioOptions playAudioOptions) {
//Currently we do not support loop on the audio media for out-call, thus setting the loop to false
PlayAudioRequest playAudioRequest = PlayAudioConverter.convert(audioFileUri, playAudioOptions);
return playAudioWithResponse(conversationId, playAudioRequest, Context.NONE);
}
@@ -588,12 +574,11 @@ Mono<Response<PlayAudioResponse>> playAudioWithResponse(String conversationId,
Context context) {
try {
Objects.requireNonNull(conversationId, "'conversationId' cannot be null.");
Objects.requireNonNull(playAudioRequest, "'playAudioRequest' cannot be null.");
Objects.requireNonNull(playAudioRequest.getAudioFileUri(), "'audioFileUri' cannot be null.");
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
return this.conversationsClient
.playAudioWithResponseAsync(conversationId, playAudioRequest, contextValue)
.flatMap(response -> Mono.just(new SimpleResponse<>(response, response.getValue())));
.playAudioWithResponseAsync(conversationId, playAudioRequest, contextValue);
});
} catch (RuntimeException ex) {
return monoError(logger, ex);
Original file line number Diff line number Diff line change
@@ -85,9 +85,7 @@ public String getCallbackUri() {
* @return the requested modalities object itself.
*/
public CallModality[] getRequestedModalities() {
CallModality[] requestedModalities = new CallModality[this.requestedModalities.length];
System.arraycopy(this.requestedModalities, 0, requestedModalities, 0, this.requestedModalities.length);
return requestedModalities;
return this.requestedModalities == null ? new CallModality[0] : this.requestedModalities.clone();
}

/**
@@ -101,9 +99,7 @@ public CallModality[] getRequestedModalities() {
* @return the requested call events to subscribe to object itself.
*/
public EventSubscriptionType[] getRequestedCallEvents() {
EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[this.requestedCallEvents.length];
System.arraycopy(this.requestedCallEvents, 0, requestedCallEvents, 0, this.requestedCallEvents.length);
return requestedCallEvents;
return this.requestedCallEvents.clone();
}

/**
@@ -130,10 +126,7 @@ public CreateCallOptions(String callbackUri,

this.callbackUri = callbackUri;

this.requestedModalities = new CallModality[requestedModalities.length];
System.arraycopy(requestedModalities, 0, this.requestedModalities, 0, requestedModalities.length);

this.requestedCallEvents = new EventSubscriptionType[requestedCallEvents.length];
System.arraycopy(requestedCallEvents, 0, this.requestedCallEvents, 0, requestedCallEvents.length);
this.requestedModalities = requestedModalities.clone();
this.requestedCallEvents = requestedCallEvents.clone();
}
}
Original file line number Diff line number Diff line change
@@ -79,12 +79,7 @@ public JoinCallOptions setCallbackUri(String callbackUri) {
* @return the requestedModalities value.
*/
public CallModality[] getRequestedModalities() {
if (this.requestedModalities == null) {
return new CallModality[0];
}
CallModality[] requestedModalities = new CallModality[this.requestedModalities.length];
System.arraycopy(this.requestedModalities, 0, requestedModalities, 0, this.requestedModalities.length);
return requestedModalities;
return this.requestedModalities == null ? new CallModality[0] : this.requestedModalities.clone();
}

/**
@@ -94,8 +89,7 @@ public CallModality[] getRequestedModalities() {
* @return the JoinCallOptions object itself.
*/
public JoinCallOptions setRequestedModalities(CallModality[] requestedModalities) {
this.requestedModalities = new CallModality[requestedModalities.length];
System.arraycopy(requestedModalities, 0, this.requestedModalities, 0, requestedModalities.length);
this.requestedModalities = requestedModalities == null ? new CallModality[0] : requestedModalities.clone();
return this;
}

@@ -106,12 +100,7 @@ public JoinCallOptions setRequestedModalities(CallModality[] requestedModalities
* @return the requestedCallEvents value.
*/
public EventSubscriptionType[] getRequestedCallEvents() {
if (this.requestedCallEvents == null) {
return new EventSubscriptionType[0];
}
EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[this.requestedCallEvents.length];
System.arraycopy(this.requestedCallEvents, 0, requestedCallEvents, 0, this.requestedCallEvents.length);
return requestedCallEvents;
return this.requestedCallEvents == null ? new EventSubscriptionType[0] : this.requestedCallEvents.clone();
}

/**
@@ -122,8 +111,7 @@ public EventSubscriptionType[] getRequestedCallEvents() {
* @return the JoinCallOptions object itself.
*/
public JoinCallOptions setRequestedCallEvents(EventSubscriptionType[] requestedCallEvents) {
this.requestedCallEvents = new EventSubscriptionType[requestedCallEvents.length];
System.arraycopy(requestedCallEvents, 0, this.requestedCallEvents, 0, requestedCallEvents.length);
this.requestedCallEvents = requestedCallEvents == null ? new EventSubscriptionType[0] : requestedCallEvents.clone();
return this;
}
}
Original file line number Diff line number Diff line change
@@ -52,9 +52,7 @@ public ParticipantsUpdatedEvent setCallLegId(String callLegId) {
* @return the result info value.
*/
public CommunicationParticipant[] getParticipants() {
CommunicationParticipant[] participants = new CommunicationParticipant[this.participants.length];
System.arraycopy(this.participants, 0, participants, 0, this.participants.length);
return participants;
return this.participants == null ? new CommunicationParticipant[0] : this.participants.clone();
}

/**
@@ -64,8 +62,7 @@ public CommunicationParticipant[] getParticipants() {
* @return the ParticipantsUpdatedEvent object itself.
*/
public ParticipantsUpdatedEvent setParticipants(CommunicationParticipant[] participants) {
this.participants = new CommunicationParticipant[participants.length];
System.arraycopy(participants, 0, this.participants, 0, participants.length);
this.participants = participants == null ? new CommunicationParticipant[0] : participants.clone();
return this;
}

@@ -90,11 +87,8 @@ public ParticipantsUpdatedEvent(String callLegId, CommunicationParticipant[] par
if (participants == null) {
throw new IllegalArgumentException("object participants cannot be null");
}

this.callLegId = callLegId;

this.participants = new CommunicationParticipant[participants.length];
System.arraycopy(participants, 0, this.participants, 0, participants.length);
this.participants = participants.clone();
}

/**
Original file line number Diff line number Diff line change
@@ -71,8 +71,6 @@ public void createCall() {
requestedCallEvents);

CreateCallResponse createCallResult = callClient.createCall(source, targets, createCallOptions);

String callId = createCallResult.getCallLegId();
}

/**
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@
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;
@@ -98,8 +97,7 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl
Response<CreateCallResponse> createCallResponse = callAsyncClient.createCallWithResponse(
new CommunicationUserIdentifier(from),
new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) },
options,
Context.NONE).block();
options).block();

CallingServerTestUtils.validateCreateCallResponse(createCallResponse);
String callId = createCallResponse.getValue().getCallLegId();
@@ -117,11 +115,11 @@ public void runCreatePlayCancelHangupScenarioWithResponseAsync(HttpClient httpCl

// Cancel All Media Operations
String cancelMediaOperationContext = "ac794123-3820-4979-8e2d-50c7d3e07b13";
Response<CancelAllMediaOperationsResponse> cancelAllMediaOperationsResponse = callAsyncClient.cancelAllMediaOperationsWithResponse(callId, cancelMediaOperationContext, Context.NONE).block();
Response<CancelAllMediaOperationsResponse> cancelAllMediaOperationsResponse = callAsyncClient.cancelAllMediaOperationsWithResponse(callId, cancelMediaOperationContext).block();
CallingServerTestUtils.validateCancelAllMediaOperationsResponse(cancelAllMediaOperationsResponse, cancelMediaOperationContext);

// Hang up
Response<Void> hangupResponse = callAsyncClient.hangupCallWithResponse(callId, Context.NONE).block();
Response<Void> hangupResponse = callAsyncClient.hangupCallWithResponse(callId).block();
CallingServerTestUtils.validateResponse(hangupResponse);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
@@ -186,24 +184,23 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli
Response<CreateCallResponse> createCallResponse = callAsyncClient.createCallWithResponse(
new CommunicationUserIdentifier(from),
new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) },
options,
Context.NONE).block();
options).block();

CallingServerTestUtils.validateCreateCallResponse(createCallResponse);
String callId = createCallResponse.getValue().getCallLegId();

// Invite User
String operationContext = "ac794123-3820-4979-8e2d-50c7d3e07b12";
Response<Void> inviteParticipantResponse = callAsyncClient.addParticipantWithResponse(callId, new CommunicationUserIdentifier(invitedUser), null, operationContext, Context.NONE).block();
Response<Void> inviteParticipantResponse = callAsyncClient.addParticipantWithResponse(callId, new CommunicationUserIdentifier(invitedUser), null, operationContext).block();
CallingServerTestUtils.validateResponse(inviteParticipantResponse);

// Remove Participant
String participantId = "4c100bf4-304c-48e0-87a8-03597ec75464";
Response<Void> removeParticipantResponse = callAsyncClient.removeParticipantWithResponse(callId, participantId, Context.NONE).block();
Response<Void> removeParticipantResponse = callAsyncClient.removeParticipantWithResponse(callId, participantId).block();
CallingServerTestUtils.validateResponse(removeParticipantResponse);

// Hang up
Response<Void> hangupResponse = callAsyncClient.hangupCallWithResponse(callId, Context.NONE).block();
Response<Void> hangupResponse = callAsyncClient.hangupCallWithResponse(callId).block();
CallingServerTestUtils.validateResponse(hangupResponse);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
@@ -260,14 +257,13 @@ public void runCreateDeleteScenarioWithResponseAsync(HttpClient httpClient) thro
Response<CreateCallResponse> createCallResponse = callAsyncClient.createCallWithResponse(
new CommunicationUserIdentifier(from),
new CommunicationIdentifier[] { new PhoneNumberIdentifier(to) },
options,
Context.NONE).block();
options).block();

CallingServerTestUtils.validateCreateCallResponse(createCallResponse);
String callId = createCallResponse.getValue().getCallLegId();

// Delete Call
Response<Void> hangupResponse = callAsyncClient.deleteCallWithResponse(callId, Context.NONE).block();
Response<Void> hangupResponse = callAsyncClient.deleteCallWithResponse(callId).block();
CallingServerTestUtils.validateResponse(hangupResponse);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());

0 comments on commit 4459456

Please sign in to comment.