From 16ef796b33afa63667722a8d61f8e4251418f36a Mon Sep 17 00:00:00 2001 From: atazimsft <89811028+atazimsft@users.noreply.github.com> Date: Wed, 14 Sep 2022 12:09:06 -0700 Subject: [PATCH] add mediaSubscriptionId field to CallConnectionProperties class (#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 --- .../models/CallConnectionProperties.java | 10 ++++++++++ .../CallAutomationAsyncClientUnitTests.java | 10 ++++++---- .../callautomation/CallAutomationClientUnitTests.java | 10 ++++++---- .../callautomation/CallAutomationUnitTestBase.java | 5 ++++- .../callautomation/CallConnectionAsyncUnitTests.java | 4 ++-- .../callautomation/CallConnectionUnitTests.java | 4 ++-- 6 files changed, 30 insertions(+), 13 deletions(-) diff --git a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallConnectionProperties.java b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallConnectionProperties.java index d0cf787d908f0..ebd481521c267 100644 --- a/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallConnectionProperties.java +++ b/sdk/communication/azure-communication-callautomation/src/main/java/com/azure/communication/callautomation/models/CallConnectionProperties.java @@ -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( @@ -50,6 +51,7 @@ public CallConnectionProperties() { this.callConnectionState = null; this.subject = null; this.callbackUri = null; + this.mediaSubscriptionId = null; } /** @@ -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(); } /** @@ -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; } + } diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientUnitTests.java index d1179e525a322..62f79c6098392 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientUnitTests.java @@ -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 targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID))); @@ -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 targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID))); @@ -56,6 +56,7 @@ public void createCallWithResponse() { assertNotNull(createCallResult); assertEquals(201, createCallResult.getStatusCode()); assertNotNull(createCallResult.getValue()); + assertEquals("mediaSubscriptionId", createCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId()); } @Test @@ -63,7 +64,7 @@ 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(); @@ -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 = callAutomationAsyncClient.answerCallWithResponse( @@ -85,6 +86,7 @@ public void answerCallWithResponse() { assertNotNull(answerCallResult); assertEquals(200, answerCallResult.getStatusCode()); assertNotNull(answerCallResult.getValue()); + assertEquals("mediaSubscriptionId", answerCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId()); } @Test diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationClientUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationClientUnitTests.java index 277c63e724578..8f19ab7749caa 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationClientUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationClientUnitTests.java @@ -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 targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID))); @@ -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 targets = new ArrayList<>(Collections.singletonList(new CommunicationUserIdentifier(CALL_TARGET_ID))); @@ -58,6 +58,7 @@ public void createCallWithResponse() { assertNotNull(createCallResult); assertEquals(201, createCallResult.getStatusCode()); assertNotNull(createCallResult.getValue()); + assertEquals(null, createCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId()); } @Test @@ -65,7 +66,7 @@ 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); @@ -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 = callAutomationClient.answerCallWithResponse( @@ -87,6 +88,7 @@ public void answerCallWithResponse() { assertNotNull(answerCallResult); assertEquals(200, answerCallResult.getStatusCode()); assertNotNull(answerCallResult.getValue()); + assertEquals("mediaSubscriptionId", answerCallResult.getValue().getCallConnectionProperties().getMediaSubscriptionId()); } @Test diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationUnitTestBase.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationUnitTestBase.java index e1d68d9302f39..b8b96d05c7f40 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationUnitTestBase.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationUnitTestBase.java @@ -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", @@ -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))) diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncUnitTests.java index 95e7715ff5379..45d6e7b31229b 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncUnitTests.java @@ -30,7 +30,7 @@ public void getCallProperties() { CallConnectionAsync callConnectionAsync = getCallAutomationAsyncClient(new ArrayList>( Arrays.asList( 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) ))) .getCallConnectionAsync(CALL_CONNECTION_ID); @@ -44,7 +44,7 @@ public void getCallPropertiesWithResponse() { CallConnectionAsync callConnectionAsync = getCallAutomationAsyncClient(new ArrayList>( Arrays.asList( 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) ))) .getCallConnectionAsync(CALL_CONNECTION_ID); diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionUnitTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionUnitTests.java index d381dacecd8f7..7abeedee4ceb7 100644 --- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionUnitTests.java +++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionUnitTests.java @@ -32,7 +32,7 @@ public void getCallProperties() { CallConnection callConnection = getCallAutomationClient(new ArrayList>( Arrays.asList( 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) ))) .getCallConnection(CALL_CONNECTION_ID); @@ -46,7 +46,7 @@ public void getCallPropertiesWithResponse() { CallConnection callConnection = getCallAutomationClient(new ArrayList>( Arrays.asList( 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) ))) .getCallConnection(CALL_CONNECTION_ID);