Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live test fixes #22312

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This is a Public Preview version, so breaking changes are possible in subsequent
- Play audio in the call.
- Outbound APIs for call recording including start, pause, resume and stop.
- Subscribe to tone and receive tone selections via events.
- Invite and remove participants from the call.
- Add and remove participants from the call.

<!-- LINKS -->
[read_me]: https://github.com/Azure/azure-sdk-for-java/blob/feature/communication-ServerCalling/sdk/communication/azure-communication-callingserver/README.md
Expand Down
7 changes: 4 additions & 3 deletions sdk/communication/azure-communication-callingserver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ CommunicationIdentifier[] targets = new CommunicationIdentifier[] { firstCallee,

String callbackUri = "<callback-uri-for-notification>";

CallModality[] requestedMediaTypes = new CallModality[] { CallModality.AUDIO, CallModality.VIDEO };
MediaType[] requestedMediaTypes = new MediaType[] { MediaType.AUDIO, MediaType.VIDEO };

EventSubscriptionType[] requestedCallEvents = new EventSubscriptionType[] {
EventSubscriptionType.DTMF_RECEIVED,
EventSubscriptionType.PARTICIPANTS_UPDATED };
EventSubscriptionType.DTMF_RECEIVED,
EventSubscriptionType.PARTICIPANTS_UPDATED
};

CreateCallOptions createCallOptions = new CreateCallOptions(
callbackUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public Response<CancelAllMediaOperationsResult> cancelAllMediaOperationsWithResp
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
Expand All @@ -191,7 +191,7 @@ public AddParticipantResult addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.azure.communication.callingserver.implementation.CallConnectionsImpl;
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
import com.azure.communication.callingserver.implementation.converters.CancelAllMediaOperationsResultConverter;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.AddParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
import com.azure.communication.callingserver.implementation.models.AddParticipantRequest;
import com.azure.communication.callingserver.implementation.models.CancelAllMediaOperationsRequest;
Expand Down Expand Up @@ -337,7 +337,7 @@ Mono<Response<CancelAllMediaOperationsResult>> cancelAllMediaOperationsWithRespo
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
Expand All @@ -350,7 +350,7 @@ public Mono<AddParticipantResult> addParticipant(
String operationContext) {
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
AddParticipantRequest request = InviteParticipantRequestConverter.convert(participant,
AddParticipantRequest request = AddParticipantRequestConverter.convert(participant,
alternateCallerId,
operationContext,
null);
Expand All @@ -365,7 +365,7 @@ public Mono<AddParticipantResult> addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
* communications related to this operation
Expand All @@ -387,7 +387,7 @@ Mono<Response<AddParticipantResult>> addParticipantWithResponse(
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
AddParticipantRequest request =
InviteParticipantRequestConverter
AddParticipantRequestConverter
.convert(participant, alternateCallerId, operationContext, null);
return withContext(contextValue -> {
contextValue = context == null ? contextValue : context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public String getServerCallId() {
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param callBackUri callBackUri to get notifications.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
Expand All @@ -55,7 +55,7 @@ public AddParticipantResult addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param callBackUri callBackUri to get notifications.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import com.azure.communication.callingserver.implementation.ServerCallsImpl;
import com.azure.communication.callingserver.implementation.converters.CallingServerErrorConverter;
import com.azure.communication.callingserver.implementation.converters.InviteParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.AddParticipantRequestConverter;
import com.azure.communication.callingserver.implementation.converters.PlayAudioResultConverter;
import com.azure.communication.callingserver.implementation.models.AddParticipantRequest;
import com.azure.communication.callingserver.implementation.models.CommunicationErrorResponseException;
Expand Down Expand Up @@ -58,7 +58,7 @@ public String getServerCallId() {
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param callBackUri callBackUri to get notifications.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
Expand All @@ -74,7 +74,7 @@ public Mono<AddParticipantResult> addParticipant(
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
AddParticipantRequest request =
InviteParticipantRequestConverter.convert(participant,
AddParticipantRequestConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
Expand All @@ -89,7 +89,7 @@ public Mono<AddParticipantResult> addParticipant(
/**
* Add a participant to the call.
*
* @param participant Invited participant.
* @param participant Added participant.
* @param callBackUri callBackUri to get notifications.
* @param alternateCallerId The phone number to use when adding a phone number participant.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
Expand Down Expand Up @@ -118,7 +118,7 @@ Mono<Response<AddParticipantResult>> addParticipantWithResponse(
try {
Objects.requireNonNull(participant, "'participant' cannot be null.");
AddParticipantRequest request =
InviteParticipantRequestConverter.convert(participant,
AddParticipantRequestConverter.convert(participant,
alternateCallerId,
operationContext,
callBackUri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* A converter for {@link AddParticipantRequest}
*/
public final class InviteParticipantRequestConverter {
public final class AddParticipantRequestConverter {

/**
* Converts to {@link AddParticipantRequest}.
Expand All @@ -37,6 +37,6 @@ public static AddParticipantRequest convert(
.setCallbackUri(callBackUri);
}

private InviteParticipantRequestConverter() {
private AddParticipantRequestConverter() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public OperationStatus getStatus() {
}

/**
* Initializes a new instance of InviteParticipantResultEvent.
* Initializes a new instance of AddParticipantResultEvent.
*
* @param resultInfo the resultInfo value.
* @param operationContext The value to identify context of the operation. This is used to co-relate other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public final class CallingServerEventType extends ExpandableStringEnum<CallingSe
/** The call connection state change event type. */
public static final CallingServerEventType CALL_CONNECTION_STATE_CHANGED_EVENT = fromString("Microsoft.Communication.CallConnectionStateChanged");

/** The invited participants result event type. */
/** The add participant result event type. */
public static final CallingServerEventType ADD_PARTICIPANT_RESULT_EVENT = fromString("Microsoft.Communication.AddParticipantResult");

/** The call recording state change event type. */
Expand All @@ -42,7 +42,7 @@ public static CallingServerEventType fromString(String name) {
return fromString(name, CallingServerEventType.class);
}

/** @return known CallModality values. */
/** @return known CallingServerEventType values. */
public static Collection<CallingServerEventType> values() {
return values(CallingServerEventType.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
// Licensed under the MIT License.
package com.azure.communication.callingserver;

import java.util.UUID;

import com.azure.communication.callingserver.models.AddParticipantResult;
import com.azure.communication.callingserver.models.CancelAllMediaOperationsResult;
import com.azure.communication.callingserver.models.EventSubscriptionType;
import com.azure.communication.callingserver.models.CreateCallOptions;
import com.azure.communication.callingserver.models.EventSubscriptionType;
import com.azure.communication.callingserver.models.JoinCallOptions;
import com.azure.communication.callingserver.models.MediaType;
import com.azure.communication.callingserver.models.PlayAudioResult;
Expand All @@ -17,11 +15,11 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestMode;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import java.util.UUID;

public class CallConnectionAsyncLiveTests extends CallingServerTestBase {

private final String fromUser = getNewUserId();
Expand All @@ -36,7 +34,7 @@ public void runCreatePlayCancelHangupScenarioAsync(HttpClient httpClient) {
if (this.getTestMode() == TestMode.LIVE) {
System.out.println("Warning: Test is skipped, does not support live mode.");
return;
}
}

CallingServerClientBuilder builder = getCallClientUsingConnectionString(httpClient);
CallingServerAsyncClient callingServerAsyncClient =
Expand Down Expand Up @@ -174,22 +172,16 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) {

CallingServerTestUtils.validateCallConnectionAsync(callConnectionAsync);

// Invite User
// Add User
String operationContext = UUID.randomUUID().toString();
assert callConnectionAsync != null;
callConnectionAsync.addParticipant(
AddParticipantResult addParticipantResult = callConnectionAsync.addParticipant(
new CommunicationUserIdentifier(toUser),
null,
operationContext).block();

// Remove Participant
/*
There is an update that we require to be able to get
the participantId from the service when a user is
added to a call. Until that is fixed this recorded
value needs to be used.
*/
String participantId = "e3560385-776f-41d1-bf04-07ef738f2fc1";
assert addParticipantResult != null;
String participantId = addParticipantResult.getParticipantId();
callConnectionAsync.removeParticipant(participantId).block();

// Hang up
Expand All @@ -201,7 +193,6 @@ public void runCreateAddRemoveHangupScenarioAsync(HttpClient httpClient) {
}

@ParameterizedTest
@Disabled
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpClient) {

Expand Down Expand Up @@ -235,23 +226,17 @@ public void runCreateAddRemoveHangupScenarioWithResponseAsync(HttpClient httpCli
assert callConnectionAsyncResponse != null;
CallConnectionAsync callConnectionAsync = callConnectionAsyncResponse.getValue();

// Invite User
// Add User
String operationContext = UUID.randomUUID().toString();
Response<AddParticipantResult> inviteParticipantResponse =
Response<AddParticipantResult> addParticipantResponse =
callConnectionAsync.addParticipantWithResponse(
new CommunicationUserIdentifier(toUser),
null,
operationContext).block();
CallingServerTestUtils.validateAddParticipantResponse(inviteParticipantResponse);
CallingServerTestUtils.validateAddParticipantResponse(addParticipantResponse);

// Remove Participant
/*
There is an update that we require to be able to get
the participantId from the service when a user is
added to a call. Until that is fixed this recorded
value needs to be used.
*/
String participantId = "80238d5f-9eda-481a-b911-e2e12eba9eda";
assert addParticipantResponse != null;
String participantId = addParticipantResponse.getValue().getParticipantId();
Response<Void> removeParticipantResponse =
callConnectionAsync.removeParticipantWithResponse(participantId).block();
CallingServerTestUtils.validateResponse(removeParticipantResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestMode;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

Expand Down Expand Up @@ -174,16 +172,9 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) {

// Add User
String operationContext = UUID.randomUUID().toString();
callConnection.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext);
AddParticipantResult addParticipantResult = callConnection.addParticipant(new CommunicationUserIdentifier(toUser), null, operationContext);

// Remove Participant
/*
There is an update that we require to be able to get
the participantId from the service when a user is
added to a call. Until that is fixed this recorded
value needs to be used.
*/
String participantId = "f29f70e3-1eaf-44c0-839c-b4e8a74ffec3";
String participantId = addParticipantResult.getParticipantId();
callConnection.removeParticipant(participantId);

// Hang up
Expand All @@ -195,7 +186,6 @@ public void runCreateAddRemoveHangupScenario(HttpClient httpClient) {
}

@ParameterizedTest
@Disabled
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient) {

Expand Down Expand Up @@ -231,22 +221,15 @@ public void runCreateAddRemoveHangupScenarioWithResponse(HttpClient httpClient)

// Add User
String operationContext = UUID.randomUUID().toString();
Response<AddParticipantResult> inviteParticipantResponse = callConnection
Response<AddParticipantResult> addParticipantResponse = callConnection
.addParticipantWithResponse(
new CommunicationUserIdentifier(toUser),
null,
operationContext,
null);
CallingServerTestUtils.validateAddParticipantResponse(inviteParticipantResponse);
CallingServerTestUtils.validateAddParticipantResponse(addParticipantResponse);

// Remove Participant
/*
There is an update that we require to be able to get
the participantId from the service when a user is
added to a call. Until that is fixed this recorded
value needs to be used.
*/
String participantId = "71ed956b-366e-450c-9a61-3bbccf42baa5";
String participantId = addParticipantResponse.getValue().getParticipantId();
Response<Void> removeParticipantResponse =
callConnection.removeParticipantWithResponse(participantId, null);
CallingServerTestUtils.validateResponse(removeParticipantResponse);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected static void validateResponse(Response<Void> response) {

protected static void validateAddParticipantResponse(Response<AddParticipantResult> response) {
assertNotNull(response);
Assertions.assertEquals(200, response.getStatusCode());
Assertions.assertEquals(202, response.getStatusCode());
assertNotNull(response.getValue());
validateAddParticipantResult(response.getValue());
}
Expand Down
Loading