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

add mediaSubscriptionId field to CallConnectionProperties class #30871

Merged
merged 6 commits into from
Sep 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -9,6 +9,7 @@
import com.azure.communication.callautomation.implementation.models.CallConnectionPropertiesInternal;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -27,6 +28,7 @@ public final class CallConnectionProperties {
private final CallConnectionState callConnectionState;
private final String subject;
private final URI callbackUri;
private final String mediaSubscriptionId;

static {
CallConnectionPropertiesConstructorProxy.setAccessor(
Expand All @@ -50,6 +52,7 @@ public CallConnectionProperties() {
this.callConnectionState = null;
this.subject = null;
this.callbackUri = null;
this.mediaSubscriptionId = null;
}

/**
Expand All @@ -66,6 +69,7 @@ public CallConnectionProperties() {
this.callConnectionState = CallConnectionState.fromString(callConnectionPropertiesInternal.getCallConnectionState().toString());
this.subject = callConnectionPropertiesInternal.getSubject();
this.callbackUri = new URI(callConnectionPropertiesInternal.getCallbackUri());
this.mediaSubscriptionId = callConnectionPropertiesInternal.getMediaSubscriptionId();
}

/**
Expand Down Expand Up @@ -131,4 +135,11 @@ public String getCallConnectionId() {
return callConnectionId;
}

/**
* Get the mediaSubscriptionId property: SubscriptionId for media streaming.
*
* @return the mediaSubscriptionId value.
*/
public String getMediaSubscriptionId() { return mediaSubscriptionId; }

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void createCall() {
CallAutomationAsyncClient callAutomationAsyncClient = getCallAutomationAsyncClient(new ArrayList<>(
Collections.singletonList(
new AbstractMap.SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 201)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, null), 201)
)));
CommunicationUserIdentifier caller = new CommunicationUserIdentifier(CALL_CALLER_ID);
List<CommunicationIdentifier> targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID)));
Expand All @@ -43,7 +43,7 @@ public void createCallWithResponse() {
CallAutomationAsyncClient callAutomationAsyncClient = getCallAutomationAsyncClient(new ArrayList<>(
Collections.singletonList(
new AbstractMap.SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 201)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 201)
)));
CommunicationUserIdentifier caller = new CommunicationUserIdentifier(CALL_CALLER_ID);
List<CommunicationIdentifier> targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID)));
Expand All @@ -56,14 +56,15 @@ public void createCallWithResponse() {
assertNotNull(createCallResult);
assertEquals(201, createCallResult.getStatusCode());
assertNotNull(createCallResult.getValue());
assertEquals("mediaSubscriptionId", null);
}

@Test
public void answerCall() {
CallAutomationAsyncClient callAutomationAsyncClient = getCallAutomationAsyncClient(new ArrayList<>(
Collections.singletonList(
new AbstractMap.SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, null), 200)
)));

AnswerCallResult answerCallResult = callAutomationAsyncClient.answerCall(CALL_INCOMING_CALL_CONTEXT, CALL_CALLBACK_URL).block();
Expand All @@ -76,7 +77,7 @@ public void answerCallWithResponse() {
CallAutomationAsyncClient callAutomationAsyncClient = getCallAutomationAsyncClient(new ArrayList<>(
Collections.singletonList(
new AbstractMap.SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, null), 200)
)));

Response<AnswerCallResult> answerCallResult = callAutomationAsyncClient.answerCallWithResponse(
Expand All @@ -85,6 +86,7 @@ public void answerCallWithResponse() {
assertNotNull(answerCallResult);
assertEquals(200, answerCallResult.getStatusCode());
assertNotNull(answerCallResult.getValue());
assertEquals("mediaSubscriptionId", null);
atazimsft marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void createCall() {
CallAutomationClient callAutomationClient = getCallAutomationClient(new ArrayList<>(
Collections.singletonList(
new SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 201)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 201)
)));
CommunicationUserIdentifier caller = new CommunicationUserIdentifier(CALL_CALLER_ID);
List<CommunicationIdentifier> targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID)));
Expand All @@ -46,7 +46,7 @@ public void createCallWithResponse() {
CallAutomationClient callAutomationClient = getCallAutomationClient(new ArrayList<>(
Collections.singletonList(
new SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 201)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, null), 201)
)));
CommunicationUserIdentifier caller = new CommunicationUserIdentifier(CALL_CALLER_ID);
List<CommunicationIdentifier> targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID)));
Expand All @@ -58,14 +58,15 @@ public void createCallWithResponse() {
assertNotNull(createCallResult);
assertEquals(201, createCallResult.getStatusCode());
assertNotNull(createCallResult.getValue());
assertEquals("mediaSubscriptionId", null);
}

@Test
public void answerCall() {
CallAutomationClient callAutomationClient = getCallAutomationClient(new ArrayList<>(
Collections.singletonList(
new SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
)));

AnswerCallResult answerCallResult = callAutomationClient.answerCall(CALL_INCOMING_CALL_CONTEXT, CALL_CALLBACK_URL);
Expand All @@ -78,7 +79,7 @@ public void answerCallWithResponse() {
CallAutomationClient callAutomationClient = getCallAutomationClient(new ArrayList<>(
Collections.singletonList(
new SimpleEntry<>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
atazimsft marked this conversation as resolved.
Show resolved Hide resolved
)));

Response<AnswerCallResult> answerCallResult = callAutomationClient.answerCallWithResponse(
Expand All @@ -87,6 +88,7 @@ public void answerCallWithResponse() {
assertNotNull(answerCallResult);
assertEquals(200, answerCallResult.getStatusCode());
assertNotNull(answerCallResult.getValue());
assertEquals("mediaSubscriptionId", answerCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class CallAutomationUnitTestBase {
static final String CALL_CALLBACK_URL = "https://REDACTED.com/events";
static final String CALL_INCOMING_CALL_CONTEXT = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.REDACTED";
static final String CALL_OPERATION_CONTEXT = "operationContext";
static final String MEDIA_SUBSCRIPTION_ID = "mediaSubscriptionId";

static final MediaStreamingConfiguration MEDIA_STREAMING_CONFIGURATION = new MediaStreamingConfiguration(
"https://websocket.url.com",
Expand All @@ -55,13 +56,15 @@ public static String generateDownloadResult(String content) {
}

public static String generateCallProperties(String callConnectionId, String serverCallId, String callerId,
String targetId, String connectionState, String subject, String callbackUri) {
String targetId, String connectionState, String subject, String callbackUri,
String mediaSubscriptionId) {
CallConnectionPropertiesInternal result = new CallConnectionPropertiesInternal()
.setCallConnectionId(callConnectionId)
.setServerCallId(serverCallId)
.setCallbackUri(callbackUri)
.setSubject(subject)
.setCallConnectionState(CallConnectionStateModelInternal.fromString(connectionState))
.setMediaSubscriptionId(mediaSubscriptionId)
.setSource(new CallSourceInternal()
.setIdentifier(ModelGenerator.generateUserIdentifierModel(callerId)))
.setTargets(new ArrayList<>(Collections.singletonList(ModelGenerator.generateUserIdentifierModel(targetId)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void getCallProperties() {
CallConnectionAsync callConnectionAsync = getCallAutomationAsyncClient(new ArrayList<SimpleEntry<String, Integer>>(
Arrays.asList(
new SimpleEntry<String, Integer>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
)))
.getCallConnectionAsync(CALL_CONNECTION_ID);

Expand All @@ -44,7 +44,7 @@ public void getCallPropertiesWithResponse() {
CallConnectionAsync callConnectionAsync = getCallAutomationAsyncClient(new ArrayList<SimpleEntry<String, Integer>>(
Arrays.asList(
new SimpleEntry<String, Integer>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
)))
.getCallConnectionAsync(CALL_CONNECTION_ID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void getCallProperties() {
CallConnection callConnection = getCallAutomationClient(new ArrayList<SimpleEntry<String, Integer>>(
Arrays.asList(
new SimpleEntry<String, Integer>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
)))
.getCallConnection(CALL_CONNECTION_ID);

Expand All @@ -46,7 +46,7 @@ public void getCallPropertiesWithResponse() {
CallConnection callConnection = getCallAutomationClient(new ArrayList<SimpleEntry<String, Integer>>(
Arrays.asList(
new SimpleEntry<String, Integer>(generateCallProperties(CALL_CONNECTION_ID, CALL_SERVER_CALL_ID,
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL), 200)
CALL_CALLER_ID, CALL_TARGET_ID, CALL_CONNECTION_STATE, CALL_SUBJECT, CALL_CALLBACK_URL, MEDIA_SUBSCRIPTION_ID), 200)
)))
.getCallConnection(CALL_CONNECTION_ID);

Expand Down