Skip to content

Commit

Permalink
add mediaSubscriptionId field to CallConnectionProperties class (Azur…
Browse files Browse the repository at this point in the history
…e#30871)

* add mediaSubscriptionId field to CallConnectionProperties class

* update unit tests

* test case where mediastreamingconfiguration is not provided

* update unit test assertion

* correct unit test

* fix test and remove unused imports
  • Loading branch information
atazimsft authored Sep 14, 2022
1 parent b54306d commit 16ef796
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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 +51,7 @@ public CallConnectionProperties() {
this.callConnectionState = null;
this.subject = null;
this.callbackUri = null;
this.mediaSubscriptionId = null;
}

/**
Expand All @@ -66,6 +68,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 +134,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", createCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId());
}

@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, MEDIA_SUBSCRIPTION_ID), 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", answerCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId());
}

@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(null, createCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId());
}

@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)
)));

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

0 comments on commit 16ef796

Please sign in to comment.