addConfigurationSetting(String key, String lab
/**
* Adds a configuration value in the service if that key and label does not exist. The label value of the
* ConfigurationSetting is optional.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -391,7 +389,7 @@ public Mono addConfigurationSetting(ConfigurationSetting s
/**
* Adds a configuration value in the service if that key and label does not exist. The label value of the
* ConfigurationSetting is optional.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -429,9 +427,8 @@ public Mono> addConfigurationSettingWithResponse(
return withContext(
context -> validateSettingAsync(setting).flatMap(
settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(),
- settingInternal.getLabel(), null, ETAG_ANY, toKeyValue(settingInternal),
- addTracingNamespace(context))
- .map(response -> toConfigurationSettingWithResponse(response))));
+ settingInternal.getLabel(), null, ETAG_ANY, toKeyValue(settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -471,7 +468,7 @@ public Mono setConfigurationSetting(String key, String lab
/**
* Creates or updates a configuration value in the service. Partial updates are not supported and the entire
* configuration setting is updated.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -515,10 +512,10 @@ public Mono setConfigurationSetting(ConfigurationSetting s
/**
* Creates or updates a configuration value in the service. Partial updates are not supported and the entire
* configuration setting is updated.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
- *
+ *
* If {@link ConfigurationSetting#getETag() ETag} is specified, the configuration value is updated if the current
* setting's ETag matches. If the ETag's value is equal to the wildcard character ({@code "*"}), the setting will
* always be updated.
@@ -574,8 +571,8 @@ public Mono> setConfigurationSettingWithResponse(
context -> validateSettingAsync(setting).flatMap(
settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(),
settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), null,
- toKeyValue(settingInternal), addTracingNamespace(context))
- .map(response -> toConfigurationSettingWithResponse(response))));
+ toKeyValue(settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -716,25 +713,20 @@ public Mono getConfigurationSetting(ConfigurationSetting s
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono> getConfigurationSettingWithResponse(ConfigurationSetting setting,
OffsetDateTime acceptDateTime, boolean ifChanged) {
- return withContext(
- context -> validateSettingAsync(setting).flatMap(
- settingInternal ->
- serviceClient.getKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
- acceptDateTime == null ? null : acceptDateTime.toString(), null,
- getETag(ifChanged, settingInternal), null, addTracingNamespace(context))
- .onErrorResume(
- HttpResponseException.class,
- (Function>>) throwable -> {
- HttpResponseException e = (HttpResponseException) throwable;
- HttpResponse httpResponse = e.getResponse();
- if (httpResponse.getStatusCode() == 304) {
- return Mono.just(new ResponseBase(
- httpResponse.getRequest(), httpResponse.getStatusCode(),
- httpResponse.getHeaders(), null, null));
- }
- return Mono.error(throwable);
- })
- .map(response -> toConfigurationSettingWithResponse(response))));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal ->
+ serviceClient.getKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(),
+ acceptDateTime == null ? null : acceptDateTime.toString(), null,
+ getETag(ifChanged, settingInternal), null, context)
+ .onErrorResume(HttpResponseException.class,
+ (Function>>) throwable -> {
+ HttpResponseException e = (HttpResponseException) throwable;
+ HttpResponse httpResponse = e.getResponse();
+ if (httpResponse.getStatusCode() == 304) {
+ return Mono.just(new ResponseBase(httpResponse.getRequest(),
+ httpResponse.getStatusCode(), httpResponse.getHeaders(), null, null));
+ }
+ return Mono.error(throwable);
+ }).map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -770,7 +762,7 @@ public Mono deleteConfigurationSetting(String key, String
* {@link ConfigurationSetting#getLabel() label} and optional ETag combination from the service.
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
- *
+ *
* If {@link ConfigurationSetting#getETag() ETag} is specified and is not the wildcard character ({@code "*"}), then
* the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the
* ConfigurationSetting yet.
@@ -809,10 +801,10 @@ public Mono deleteConfigurationSetting(ConfigurationSettin
/**
* Deletes the {@link ConfigurationSetting} with a matching {@link ConfigurationSetting#getKey() key}, and optional
* {@link ConfigurationSetting#getLabel() label} and optional ETag combination from the service.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
- *
+ *
* If {@link ConfigurationSetting#getETag() ETag} is specified and is not the wildcard character ({@code "*"}), then
* the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the
* ConfigurationSetting yet.
@@ -855,8 +847,8 @@ public Mono> deleteConfigurationSettingWithRespon
boolean ifUnchanged) {
return withContext(context -> validateSettingAsync(setting).flatMap(
settingInternal -> serviceClient.deleteKeyValueWithResponseAsync(settingInternal.getKey(),
- settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), addTracingNamespace(context))
- .map(response -> toConfigurationSettingWithResponse(response))));
+ settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse)));
}
/**
@@ -901,7 +893,7 @@ public Mono setReadOnly(String key, String label, boolean
/**
* Sets the read-only status for the {@link ConfigurationSetting}.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -949,7 +941,7 @@ public Mono setReadOnly(ConfigurationSetting setting, bool
/**
* Sets the read-only status for the {@link ConfigurationSetting}.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -1000,16 +992,14 @@ public Mono setReadOnly(ConfigurationSetting setting, bool
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono> setReadOnlyWithResponse(ConfigurationSetting setting,
boolean isReadOnly) {
- return withContext(context -> validateSettingAsync(setting).flatMap(
- settingInternal -> {
- final String key = settingInternal.getKey();
- final String label = settingInternal.getLabel();
- final Context contextInternal = addTracingNamespace(context);
- return (isReadOnly
- ? serviceClient.putLockWithResponseAsync(key, label, null, null, contextInternal)
- : serviceClient.deleteLockWithResponseAsync(key, label, null, null, contextInternal))
- .map(response -> toConfigurationSettingWithResponse(response));
- }));
+ return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> {
+ final String key = settingInternal.getKey();
+ final String label = settingInternal.getLabel();
+ return (isReadOnly
+ ? serviceClient.putLockWithResponseAsync(key, label, null, null, context)
+ : serviceClient.deleteLockWithResponseAsync(key, label, null, null, context))
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse);
+ }));
}
/**
@@ -1042,31 +1032,19 @@ public PagedFlux listConfigurationSettings(SettingSelector
final List settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
final List matchConditionsList = selector == null ? null : selector.getMatchConditions();
AtomicInteger pageETagIndex = new AtomicInteger(0);
- return new PagedFlux<>(
- () -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(
- keyFilter,
- labelFilter,
- null,
- acceptDateTime,
- settingFields,
- null,
- null,
- getPageETag(matchConditionsList, pageETagIndex),
- addTracingNamespace(context))
- .onErrorResume(HttpResponseException.class,
- (Function>>) throwable ->
- handleNotModifiedErrorToValidResponse(throwable))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse))),
- nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(
- nextLink,
- acceptDateTime,
- null,
- getPageETag(matchConditionsList, pageETagIndex),
- addTracingNamespace(context))
- .onErrorResume(HttpResponseException.class,
- (Function>>) throwable ->
- handleNotModifiedErrorToValidResponse(throwable))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse)))
+ return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(keyFilter,
+ labelFilter, null, acceptDateTime, settingFields, null, null,
+ getPageETag(matchConditionsList, pageETagIndex), context)
+ .onErrorResume(HttpResponseException.class,
+ (Function>>)
+ Utility::handleNotModifiedErrorToValidResponse)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
+ nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink,
+ acceptDateTime, null, getPageETag(matchConditionsList, pageETagIndex), context)
+ .onErrorResume(HttpResponseException.class,
+ (Function>>)
+ Utility::handleNotModifiedErrorToValidResponse)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))
);
}
@@ -1124,29 +1102,13 @@ public PagedFlux listConfigurationSettingsForSnapshot(Stri
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listConfigurationSettingsForSnapshot(String snapshotName,
- List fields) {
- return new PagedFlux<>(
- () -> withContext(
- context -> serviceClient.getKeyValuesSinglePageAsync(
- null,
- null,
- null,
- null,
- fields,
- snapshotName,
- null,
- null,
- addTracingNamespace(context))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse))),
- nextLink -> withContext(
- context -> serviceClient.getKeyValuesNextSinglePageAsync(
- nextLink,
- null,
- null,
- null,
- addTracingNamespace(context))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse)))
- );
+ List fields) {
+ return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(null, null, null,
+ null, fields, snapshotName, null, null, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
+ nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null,
+ context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
}
/**
@@ -1154,7 +1116,7 @@ public PagedFlux listConfigurationSettingsForSnapshot(Stri
* in descending order from their {@link ConfigurationSetting#getLastModified() lastModified} date.
* Revisions expire after a period of time, see Pricing
* for more information.
- *
+ *
* If {@code selector} is {@code null}, then all the {@link ConfigurationSetting ConfigurationSettings} are fetched
* in their current state. Otherwise, the results returned match the parameters given in {@code selector}.
*
@@ -1181,21 +1143,12 @@ public PagedFlux listRevisions(SettingSelector selector) {
final String labelFilter = selector == null ? null : selector.getLabelFilter();
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
final List settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
- return new PagedFlux<>(
- () -> withContext(
- context -> serviceClient.getRevisionsSinglePageAsync(
- keyFilter,
- labelFilter,
- null,
- acceptDateTime,
- settingFields,
- addTracingNamespace(context))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse))),
- nextLink -> withContext(
- context ->
- serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime,
- addTracingNamespace(context))
- .map(pagedResponse -> toConfigurationSettingWithPagedResponse(pagedResponse))));
+ return new PagedFlux<>(() -> withContext(context -> serviceClient.getRevisionsSinglePageAsync(keyFilter,
+ labelFilter, null, acceptDateTime, settingFields, context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)),
+ nextLink -> withContext(context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime,
+ context)
+ .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)));
}
/**
@@ -1440,17 +1393,11 @@ public Mono> recoverSnapshotWithResponse(
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux listSnapshots(SnapshotSelector selector) {
try {
- return new PagedFlux<>(
- () -> withContext(
- context -> serviceClient.getSnapshotsSinglePageAsync(
- selector == null ? null : selector.getNameFilter(),
- null,
- selector == null ? null : selector.getFields(),
- selector == null ? null : selector.getStatus(),
- addTracingNamespace(context))),
- nextLink -> withContext(
- context -> serviceClient.getSnapshotsNextSinglePageAsync(nextLink, addTracingNamespace(context)))
- );
+ return new PagedFlux<>(() -> withContext(context -> serviceClient.getSnapshotsSinglePageAsync(
+ selector == null ? null : selector.getNameFilter(), null,
+ selector == null ? null : selector.getFields(), selector == null ? null : selector.getStatus(),
+ context)), nextLink -> withContext(context ->
+ serviceClient.getSnapshotsNextSinglePageAsync(nextLink, context)));
} catch (RuntimeException ex) {
return new PagedFlux<>(() -> monoError(LOGGER, ex));
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
index 94d07ff34f5c..30e97c8af057 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java
@@ -46,8 +46,6 @@
import static com.azure.data.appconfiguration.implementation.ConfigurationSettingDeserializationHelper.toConfigurationSettingWithPagedResponse;
import static com.azure.data.appconfiguration.implementation.ConfigurationSettingDeserializationHelper.toConfigurationSettingWithResponse;
import static com.azure.data.appconfiguration.implementation.Utility.ETAG_ANY;
-import static com.azure.data.appconfiguration.implementation.Utility.addTracingNamespace;
-import static com.azure.data.appconfiguration.implementation.Utility.enableSyncRestProxy;
import static com.azure.data.appconfiguration.implementation.Utility.getETag;
import static com.azure.data.appconfiguration.implementation.Utility.getPageETag;
import static com.azure.data.appconfiguration.implementation.Utility.handleNotModifiedErrorToValidResponse;
@@ -356,7 +354,7 @@ public ConfigurationSetting addConfigurationSetting(String key, String label, St
/**
* Adds a configuration value in the service if that key and label does not exist. The label value of the
* ConfigurationSetting is optional.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -392,7 +390,7 @@ public ConfigurationSetting addConfigurationSetting(ConfigurationSetting setting
/**
* Adds a configuration value in the service if that key and label does not exist. The label value of the
* ConfigurationSetting is optional.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -433,7 +431,7 @@ public Response addConfigurationSettingWithResponse(Config
// return an error.
final ResponseBase response =
serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), null, ETAG_ANY,
- toKeyValue(setting), enableSyncRestProxy(addTracingNamespace(context)));
+ toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -475,7 +473,7 @@ public ConfigurationSetting setConfigurationSetting(String key, String label, St
/**
* Creates or updates a configuration value in the service. Partial updates are not supported and the entire
* configuration setting is updated.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -521,10 +519,10 @@ public ConfigurationSetting setConfigurationSetting(ConfigurationSetting setting
/**
* Creates or updates a configuration value in the service. Partial updates are not supported and the entire
* configuration setting is updated.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
- *
+ *
* If {@link ConfigurationSetting#getETag() ETag} is specified, the configuration value is updated if the current
* setting's ETag matches. If the ETag's value is equal to the wildcard character ({@code "*"}), the setting will
* always be updated.
@@ -578,9 +576,8 @@ public Response setConfigurationSettingWithResponse(Config
boolean ifUnchanged, Context context) {
validateSetting(setting);
final ResponseBase response =
- serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(),
- getETag(ifUnchanged, setting), null, toKeyValue(setting),
- enableSyncRestProxy(addTracingNamespace(context)));
+ serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting),
+ null, toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -646,7 +643,7 @@ public ConfigurationSetting getConfigurationSetting(String key, String label, Of
/**
* Attempts to get the ConfigurationSetting with a matching {@link ConfigurationSetting#getKey() key}, and optional
* {@link ConfigurationSetting#getLabel() label}, optional {@code acceptDateTime} and optional ETag combination.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -681,7 +678,7 @@ public ConfigurationSetting getConfigurationSetting(ConfigurationSetting setting
/**
* Attempts to get the ConfigurationSetting with a matching {@link ConfigurationSetting#getKey() key}, and optional
* {@link ConfigurationSetting#getLabel() label}, optional {@code acceptDateTime} and optional ETag combination.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -725,8 +722,8 @@ public Response getConfigurationSettingWithResponse(Config
try {
final ResponseBase response =
serviceClient.getKeyValueWithResponse(setting.getKey(), setting.getLabel(),
- acceptDateTime == null ? null : acceptDateTime.toString(), null,
- getETag(ifChanged, setting), null, enableSyncRestProxy(addTracingNamespace(context)));
+ acceptDateTime == null ? null : acceptDateTime.toString(), null, getETag(ifChanged, setting), null,
+ context);
return toConfigurationSettingWithResponse(response);
} catch (HttpResponseException ex) {
final HttpResponse httpResponse = ex.getResponse();
@@ -769,7 +766,7 @@ public ConfigurationSetting deleteConfigurationSetting(String key, String label)
/**
* Deletes the {@link ConfigurationSetting} with a matching {@link ConfigurationSetting#getKey() key}, and optional
* {@link ConfigurationSetting#getLabel() label} and optional ETag combination.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -806,10 +803,10 @@ public ConfigurationSetting deleteConfigurationSetting(ConfigurationSetting sett
/**
* Deletes the {@link ConfigurationSetting} with a matching {@link ConfigurationSetting#getKey() key}, and optional
* {@link ConfigurationSetting#getLabel() label} and optional ETag combination.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
- *
+ *
* If {@link ConfigurationSetting#getETag() ETag} is specified and is not the wildcard character ({@code "*"}), then
* the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the
* ConfigurationSetting yet.
@@ -852,7 +849,7 @@ public Response deleteConfigurationSettingWithResponse(Con
validateSetting(setting);
final ResponseBase response =
serviceClient.deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(),
- getETag(ifUnchanged, setting), enableSyncRestProxy(addTracingNamespace(context)));
+ getETag(ifUnchanged, setting), context);
return toConfigurationSettingWithResponse(response);
}
@@ -898,7 +895,7 @@ public ConfigurationSetting setReadOnly(String key, String label, boolean isRead
/**
* Sets the read-only status for the {@link ConfigurationSetting}.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -945,7 +942,7 @@ public ConfigurationSetting setReadOnly(ConfigurationSetting setting, boolean is
/**
* Sets the read-only status for the {@link ConfigurationSetting}.
- *
+ *
* For more configuration setting types, see {@link FeatureFlagConfigurationSetting} and
* {@link SecretReferenceConfigurationSetting}.
*
@@ -995,7 +992,6 @@ public Response setReadOnlyWithResponse(ConfigurationSetti
validateSetting(setting);
final String key = setting.getKey();
final String label = setting.getLabel();
- context = enableSyncRestProxy(addTracingNamespace(context));
return isReadOnly
? toConfigurationSettingWithResponse(serviceClient.putLockWithResponse(key, label, null, null, context))
@@ -1061,34 +1057,21 @@ public PagedIterable listConfigurationSettings(SettingSele
final List settingFields = selector == null ? null : toSettingFieldsList(selector.getFields());
final List matchConditionsList = selector == null ? null : selector.getMatchConditions();
AtomicInteger pageETagIndex = new AtomicInteger(0);
- return new PagedIterable<>(
- () -> {
- PagedResponse pagedResponse;
- try {
- pagedResponse = serviceClient.getKeyValuesSinglePage(
- keyFilter,
- labelFilter,
- null,
- acceptDateTime,
- settingFields,
- null,
- null,
- getPageETag(matchConditionsList, pageETagIndex),
- enableSyncRestProxy(addTracingNamespace(context)));
- } catch (HttpResponseException ex) {
- return handleNotModifiedErrorToValidResponse(ex, LOGGER);
- }
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- },
+ return new PagedIterable<>(() -> {
+ PagedResponse pagedResponse;
+ try {
+ pagedResponse = serviceClient.getKeyValuesSinglePage(keyFilter, labelFilter, null, acceptDateTime,
+ settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex), context);
+ } catch (HttpResponseException ex) {
+ return handleNotModifiedErrorToValidResponse(ex, LOGGER);
+ }
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ },
nextLink -> {
PagedResponse pagedResponse;
try {
- pagedResponse = serviceClient.getKeyValuesNextSinglePage(
- nextLink,
- acceptDateTime,
- null,
- getPageETag(matchConditionsList, pageETagIndex),
- enableSyncRestProxy(addTracingNamespace(context)));
+ pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
+ getPageETag(matchConditionsList, pageETagIndex), context);
} catch (HttpResponseException ex) {
return handleNotModifiedErrorToValidResponse(ex, LOGGER);
}
@@ -1152,28 +1135,16 @@ public PagedIterable listConfigurationSettingsForSnapshot(
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listConfigurationSettingsForSnapshot(String snapshotName,
- List fields,
- Context context) {
- return new PagedIterable<>(
- () -> {
- final PagedResponse pagedResponse = serviceClient.getKeyValuesSinglePage(
- null,
- null,
- null,
- null,
- fields,
- snapshotName,
- null,
- null,
- enableSyncRestProxy(addTracingNamespace(context)));
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- },
- nextLink -> {
- final PagedResponse pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink,
- null, null, null, enableSyncRestProxy(addTracingNamespace(context)));
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- }
- );
+ List fields, Context context) {
+ return new PagedIterable<>(() -> {
+ final PagedResponse pagedResponse = serviceClient.getKeyValuesSinglePage(null, null, null, null,
+ fields, snapshotName, null, null, context);
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ }, nextLink -> {
+ final PagedResponse pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null,
+ null, context);
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ });
}
/**
@@ -1181,8 +1152,7 @@ public PagedIterable listConfigurationSettingsForSnapshot(
* in descending order from their {@link ConfigurationSetting#getLastModified() lastModified} date.
* Revisions expire after a period of time, see Pricing
* for more information.
- *
- *
+ *
* If {@code selector} is {@code null}, then all the {@link ConfigurationSetting ConfigurationSettings} are fetched
* in their current state. Otherwise, the results returned match the parameters given in {@code selector}.
*
@@ -1217,7 +1187,7 @@ public PagedIterable listRevisions(SettingSelector selecto
* in descending order from their {@link ConfigurationSetting#getLastModified() lastModified} date.
* Revisions expire after a period of time, see Pricing
* for more information.
- *
+ *
* If {@code selector} is {@code null}, then all the {@link ConfigurationSetting ConfigurationSettings} are fetched
* in their current state. Otherwise, the results returned match the parameters given in {@code selector}.
*
@@ -1243,23 +1213,16 @@ public PagedIterable listRevisions(SettingSelector selecto
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listRevisions(SettingSelector selector, Context context) {
final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime();
- return new PagedIterable<>(
- () -> {
- final PagedResponse pagedResponse = serviceClient.getRevisionsSinglePage(
- selector == null ? null : selector.getKeyFilter(),
- selector == null ? null : selector.getLabelFilter(),
- null,
- acceptDateTime,
- selector == null ? null : toSettingFieldsList(selector.getFields()),
- enableSyncRestProxy(addTracingNamespace(context)));
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- },
- nextLink -> {
- final PagedResponse pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink,
- acceptDateTime, enableSyncRestProxy(addTracingNamespace(context)));
- return toConfigurationSettingWithPagedResponse(pagedResponse);
- }
- );
+ return new PagedIterable<>(() -> {
+ final PagedResponse pagedResponse = serviceClient.getRevisionsSinglePage(
+ selector == null ? null : selector.getKeyFilter(), selector == null ? null : selector.getLabelFilter(),
+ null, acceptDateTime, selector == null ? null : toSettingFieldsList(selector.getFields()), context);
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ }, nextLink -> {
+ final PagedResponse pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink,
+ acceptDateTime, context);
+ return toConfigurationSettingWithPagedResponse(pagedResponse);
+ });
}
/**
@@ -1525,15 +1488,10 @@ public PagedIterable listSnapshots(SnapshotSelector selec
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listSnapshots(SnapshotSelector selector, Context context) {
- return new PagedIterable<>(
- () -> serviceClient.getSnapshotsSinglePage(
- selector == null ? null : selector.getNameFilter(),
- null,
- selector == null ? null : selector.getFields(),
- selector == null ? null : selector.getStatus(),
- enableSyncRestProxy(addTracingNamespace(context))),
- nextLink -> serviceClient.getSnapshotsNextSinglePage(nextLink,
- enableSyncRestProxy(addTracingNamespace(context))));
+ return new PagedIterable<>(() -> serviceClient.getSnapshotsSinglePage(
+ selector == null ? null : selector.getNameFilter(), null, selector == null ? null : selector.getFields(),
+ selector == null ? null : selector.getStatus(), context),
+ nextLink -> serviceClient.getSnapshotsNextSinglePage(nextLink, context));
}
/**
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
index a743a01d56bc..489a1b35b7d3 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java
@@ -12,6 +12,7 @@
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeader;
+import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
@@ -126,8 +127,8 @@ public final class ConfigurationClientBuilder implements
CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion");
ADD_HEADERS_POLICY = new AddHeadersPolicy(new HttpHeaders()
.set("x-ms-return-client-request-id", "true")
- .set("Content-Type", "application/json")
- .set("Accept", "application/vnd.microsoft.azconfig.kv+json"));
+ .set(HttpHeaderName.CONTENT_TYPE, "application/json")
+ .set(HttpHeaderName.ACCEPT, "application/vnd.microsoft.azconfig.kv+json"));
}
private static final ClientLogger LOGGER = new ClientLogger(ConfigurationClientBuilder.class);
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/Utility.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/Utility.java
index 5bc1cca355d7..f40318800e33 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/Utility.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/Utility.java
@@ -13,6 +13,7 @@
import com.azure.core.http.rest.ResponseBase;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
+import com.azure.core.util.CoreUtils;
import com.azure.core.util.logging.ClientLogger;
import com.azure.data.appconfiguration.implementation.models.KeyValue;
import com.azure.data.appconfiguration.implementation.models.SnapshotUpdateParameters;
@@ -24,19 +25,15 @@
import reactor.core.publisher.Mono;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
-import static com.azure.core.util.tracing.Tracer.AZ_TRACING_NAMESPACE_KEY;
-
/**
* App Configuration Utility methods, use internally.
*/
public class Utility {
- private static final String HTTP_REST_PROXY_SYNC_PROXY_ENABLE = "com.azure.core.http.restproxy.syncproxy.enable";
- public static final String APP_CONFIG_TRACING_NAMESPACE_VALUE = "Microsoft.AppConfiguration";
-
public static final String ID = "id";
public static final String DESCRIPTION = "description";
public static final String DISPLAY_NAME = "display_name";
@@ -67,36 +64,9 @@ public static KeyValue toKeyValue(ConfigurationSetting setting) {
.setTags(setting.getTags());
}
- // List to SettingFields[]
- public static SettingFields[] toSettingFieldsArray(List settingFieldsList) {
- int size = settingFieldsList.size();
- SettingFields[] fields = new SettingFields[size];
- for (int i = 0; i < size; i++) {
- fields[i] = settingFieldsList.get(i);
- }
- return fields;
- }
-
// SettingFields[] to List
public static List toSettingFieldsList(SettingFields[] settingFieldsArray) {
- int size = settingFieldsArray.length;
- List settingFieldsList = new ArrayList<>(size);
- for (int i = 0; i < size; i++) {
- settingFieldsList.add(settingFieldsArray[i]);
- }
- return settingFieldsList;
- }
-
- // Iterable to List
- public static List iterableToList(Iterable iterable) {
- if (iterable == null) {
- return null;
- }
- List outputList = new ArrayList<>();
- for (E item : iterable) {
- outputList.add(item);
- }
- return outputList;
+ return new ArrayList<>(Arrays.asList(settingFieldsArray));
}
/*
@@ -117,14 +87,6 @@ public static String getETag(boolean isETagRequired, ConfigurationSetting settin
return isETagRequired ? getETagValue(setting.getETag()) : null;
}
- public static String getETagSnapshot(boolean isETagRequired, ConfigurationSnapshot snapshot) {
- if (!isETagRequired) {
- return null;
- }
- Objects.requireNonNull(snapshot);
- return getETagValue(snapshot.getETag());
- }
-
/*
* Ensure that setting is not null. And, key cannot be null because it is part of the service REST URL.
*/
@@ -149,24 +111,6 @@ public static Mono validateSettingAsync(ConfigurationSetti
return Mono.just(setting);
}
- /**
- * Enable the sync stack rest proxy.
- *
- * @param context It offers a means of passing arbitrary data (key-value pairs) to pipeline policies.
- * Most applications do not need to pass arbitrary data to the pipeline and can pass Context.NONE or null.
- *
- * @return The Context.
- */
- public static Context enableSyncRestProxy(Context context) {
- context = context == null ? Context.NONE : context;
- return context.addData(HTTP_REST_PROXY_SYNC_PROXY_ENABLE, true);
- }
-
- public static Context addTracingNamespace(Context context) {
- context = context == null ? Context.NONE : context;
- return context.addData(AZ_TRACING_NAMESPACE_KEY, APP_CONFIG_TRACING_NAMESPACE_VALUE);
- }
-
public static Response updateSnapshotSync(String snapshotName,
MatchConditions matchConditions, ConfigurationSnapshotStatus status,
AzureAppConfigurationImpl serviceClient, Context context) {
@@ -203,44 +147,44 @@ public static String parseNextLink(String nextLink) {
// Async handler
public static Mono> handleNotModifiedErrorToValidResponse(HttpResponseException error) {
HttpResponse httpResponse = error.getResponse();
+ if (httpResponse == null) {
+ return Mono.error(error);
+ }
+
String continuationToken = parseNextLink(httpResponse.getHeaderValue(HttpHeaderName.LINK));
if (httpResponse.getStatusCode() == 304) {
- return Mono.just(
- new PagedResponseBase<>(
- httpResponse.getRequest(),
- httpResponse.getStatusCode(),
- httpResponse.getHeaders(),
- null,
- continuationToken,
- null));
+ return Mono.just(new PagedResponseBase<>(httpResponse.getRequest(), httpResponse.getStatusCode(),
+ httpResponse.getHeaders(), null, continuationToken, null));
}
+
return Mono.error(error);
}
// Sync Handler
public static PagedResponse handleNotModifiedErrorToValidResponse(HttpResponseException error,
ClientLogger logger) {
HttpResponse httpResponse = error.getResponse();
+ if (httpResponse == null) {
+ throw logger.logExceptionAsError(error);
+ }
+
String continuationToken = parseNextLink(httpResponse.getHeaderValue(HttpHeaderName.LINK));
if (httpResponse.getStatusCode() == 304) {
- return new PagedResponseBase<>(
- httpResponse.getRequest(),
- httpResponse.getStatusCode(),
- httpResponse.getHeaders(),
- null,
- continuationToken,
- null);
+ return new PagedResponseBase<>(httpResponse.getRequest(), httpResponse.getStatusCode(),
+ httpResponse.getHeaders(), null, continuationToken, null);
}
+
throw logger.logExceptionAsError(error);
}
// Get the ETag from a list
public static String getPageETag(List matchConditionsList, AtomicInteger pageETagIndex) {
- int pageETagListSize = (matchConditionsList == null || matchConditionsList.isEmpty())
- ? 0
- : matchConditionsList.size();
+ if (CoreUtils.isNullOrEmpty(matchConditionsList)) {
+ return null;
+ }
+
String nextPageETag = null;
int pageETagIndexValue = pageETagIndex.get();
- if (pageETagIndexValue < pageETagListSize) {
+ if (pageETagIndexValue < matchConditionsList.size()) {
nextPageETag = matchConditionsList.get(pageETagIndexValue).getIfNoneMatch();
pageETagIndex.set(pageETagIndexValue + 1);
}
diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTest.java
index 3d0c3e5a491e..744dddcf1bee 100644
--- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTest.java
+++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTest.java
@@ -777,15 +777,11 @@ public void listConfigurationSettingsAcceptDateTime(HttpClient httpClient, Confi
final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2");
// Create 3 revisions of the same key.
- try {
- assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue());
- Thread.sleep(2000);
- assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue());
- Thread.sleep(2000);
- assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue());
- } catch (InterruptedException ex) {
- // Do nothing.
- }
+ assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue());
+ sleepIfRunningAgainstService(2000);
+ assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue());
+ sleepIfRunningAgainstService(2000);
+ assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue());
// Gets all versions of this value so we can get the one we want at that particular date.
List revisions = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList());
@@ -886,15 +882,11 @@ public void listRevisionsAcceptDateTime(HttpClient httpClient, ConfigurationServ
final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2");
// Create 3 revisions of the same key.
- try {
- assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue());
- Thread.sleep(2000);
- assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue());
- Thread.sleep(2000);
- assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue());
- } catch (InterruptedException ex) {
- // Do nothing.
- }
+ assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue());
+ sleepIfRunningAgainstService(2000);
+ assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue());
+ sleepIfRunningAgainstService(2000);
+ assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue());
// Gets all versions of this value.
List revisions = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList());
diff --git a/sdk/attestation/azure-security-attestation/src/test/java/com/azure/security/attestation/AttestationTest.java b/sdk/attestation/azure-security-attestation/src/test/java/com/azure/security/attestation/AttestationTest.java
index 21c89af0fc57..0dada17dbdf1 100644
--- a/sdk/attestation/azure-security-attestation/src/test/java/com/azure/security/attestation/AttestationTest.java
+++ b/sdk/attestation/azure-security-attestation/src/test/java/com/azure/security/attestation/AttestationTest.java
@@ -9,6 +9,7 @@
import com.azure.core.test.utils.TestUtils;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
+import com.azure.core.util.logging.LogLevel;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.security.attestation.models.AttestationData;
import com.azure.security.attestation.models.AttestationDataInterpretation;
@@ -354,7 +355,8 @@ void testTpmAttestation(HttpClient httpClient, String clientUri) {
.setAttestationSigner(new AttestationSigningKey(getIsolatedSigningCertificate(), getIsolatedSigningKey())));
if (result.getPolicyResolution() != PolicyModification.UPDATED) {
- System.out.printf("Unexpected resolution setting TPM policy: %s", result.getPolicyResolution().toString());
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> "Unexpected resolution setting TPM policy: " + result.getPolicyResolution());
return;
}
@@ -373,11 +375,11 @@ void testTpmAttestation(HttpClient httpClient, String clientUri) {
Object deserializedResponse = assertDoesNotThrow(() -> ADAPTER.deserialize(tpmResponse.getTpmResult().toBytes(),
Object.class, SerializerEncoding.JSON));
- assertTrue(deserializedResponse instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, deserializedResponse);
@SuppressWarnings("unchecked")
LinkedHashMap initialResponse = (LinkedHashMap) deserializedResponse;
assertTrue(initialResponse.containsKey("payload"));
- assertTrue(initialResponse.get("payload") instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, initialResponse.get("payload"));
@SuppressWarnings("unchecked")
LinkedHashMap payload = (LinkedHashMap) initialResponse.get("payload");
assertTrue(payload.containsKey("challenge"));
@@ -402,7 +404,8 @@ void testTpmAttestationWithResult(HttpClient httpClient, String clientUri) {
.setAttestationSigner(new AttestationSigningKey(getIsolatedSigningCertificate(), getIsolatedSigningKey())));
if (result.getPolicyResolution() != PolicyModification.UPDATED) {
- System.out.printf("Unexpected resolution setting TPM policy: %s", result.getPolicyResolution().toString());
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> "Unexpected resolution setting TPM policy: " + result.getPolicyResolution());
return;
}
@@ -423,11 +426,11 @@ void testTpmAttestationWithResult(HttpClient httpClient, String clientUri) {
Object deserializedResponse = assertDoesNotThrow(() -> ADAPTER.deserialize(
tpmResponse.getValue().getTpmResult().toBytes(), Object.class, SerializerEncoding.JSON));
- assertTrue(deserializedResponse instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, deserializedResponse);
@SuppressWarnings("unchecked")
LinkedHashMap initialResponse = (LinkedHashMap) deserializedResponse;
assertTrue(initialResponse.containsKey("payload"));
- assertTrue(initialResponse.get("payload") instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, initialResponse.get("payload"));
@SuppressWarnings("unchecked")
LinkedHashMap payload = (LinkedHashMap) initialResponse.get("payload");
assertTrue(payload.containsKey("challenge"));
@@ -450,7 +453,8 @@ void testTpmAttestationAsync(HttpClient httpClient, String clientUri) {
.setAttestationSigner(new AttestationSigningKey(getIsolatedSigningCertificate(), getIsolatedSigningKey())));
if (result.getPolicyResolution() != PolicyModification.UPDATED) {
- System.out.printf("Unexpected resolution setting TPM policy: %s", result.getPolicyResolution().toString());
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> "Unexpected resolution setting TPM policy: " + result.getPolicyResolution());
return;
}
@@ -469,11 +473,11 @@ void testTpmAttestationAsync(HttpClient httpClient, String clientUri) {
.assertNext(tpmResponse -> {
Object deserializedResponse = assertDoesNotThrow(() -> ADAPTER.deserialize(
tpmResponse.getTpmResult().toBytes(), Object.class, SerializerEncoding.JSON));
- assertTrue(deserializedResponse instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, deserializedResponse);
@SuppressWarnings("unchecked")
LinkedHashMap initialResponse = (LinkedHashMap) deserializedResponse;
assertTrue(initialResponse.containsKey("payload"));
- assertTrue(initialResponse.get("payload") instanceof LinkedHashMap);
+ assertInstanceOf(LinkedHashMap.class, initialResponse.get("payload"));
@SuppressWarnings("unchecked")
LinkedHashMap payload = (LinkedHashMap) initialResponse.get("payload");
assertTrue(payload.containsKey("challenge"));
@@ -669,7 +673,7 @@ private static void verifyAttestationResult(TestMode testMode, String clientUri,
assertNull(result.getNonce());
if (expectJson) {
- assertTrue(result.getRuntimeClaims() instanceof Map);
+ assertInstanceOf(Map.class, result.getRuntimeClaims());
@SuppressWarnings("unchecked")
Map runtimeClaims = (Map) result.getRuntimeClaims();
Map expectedClaims = assertDoesNotThrow(() ->
@@ -685,7 +689,7 @@ static void assertObjectEqual(Map expected, Map
LOGGER.verbose("Key: " + key);
assertTrue(actual.containsKey(key));
if (expected.get(key) instanceof Map) {
- assertTrue(actual.get(key) instanceof Map);
+ assertInstanceOf(Map.class, actual.get(key));
@SuppressWarnings("unchecked")
Map expectedInner = (Map) expected.get(key);
@SuppressWarnings("unchecked")
diff --git a/sdk/boms/spring-cloud-azure-dependencies/pom.xml b/sdk/boms/spring-cloud-azure-dependencies/pom.xml
index 01737e7633d1..cbb7b2fd5ae8 100644
--- a/sdk/boms/spring-cloud-azure-dependencies/pom.xml
+++ b/sdk/boms/spring-cloud-azure-dependencies/pom.xml
@@ -6,7 +6,7 @@
com.azure.spring
spring-cloud-azure-dependencies
- 4.18.0-beta.1
+ 4.19.0-beta.1
pom
Spring Cloud Azure Dependencies
@@ -51,14 +51,14 @@
com.azure
azure-sdk-bom
- 1.2.22
+ 1.2.23
pom
import
com.azure
azure-spring-data-cosmos
- 3.45.0-beta.1
+ 3.46.0-beta.1
com.azure.resourcemanager
diff --git a/sdk/communication/azure-communication-callautomation/pom.xml b/sdk/communication/azure-communication-callautomation/pom.xml
index 32b5e27eb7b8..722ac6b09f44 100644
--- a/sdk/communication/azure-communication-callautomation/pom.xml
+++ b/sdk/communication/azure-communication-callautomation/pom.xml
@@ -71,7 +71,7 @@
com.azure
azure-messaging-servicebus
- 7.16.0
+ 7.17.0
test
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientAutomatedLiveTests.java
index 31efad130aa1..27e11915f67f 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientAutomatedLiveTests.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAsyncClientAutomatedLiveTests.java
@@ -17,6 +17,7 @@
import com.azure.communication.identity.CommunicationIdentityAsyncClient;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
+import com.azure.core.test.annotation.DoNotRecord;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -32,6 +33,7 @@
import static org.junit.jupiter.api.Assertions.fail;
public class CallAutomationAsyncClientAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase {
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
@@ -132,6 +134,7 @@ public void createVOIPCallAndAnswerThenHangupAutomatedTest(HttpClient httpClient
}
}
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAutomatedLiveTestBase.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAutomatedLiveTestBase.java
index 500d2108a25c..a7a831b0b173 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAutomatedLiveTestBase.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationAutomatedLiveTestBase.java
@@ -8,28 +8,27 @@
import com.azure.communication.callautomation.models.events.CallAutomationEventBase;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.core.amqp.AmqpTransportType;
+import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.test.TestMode;
import com.azure.core.util.Configuration;
+import com.azure.core.util.CoreUtils;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.messaging.servicebus.ServiceBusClientBuilder;
import com.azure.messaging.servicebus.ServiceBusErrorContext;
import com.azure.messaging.servicebus.ServiceBusException;
import com.azure.messaging.servicebus.ServiceBusFailureReason;
import com.azure.messaging.servicebus.ServiceBusProcessorClient;
-import com.azure.core.http.HttpClient;
import com.azure.messaging.servicebus.ServiceBusReceivedMessage;
import com.azure.messaging.servicebus.ServiceBusReceivedMessageContext;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.azure.core.util.CoreUtils;
-import java.util.StringJoiner;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -39,11 +38,15 @@
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
+import java.util.StringJoiner;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
public class CallAutomationAutomatedLiveTestBase extends CallAutomationLiveTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(CallAutomationAutomatedLiveTestBase.class);
+
protected ConcurrentHashMap processorStore;
// Key: callerId + receiverId, Value: incomingCallContext
protected ConcurrentHashMap incomingCallContextStore;
@@ -60,7 +63,7 @@ public class CallAutomationAutomatedLiveTestBase extends CallAutomationLiveTestB
protected static final String BOT_APP_ID = Configuration.getGlobalConfiguration()
.get("BOT_APP_ID", "REDACTED-bedb-REDACTED-b8c6-REDACTED");
- private static final StringJoiner JSON_PROPERTIES_TO_REDACT
+ private static final StringJoiner JSON_PROPERTIES_TO_REDACT
= new StringJoiner("\":\"|\"", "\"", "\":\"")
.add("value")
.add("rawId")
@@ -70,11 +73,11 @@ public class CallAutomationAutomatedLiveTestBase extends CallAutomationLiveTestB
.add("ivrContext")
.add("incomingCallContext")
.add("serverCallId");
-
+
protected static final Pattern JSON_PROPERTY_VALUE_REDACTION_PATTERN
= Pattern.compile(String.format("(?:%s)(.*?)(?:\",|\"})", JSON_PROPERTIES_TO_REDACT),
Pattern.CASE_INSENSITIVE);
-
+
protected static final String URL_REGEX = "(?<=http:\\/\\/|https:\\/\\/)([^\\/?]+)";
@Override
@@ -206,11 +209,12 @@ private void messageBodyHandler(String body) {
}
protected void errorHandler(ServiceBusErrorContext context, CountDownLatch countdownLatch) {
- System.out.printf("Error when receiving messages from namespace: '%s'. Entity: '%s'%n",
- context.getFullyQualifiedNamespace(), context.getEntityPath());
+ LOGGER.log(LogLevel.VERBOSE, () -> String.format(
+ "Error when receiving messages from namespace: '%s'. Entity: '%s'%n",
+ context.getFullyQualifiedNamespace(), context.getEntityPath()));
if (!(context.getException() instanceof ServiceBusException)) {
- System.out.printf("Non-ServiceBusException occurred: %s%n", context.getException());
+ LOGGER.log(LogLevel.VERBOSE, () -> "Non-ServiceBusException occurred: " + context.getException());
return;
}
@@ -220,22 +224,20 @@ protected void errorHandler(ServiceBusErrorContext context, CountDownLatch count
if (reason == ServiceBusFailureReason.MESSAGING_ENTITY_DISABLED
|| reason == ServiceBusFailureReason.MESSAGING_ENTITY_NOT_FOUND
|| reason == ServiceBusFailureReason.UNAUTHORIZED) {
- System.out.printf("An unrecoverable error occurred. Stopping processing with reason %s: %s%n",
- reason, exception.getMessage());
+ LOGGER.log(LogLevel.VERBOSE, () -> String.format(
+ "An unrecoverable error occurred. Stopping processing with reason %s: %s%n",
+ reason, exception.getMessage()));
countdownLatch.countDown();
} else if (reason == ServiceBusFailureReason.MESSAGE_LOCK_LOST) {
- System.out.printf("Message lock lost for message: %s%n", context.getException());
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> String.format("Message lock lost for message: %s%n", context.getException()));
} else if (reason == ServiceBusFailureReason.SERVICE_BUSY) {
- try {
- // Choosing an arbitrary amount of time to wait until trying again.
- TimeUnit.SECONDS.sleep(1);
- } catch (InterruptedException e) {
- System.err.println("Unable to sleep for period of time");
- }
+ // Choosing an arbitrary amount of time to wait until trying again.
+ sleepIfRunningAgainstService(1000);
} else {
- System.out.printf("Error source %s, reason %s, message: %s%n", context.getErrorSource(),
- reason, context.getException());
+ LOGGER.log(LogLevel.VERBOSE, () -> String.format("Error source %s, reason %s, message: %s%n",
+ context.getErrorSource(), reason, context.getException()));
}
}
@@ -260,7 +262,7 @@ protected String waitForIncomingCallContext(String uniqueId, Duration timeOut) t
if (incomingCallContext != null) {
return incomingCallContext;
}
- Thread.sleep(1000);
+ sleepIfRunningAgainstService(1000);
}
return null;
}
@@ -275,11 +277,11 @@ protected T waitForEvent(Class eventType,
return event;
}
}
- Thread.sleep(1000);
+ sleepIfRunningAgainstService(1000);
}
return null;
}
-
+
protected String redact(String content, Matcher matcher) {
while (matcher.find()) {
String captureGroup = matcher.group(1);
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationLiveTestBase.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationLiveTestBase.java
index fbd9a81bd697..ca45f40b8eba 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationLiveTestBase.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallAutomationLiveTestBase.java
@@ -62,17 +62,17 @@ public class CallAutomationLiveTestBase extends TestProxyTestBase {
protected static final String MEDIA_SOURCE = Configuration.getGlobalConfiguration()
.get("ACS_MEDIA_SOURCE", "https://contoso.com/music.wav");
protected static final String URL_REGEX = "(?<=http:\\/\\/|https:\\/\\/)([^\\/?]+)";
-
+
protected CommunicationIdentityClientBuilder getCommunicationIdentityClientUsingConnectionString(HttpClient httpClient) {
CommunicationIdentityClientBuilder builder = new CommunicationIdentityClientBuilder()
.connectionString(CONNECTION_STRING)
.httpClient(getHttpClientOrUsePlayback(httpClient));
-
+
if (getTestMode() == TestMode.RECORD) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}
addTestProxyTestSanitizersAndMatchers(interceptorManager);
-
+
return builder;
}
@@ -88,12 +88,12 @@ protected CallAutomationClientBuilder getCallAutomationClientUsingConnectionStri
.connectionString(CONNECTION_STRING)
.httpClient(getHttpClientOrUsePlayback(httpClient));
}
-
+
if (getTestMode() == TestMode.RECORD) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}
addTestProxyTestSanitizersAndMatchers(interceptorManager);
-
+
return builder;
}
@@ -137,12 +137,6 @@ protected Mono logHeaders(String testName, HttpPipelineNextPolicy
});
}
- protected void waitForOperationCompletion(int milliSeconds) throws InterruptedException {
- if (getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(milliSeconds);
- }
- }
-
static class FakeCredentials implements TokenCredential {
@Override
public Mono getToken(TokenRequestContext tokenRequestContext) {
@@ -159,15 +153,15 @@ protected String redact(String content, Matcher matcher) {
}
return content;
}
-
+
protected void addTestProxyTestSanitizersAndMatchers(InterceptorManager interceptorManager) {
-
+
if (interceptorManager.isLiveMode()) {
return;
}
List customSanitizers = new ArrayList<>();
-
+
customSanitizers.add(new TestProxySanitizer("Authorization", null, "REDACTED", TestProxySanitizerType.HEADER));
customSanitizers.add(new TestProxySanitizer("x-ms-client-request-id", null, "REDACTED", TestProxySanitizerType.HEADER));
customSanitizers.add(new TestProxySanitizer("x-ms-content-sha256", null, "REDACTED", TestProxySanitizerType.HEADER));
@@ -187,7 +181,7 @@ protected void addTestProxyTestSanitizersAndMatchers(InterceptorManager intercep
customSanitizers.add(new TestProxySanitizer("$..mediaSubscriptionId", null, "REDACTED", TestProxySanitizerType.BODY_KEY));
customSanitizers.add(new TestProxySanitizer("$..dataSubscriptionId", null, "REDACTED", TestProxySanitizerType.BODY_KEY));
customSanitizers.add(new TestProxySanitizer(URL_REGEX, "REDACTED", TestProxySanitizerType.BODY_REGEX));
-
+
interceptorManager.addSanitizers(customSanitizers);
if (interceptorManager.isPlaybackMode()) {
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncAutomatedLiveTests.java
index c807992bf2a3..69662ce92337 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncAutomatedLiveTests.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallConnectionAsyncAutomatedLiveTests.java
@@ -15,14 +15,14 @@
import com.azure.communication.callautomation.models.RemoveParticipantResult;
import com.azure.communication.callautomation.models.events.AddParticipantSucceeded;
import com.azure.communication.callautomation.models.events.CallConnected;
-import com.azure.communication.callautomation.models.events.RemoveParticipantSucceeded;
import com.azure.communication.callautomation.models.events.CancelAddParticipantSucceeded;
+import com.azure.communication.callautomation.models.events.RemoveParticipantSucceeded;
import com.azure.communication.common.CommunicationIdentifier;
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.CommunicationIdentityAsyncClient;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
-
+import com.azure.core.test.annotation.DoNotRecord;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -39,6 +39,7 @@
public class CallConnectionAsyncAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase {
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
@@ -157,6 +158,7 @@ public void createVOIPCallAndAnswerThenAddParticipantFinallyRemoveParticipantAut
}
}
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
@@ -232,7 +234,7 @@ public void createVOIPCallAndAnswerThenAddParticipantFinallyCancelAddParticipant
assertNotNull(addParticipantsResultResponse);
// ensure invitation is sent
- Thread.sleep(3000);
+ sleepIfRunningAgainstService(3000);
// cancel add participant
CancelAddParticipantOperationResult cancelAddParticipantResponse = createCallResult
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallDialogAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallDialogAsyncAutomatedLiveTests.java
index c12f8a6f6e83..4dac2c5d8b31 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallDialogAsyncAutomatedLiveTests.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallDialogAsyncAutomatedLiveTests.java
@@ -12,6 +12,7 @@
import com.azure.communication.identity.CommunicationIdentityAsyncClient;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
+import com.azure.core.test.annotation.DoNotRecord;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
@@ -25,6 +26,7 @@
public class CallDialogAsyncAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase {
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java
index 60e5034b3d1d..a7d6c8f17887 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallMediaAsyncAutomatedLiveTests.java
@@ -24,6 +24,7 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
import com.azure.core.test.TestMode;
+import com.azure.core.test.annotation.DoNotRecord;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
@@ -42,6 +43,7 @@
public class CallMediaAsyncAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase {
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
@@ -128,6 +130,7 @@ public void playMediaInACallAutomatedTest(HttpClient httpClient) {
}
}
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@DisabledIfEnvironmentVariable(
diff --git a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallRecordingAutomatedLiveTests.java b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallRecordingAutomatedLiveTests.java
index 98e6ee049631..8187e92aaef8 100644
--- a/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallRecordingAutomatedLiveTests.java
+++ b/sdk/communication/azure-communication-callautomation/src/test/java/com/azure/communication/callautomation/CallRecordingAutomatedLiveTests.java
@@ -21,6 +21,7 @@
import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.CommunicationIdentityClient;
import com.azure.core.http.HttpClient;
+import com.azure.core.test.annotation.DoNotRecord;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -34,6 +35,7 @@
import static org.junit.jupiter.api.Assertions.fail;
public class CallRecordingAutomatedLiveTests extends CallAutomationAutomatedLiveTestBase {
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createACSCallAndUnmixedAudioTest(HttpClient httpClient) {
@@ -118,6 +120,7 @@ public void createACSCallAndUnmixedAudioTest(HttpClient httpClient) {
}
}
+ @DoNotRecord(skipInPlayback = true)
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
public void createACSCallUnmixedAudioAffinityTest(HttpClient httpClient) {
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallAndUnmixedAudioTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallAndUnmixedAudioTest.json
deleted file mode 100644
index 41689d777012..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallAndUnmixedAudioTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"802fc64d-4d4e-4280-be90-228202784cd6\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-d9b1-40b6-805b-56cef20d7f13\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"802fc64d-4d4e-4280-be90-228202784cd6\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:17:14.5301986\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-d9b1-40b6-805b-56cef20d7f13\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"802fc64d-4d4e-4280-be90-228202784cd6\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:14.5301986\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-d9b1-40b6-805b-56cef20d7f13\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"802fc64d-4d4e-4280-be90-228202784cd6\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:19.8119571\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-d9b1-40b6-805b-56cef20d7f13\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"802fc64d-4d4e-4280-be90-228202784cd6\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T19:17:20.2182933\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-d9b1-40b6-805b-56cef20d7f13\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallUnmixedAudioAffinityTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallUnmixedAudioAffinityTest.json
deleted file mode 100644
index 3b6fc1e33a39..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createACSCallUnmixedAudioAffinityTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"54f85e11-3105-433f-aac8-19cf1df95d36\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-78fd-4327-bf24-44ec170f86cd\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"54f85e11-3105-433f-aac8-19cf1df95d36\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:26.4688368\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-78fd-4327-bf24-44ec170f86cd\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"54f85e11-3105-433f-aac8-19cf1df95d36\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:17:26.4688368\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-78fd-4327-bf24-44ec170f86cd\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"54f85e11-3105-433f-aac8-19cf1df95d36\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:30.9536716\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-78fd-4327-bf24-44ec170f86cd\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"54f85e11-3105-433f-aac8-19cf1df95d36\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T19:17:31.3599728\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-78fd-4327-bf24-44ec170f86cd\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyCancelAddParticipant.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyCancelAddParticipant.json
deleted file mode 100644
index 8bc5f1f63488..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyCancelAddParticipant.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-cbad-484c-bcde-27c5edc765db\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:37.484509\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-8ff1-4fe6-a575-d0e702b71497\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:37.5001327\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-8ff1-4fe6-a575-d0e702b71497\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:37.5157768\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-cbad-484c-bcde-27c5edc765db\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:37.5157768\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-8ff1-4fe6-a575-d0e702b71497\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:39.5471963\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-cbad-484c-bcde-27c5edc765db\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:39.5471963\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-cbad-484c-bcde-27c5edc765db\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\",\"type\":\"Microsoft.Communication.CancelAddParticipantSucceeded\",\"data\":{\"invitationId\":\"03b7d0e2-1d59-4f37-9fd1-f827d275eb59\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-8ff1-4fe6-a575-d0e702b71497\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"7d16dfce-c0c5-490d-8105-7debd7893a32\",\"publicEventType\":\"Microsoft.Communication.CancelAddParticipantSucceeded\"},\"time\":\"2024-04-24T19:16:41.2504076\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-8ff1-4fe6-a575-d0e702b71497\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyRemoveParticipantAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyRemoveParticipantAutomatedTest.json
deleted file mode 100644
index cb7d3ec5caf6..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenAddParticipantFinallyRemoveParticipantAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:23.5615833\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:23.6240133\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:23.6083905\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:23.6240133\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:26.4836617\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":3,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:26.5148471\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:28.2649797\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.AddParticipantSucceeded\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participant\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.AddParticipantSucceeded\"},\"time\":\"2024-04-24T19:16:28.358734\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":4,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:28.358734\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":4,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:28.358734\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":6,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:28.6244317\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":6,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:28.8431467\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":5,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:28.8431467\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":7,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:29.0931748\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":6,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:29.3119818\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":6,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:29.3119818\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":9,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:29.5775742\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c9dd-4c59-b2b3-d50aaa67159f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T19:16:29.6557095\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c9dd-4c59-b2b3-d50aaa67159f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":9,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:30.0464126\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.RemoveParticipantSucceeded\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participant\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.RemoveParticipantSucceeded\"},\"time\":\"2024-04-24T19:16:29.6557095\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":7,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:29.7807154\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":9,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:30.5151508\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":8,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:30.6089007\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":11,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-9ebd-43a1-95f7-92e9994edb3f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:30.9996063\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-9ebd-43a1-95f7-92e9994edb3f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":9,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-7b70-4bfd-b026-739e6c663e81\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"448c7527-7911-4149-b835-e49afb83a6bf\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:31.1246381\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-7b70-4bfd-b026-739e6c663e81\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenHangupAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenHangupAutomatedTest.json
deleted file mode 100644
index ecc6d9ed6c24..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndAnswerThenHangupAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-4f90-4199-9a2c-e07e3af80407\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:12.9357522\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:12.9670517\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:12.9984379\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-4f90-4199-9a2c-e07e3af80407\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:13.0451895\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-4f90-4199-9a2c-e07e3af80407\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T19:16:14.4514859\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-4f90-4199-9a2c-e07e3af80407\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-2077-4ee0-b8ac-017ad075c7bb\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"b94e5319-f526-4538-aaef-6d59b28d3aa2\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T19:16:14.529611\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-2077-4ee0-b8ac-017ad075c7bb\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndRejectAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndRejectAutomatedTest.json
deleted file mode 100644
index b2a384ab4c74..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/createVOIPCallAndRejectAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"5556ad81-73a7-4fa7-a5c7-b4b7d08a2001\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-c0ef-474b-8b58-ad685a4b1ce9\",\"type\":\"Microsoft.Communication.CreateCallFailed\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-c0ef-474b-8b58-ad685a4b1ce9\",\"resultInformation\":{\"code\":603,\"subCode\":0,\"message\":\"Decline. DiagCode: 603#0.@\"},\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-c0ef-474b-8b58-ad685a4b1ce9\",\"correlationId\":\"5556ad81-73a7-4fa7-a5c7-b4b7d08a2001\",\"publicEventType\":\"Microsoft.Communication.CreateCallFailed\"},\"time\":\"2024-04-24T19:16:06.0905745\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-c0ef-474b-8b58-ad685a4b1ce9\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dialogActionInACallAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dialogActionInACallAutomatedTest.json
deleted file mode 100644
index 4647cc0dd9a7..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dialogActionInACallAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-688b-44d7-8081-1282028cdd97\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T18:28:31.0979781\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-688b-44d7-8081-1282028cdd97\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T18:28:31.1448558\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T18:28:31.1762164\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T18:28:31.1762164\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-3a6a-431c-8c4a-7c1f8b27f9f5\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"type\":\"Microsoft.Communication.DialogFailed\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\",\"resultInformation\":{\"code\":500,\"subCode\":8595,\"message\":\"Action failed, missing bot config or app id.\"},\"dialogInputType\":\"powerVirtualAgents\",\"dialogId\":\"92e08834-b6ee-4ede-8956-9fefa27a691c\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-688b-44d7-8081-1282028cdd97\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"41820b15-8dca-430f-b226-b3d26a3f80b5\",\"publicEventType\":\"Microsoft.Communication.DialogFailed\"},\"time\":\"2024-04-24T18:28:33.2388006\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-688b-44d7-8081-1282028cdd97\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dtmfActionsInACallAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dtmfActionsInACallAutomatedTest.json
deleted file mode 100644
index 63208076fd7d..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/dtmfActionsInACallAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-09a1-4ad4-9320-4f2d89459535\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-09a1-4ad4-9320-4f2d89459535\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-09a1-4ad4-9320-4f2d89459535\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"892264d7-e380-44f1-88fd-7764e019664b\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T18:29:05.7916051\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-09a1-4ad4-9320-4f2d89459535\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-567b-47c2-93a4-546fa6997899\",\"type\":\"Microsoft.Communication.CallDisconnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-567b-47c2-93a4-546fa6997899\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-567b-47c2-93a4-546fa6997899\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"63ad2792-7c3d-497d-bbae-aa384c7a8f03\",\"publicEventType\":\"Microsoft.Communication.CallDisconnected\"},\"time\":\"2024-04-24T18:29:06.0572971\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-567b-47c2-93a4-546fa6997899\"}]","{\"to\":{\"kind\":\"phoneNumber\",\"rawId\":\"REDACTED\",\"phoneNumber\":{\"value\":\"REDACTED\"}},\"from\":{\"kind\":\"phoneNumber\",\"rawId\":\"REDACTED\",\"phoneNumber\":{\"value\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"1a14f457-e406-4aed-95b3-7e6259d23851\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-476a-4aed-ae4b-fb8657609c2f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"1a14f457-e406-4aed-95b3-7e6259d23851\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:50.3802422\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"phoneNumber\",\"phoneNumber\":{\"value\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-476a-4aed-ae4b-fb8657609c2f\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"1a14f457-e406-4aed-95b3-7e6259d23851\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:50.5365\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-476a-4aed-ae4b-fb8657609c2f\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-e121-46d6-ab08-b468bd18edd5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"d6d82270-ed3c-49b0-aeb9-2a157ca1af60\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:16:50.6345661\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"phoneNumber\",\"phoneNumber\":{\"value\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-e121-46d6-ab08-b468bd18edd5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"d6d82270-ed3c-49b0-aeb9-2a157ca1af60\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:16:50.6345661\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"type\":\"Microsoft.Communication.SendDtmfTonesCompleted\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-e121-46d6-ab08-b468bd18edd5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"d6d82270-ed3c-49b0-aeb9-2a157ca1af60\",\"publicEventType\":\"Microsoft.Communication.SendDtmfTonesCompleted\"},\"time\":\"2024-04-24T19:16:55.6194105\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"type\":\"Microsoft.Communication.ContinuousDtmfRecognitionStopped\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-e121-46d6-ab08-b468bd18edd5\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"d6d82270-ed3c-49b0-aeb9-2a157ca1af60\",\"publicEventType\":\"Microsoft.Communication.ContinuousDtmfRecognitionStopped\"},\"time\":\"2024-04-24T19:16:56.1352209\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-e121-46d6-ab08-b468bd18edd5\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/playMediaInACallAutomatedTest.json b/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/playMediaInACallAutomatedTest.json
deleted file mode 100644
index ef82e3d66c80..000000000000
--- a/sdk/communication/azure-communication-callautomation/src/test/resources/session-records/playMediaInACallAutomatedTest.json
+++ /dev/null
@@ -1 +0,0 @@
-["{\"to\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"from\":{\"kind\":\"communicationUser\",\"rawId\":\"REDACTED\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"serverCallId\":\"REDACTED\",\"callerDisplayName\":\"\",\"incomingCallContext\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\"}","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-b29e-4059-8f3c-f78434c99035\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:17:02.3387065\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\",\"type\":\"Microsoft.Communication.CallConnected\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\",\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-5e6f-47d8-bc89-5489b351cd37\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\",\"publicEventType\":\"Microsoft.Communication.CallConnected\"},\"time\":\"2024-04-24T19:17:02.307396\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-5e6f-47d8-bc89-5489b351cd37\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:02.3543277\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-5e6f-47d8-bc89-5489b351cd37\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"type\":\"Microsoft.Communication.ParticipantsUpdated\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"participants\":[{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false},{\"identifier\":{\"rawId\":\"REDACTED\",\"kind\":\"communicationUser\",\"communicationUser\":{\"id\":\"REDACTED\"}},\"isMuted\":false,\"isOnHold\":false}],\"sequenceNumber\":1,\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-b29e-4059-8f3c-f78434c99035\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\",\"publicEventType\":\"Microsoft.Communication.ParticipantsUpdated\"},\"time\":\"2024-04-24T19:17:02.3543277\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\"}]","[{\"id\":\"REDACTED\",\"source\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"type\":\"Microsoft.Communication.PlayCompleted\",\"data\":{\"eventSource\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\",\"resultInformation\":{\"code\":200,\"subCode\":0,\"message\":\"Action completed successfully.\"},\"version\":\"2023-10-03-preview\",\"callConnectionId\":\"451f3600-b29e-4059-8f3c-f78434c99035\",\"serverCallId\":\"REDACTED\",\"correlationId\":\"ef73aa27-a842-4fb1-bdaa-3a46db20014e\",\"publicEventType\":\"Microsoft.Communication.PlayCompleted\"},\"time\":\"2024-04-24T19:17:08.357708\\u002B00:00\",\"specversion\":\"1.0\",\"datacontenttype\":\"application/json\",\"subject\":\"calling/callConnections/451f3600-b29e-4059-8f3c-f78434c99035\"}]"]
\ No newline at end of file
diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAutomationLiveTestBase.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAutomationLiveTestBase.java
index e5cf3dc2817e..fbfb3defe424 100644
--- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAutomationLiveTestBase.java
+++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/CallAutomationLiveTestBase.java
@@ -13,6 +13,8 @@
import com.azure.core.test.TestMode;
import com.azure.core.util.Configuration;
import com.azure.core.util.CoreUtils;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.identity.DefaultAzureCredentialBuilder;
import reactor.core.publisher.Mono;
@@ -25,6 +27,8 @@
import java.util.regex.Pattern;
public class CallAutomationLiveTestBase extends TestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(CallAutomationLiveTestBase.class);
+
protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
"endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5");
@@ -109,7 +113,7 @@ protected Mono logHeaders(String testName, HttpPipelineNextPolicy
final HttpResponse bufferedResponse = httpResponse.buffer();
/* Should sanitize printed response url */
- System.out.println("Chain-ID header for " + testName + " request "
+ LOGGER.log(LogLevel.VERBOSE, () -> "Chain-ID header for " + testName + " request "
+ bufferedResponse.getRequest().getUrl()
+ ": " + bufferedResponse.getHeaderValue("X-Microsoft-Skype-Chain-ID"));
return Mono.just(bufferedResponse);
diff --git a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java
index 4a397fa5a51f..732a8df93167 100644
--- a/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java
+++ b/sdk/communication/azure-communication-callingserver/src/test/java/com/azure/communication/callingserver/DownloadContentAsyncLiveTests.java
@@ -8,6 +8,8 @@
import com.azure.communication.callingserver.models.ParallelDownloadOptions;
import com.azure.core.http.HttpClient;
import com.azure.core.util.Context;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -31,6 +33,7 @@
import static org.mockito.Mockito.times;
public class DownloadContentAsyncLiveTests extends CallAutomationLiveTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(DownloadContentAsyncLiveTests.class);
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
@@ -61,7 +64,7 @@ private void downloadMetadata(CallAutomationAsyncClient conversationAsyncClient)
try {
validateMetadata(conversationAsyncClient.getCallRecordingAsync().downloadStream(METADATA_URL));
} catch (Exception e) {
- System.out.println("Error: " + e.getMessage());
+ LOGGER.log(LogLevel.VERBOSE, () -> "Error", e);
throw e;
}
}
@@ -79,7 +82,7 @@ public void downloadMetadataRetryingAsync(HttpClient httpClient) {
try {
validateMetadata(conversationAsyncClient.getCallRecordingAsync().downloadStream(METADATA_URL));
} catch (Exception e) {
- System.out.println("Error: " + e.getMessage());
+ LOGGER.log(LogLevel.VERBOSE, () -> "Error", e);
throw e;
}
}
@@ -104,7 +107,7 @@ public void downloadVideoAsync(HttpClient httpClient) {
.verifyComplete())
.verifyComplete();
} catch (Exception e) {
- System.out.println("Error: " + e.getMessage());
+ LOGGER.log(LogLevel.VERBOSE, () -> "Error", e);
throw e;
}
}
diff --git a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTest.java b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTest.java
index 89cd18a49ba8..4bdb19fff1e7 100644
--- a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTest.java
+++ b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTest.java
@@ -3,28 +3,30 @@
package com.azure.communication.chat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
+import com.azure.communication.chat.implementation.ChatOptionsProvider;
+import com.azure.communication.chat.models.ChatThreadItem;
+import com.azure.communication.chat.models.CreateChatThreadOptions;
+import com.azure.communication.chat.models.CreateChatThreadResult;
+import com.azure.communication.chat.models.ListChatThreadsOptions;
+import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.CommunicationIdentityClient;
import com.azure.communication.identity.models.CommunicationTokenScope;
-import com.azure.communication.common.CommunicationUserIdentifier;
-import com.azure.communication.chat.implementation.ChatOptionsProvider;
-import com.azure.communication.chat.models.*;
import com.azure.core.credential.AccessToken;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Set the AZURE_TEST_MODE environment variable to either PLAYBACK or RECORD to determine if tests are playback or
* live. By default, tests are run in playback mode.
@@ -129,7 +131,7 @@ public void canDeleteChatThreadWithResponse(HttpClient httpClient) {
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
- public void canListChatThreads(HttpClient httpClient) throws InterruptedException {
+ public void canListChatThreads(HttpClient httpClient) {
// Arrange
setupTest(httpClient, "canListChatThreadsSync");
CreateChatThreadOptions threadRequest1 = ChatOptionsProvider.createThreadOptions(
@@ -139,7 +141,7 @@ public void canListChatThreads(HttpClient httpClient) throws InterruptedExceptio
client.createChatThread(threadRequest1);
client.createChatThread(threadRequest2);
- Thread.sleep(500);
+ sleepIfRunningAgainstService(500);
// Action & Assert
PagedIterable threadsResponse = client.listChatThreads();
@@ -156,7 +158,7 @@ public void canListChatThreads(HttpClient httpClient) throws InterruptedExceptio
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
- public void canListChatThreadsWithMaxPageSize(HttpClient httpClient) throws InterruptedException {
+ public void canListChatThreadsWithMaxPageSize(HttpClient httpClient) {
// Arrange
setupTest(httpClient, "canListChatThreadsWithMaxPageSizeSync");
CreateChatThreadOptions threadRequest1 = ChatOptionsProvider.createThreadOptions(
@@ -166,7 +168,7 @@ public void canListChatThreadsWithMaxPageSize(HttpClient httpClient) throws Inte
client.createChatThread(threadRequest1);
client.createChatThread(threadRequest2);
- Thread.sleep(500);
+ sleepIfRunningAgainstService(500);
ListChatThreadsOptions options = new ListChatThreadsOptions();
options.setMaxPageSize(10);
diff --git a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/CommunicationLoggerPolicy.java b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/CommunicationLoggerPolicy.java
index 362f2f720f74..74737342374d 100644
--- a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/CommunicationLoggerPolicy.java
+++ b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/CommunicationLoggerPolicy.java
@@ -9,6 +9,7 @@
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import reactor.core.publisher.Mono;
/**
@@ -16,7 +17,7 @@
*/
public class CommunicationLoggerPolicy implements HttpPipelinePolicy {
- private final ClientLogger logger = new ClientLogger(CommunicationLoggerPolicy.class);
+ private static final ClientLogger LOGGER = new ClientLogger(CommunicationLoggerPolicy.class);
private final String testName;
/**
@@ -34,7 +35,7 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request "
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for " + testName + " request "
+ bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
diff --git a/sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityClientTestBase.java b/sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityClientTestBase.java
index 4a2be505d72a..0b183b1b4d6a 100644
--- a/sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityClientTestBase.java
+++ b/sdk/communication/azure-communication-identity/src/test/java/com/azure/communication/identity/CommunicationIdentityClientTestBase.java
@@ -19,6 +19,8 @@
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.Configuration;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.identity.DefaultAzureCredentialBuilder;
import reactor.core.publisher.Mono;
@@ -33,6 +35,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class CommunicationIdentityClientTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(CommunicationIdentityClientTestBase.class);
private static final String REDACTED = "REDACTED";
private static final String URI_IDENTITY_REPLACER_REGEX = "/identities/([^/?]+)";
@@ -159,7 +162,7 @@ private Mono logHeaders(String testName, HttpPipelineNextPolicy ne
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request "
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for " + testName + " request "
+ bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyAsyncLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyAsyncLiveTests.java
index b180abf99367..deac224f7551 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyAsyncLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyAsyncLiveTests.java
@@ -26,7 +26,6 @@
import com.azure.communication.jobrouter.models.WorkerSelectorAttachment;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -139,9 +138,7 @@ public void createClassificationPolicy(HttpClient httpClient) throws Interrupted
}
})).block();
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
// Verify
assertEquals(classificationPolicyId, policy.getId());
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java
index 5639631436e9..1da46b2b40da 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/ClassificationPolicyLiveTests.java
@@ -24,7 +24,6 @@
import com.azure.communication.jobrouter.models.WorkerSelectorAttachment;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -107,9 +106,7 @@ public void createClassificationPolicy(HttpClient httpClient) throws Interrupted
RouterJob job = routerClient.createJobWithClassificationPolicy(
new CreateJobWithClassificationPolicyOptions(jobId, channelId, classificationPolicyId));
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
// Verify
assertEquals(classificationPolicyId, policy.getId());
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobAsyncLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobAsyncLiveTests.java
index 92e21536b168..ccf6b55c2157 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobAsyncLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobAsyncLiveTests.java
@@ -25,7 +25,6 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -150,9 +149,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
assertEquals(2, jobDeserialized.getRequestedWorkerSelectors().size());
assertEquals(Duration.ofSeconds(100), jobDeserialized.getRequestedWorkerSelectors().get(0).getExpiresAfter());
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(2000);
- }
+ sleepIfRunningAgainstService(2000);
jobDeserialized.setPriority(10);
RouterJob updatedJob = jobRouterAsyncClient.updateJob(jobId, jobDeserialized).block();
@@ -207,9 +204,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
// Verify
assertTrue(unassignJobResult.getUnassignmentCount() > 0);
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
RouterQueueStatistics queueStatistics = jobRouterAsyncClient.getQueueStatistics(queueId).block();
@@ -236,9 +231,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
jobRouterAsyncClient.cancelJob(jobId, requestOptions).block();
jobRouterAsyncClient.deleteJob(jobId).block();
jobRouterAsyncClient.deleteWorker(workerId).block();
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
administrationAsyncClient.deleteQueue(queueId).block();
administrationAsyncClient.deleteDistributionPolicy(distributionPolicyId).block();
}
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java
index 23447f8edab1..2363a4d1228a 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterJobLiveTests.java
@@ -25,7 +25,6 @@
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -151,9 +150,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
assertEquals(2, jobDeserialized.getRequestedWorkerSelectors().size());
assertEquals(Duration.ofSeconds(100), jobDeserialized.getRequestedWorkerSelectors().get(0).getExpiresAfter());
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(2000);
- }
+ sleepIfRunningAgainstService(2000);
jobDeserialized.setPriority(10);
RouterJob updatedJob = jobRouterClient.updateJob(jobId, jobDeserialized);
@@ -207,9 +204,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
// Verify
assertTrue(unassignJobResult.getUnassignmentCount() > 0);
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
RouterQueueStatistics queueStatistics = jobRouterClient.getQueueStatistics(queueId);
@@ -235,9 +230,7 @@ public void unassignJob(HttpClient httpClient) throws InterruptedException {
jobRouterClient.cancelJob(jobId, requestOptions);
jobRouterClient.deleteJob(jobId);
jobRouterClient.deleteWorker(workerId);
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(5000);
- }
+ sleepIfRunningAgainstService(5000);
routerAdminClient.deleteQueue(queueId);
routerAdminClient.deleteDistributionPolicy(distributionPolicyId);
}
@@ -264,9 +257,7 @@ public void jobScheduling(HttpClient httpClient) throws InterruptedException {
OffsetDateTime.of(2040, 1, 1, 1, 1, 1, 1, ZoneOffset.UTC))));
assertEquals(RouterJobStatus.PENDING_SCHEDULE, job.getStatus());
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(2000);
- }
+ sleepIfRunningAgainstService(2000);
// Action
job.setMatchingMode(new QueueAndMatchMode());
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerAsyncLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerAsyncLiveTests.java
index 800d9d47d2f1..4cd77b5ce427 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerAsyncLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerAsyncLiveTests.java
@@ -14,7 +14,6 @@
import com.azure.communication.jobrouter.models.RouterWorker;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -132,9 +131,7 @@ public void createWorker(HttpClient httpClient) throws InterruptedException {
assertEquals(channels.size(), deserialized.getChannels().size());
assertEquals(deserialized.getEtag(), result.getEtag());
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(2000);
- }
+ sleepIfRunningAgainstService(2000);
deserialized.setAvailableForOffers(true);
deserialized.setChannels(new ArrayList() {
diff --git a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java
index 008f0b3a0eea..b4423b1403e9 100644
--- a/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java
+++ b/sdk/communication/azure-communication-jobrouter/src/test/java/com.azure.communication.jobrouter/RouterWorkerLiveTests.java
@@ -11,7 +11,6 @@
import com.azure.communication.jobrouter.models.RouterWorker;
import com.azure.core.http.HttpClient;
import com.azure.core.http.rest.Response;
-import com.azure.core.test.TestMode;
import com.azure.core.util.BinaryData;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -108,9 +107,7 @@ public void createWorker(HttpClient httpClient) throws InterruptedException {
assertEquals(channels.size(), deserialized.getChannels().size());
assertEquals(deserialized.getEtag(), result.getEtag());
- if (this.getTestMode() != TestMode.PLAYBACK) {
- Thread.sleep(2000);
- }
+ sleepIfRunningAgainstService(2000);
deserialized.setAvailableForOffers(true);
deserialized.setChannels(new ArrayList() {
diff --git a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
index 34bfb174ebde..ebb1ceae3992 100644
--- a/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
+++ b/sdk/communication/azure-communication-messages/src/test/java/com/azure/communication/messages/CommunicationMessagesTestBase.java
@@ -14,11 +14,14 @@
import com.azure.core.test.models.TestProxySanitizer;
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.util.Configuration;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import reactor.core.publisher.Mono;
import java.util.Arrays;
public class CommunicationMessagesTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(CommunicationMessagesTestBase.class);
protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_CONNECTION_STRING_CPM",
@@ -101,7 +104,7 @@ public Mono logHeaders(HttpPipelineNextPolicy next) {
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for request "
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for request "
+ bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
diff --git a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/PhoneNumbersIntegrationTestBase.java b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/PhoneNumbersIntegrationTestBase.java
index 43789327783c..15d95cadd7c3 100644
--- a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/PhoneNumbersIntegrationTestBase.java
+++ b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/PhoneNumbersIntegrationTestBase.java
@@ -16,12 +16,16 @@
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.Configuration;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.identity.DefaultAzureCredentialBuilder;
import reactor.core.publisher.Mono;
import java.util.Arrays;
public class PhoneNumbersIntegrationTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(PhoneNumbersIntegrationTestBase.class);
+
private static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING",
"endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5");
@@ -141,8 +145,8 @@ private Mono logHeaders(String testName, HttpPipelineNextPolicy ne
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request "
- + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for " + testName + " request "
+ + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
}
diff --git a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingIntegrationTestBase.java b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingIntegrationTestBase.java
index b74c96e53805..8d0b33036d34 100644
--- a/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingIntegrationTestBase.java
+++ b/sdk/communication/azure-communication-phonenumbers/src/test/java/com/azure/communication/phonenumbers/siprouting/SipRoutingIntegrationTestBase.java
@@ -19,16 +19,20 @@
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.Configuration;
+import com.azure.core.util.CoreUtils;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.identity.DefaultAzureCredentialBuilder;
import reactor.core.publisher.Mono;
import java.util.Arrays;
import java.util.List;
-import java.util.UUID;
import static java.util.Arrays.asList;
public class SipRoutingIntegrationTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(SipRoutingIntegrationTestBase.class);
+
private static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING", "endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5");
private static final String AZURE_TEST_DOMAIN = Configuration.getGlobalConfiguration()
@@ -192,7 +196,7 @@ private Mono logHeaders(String testName, HttpPipelineNextPolicy ne
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request "
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for " + testName + " request "
+ bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
@@ -203,7 +207,7 @@ private static String getUniqueFqdn(String order) {
return order + ".redacted" + "." + AZURE_TEST_DOMAIN;
}
- String unique = UUID.randomUUID().toString().replace("-", "");
+ String unique = CoreUtils.randomUuid().toString().replace("-", "");
return order + "-" + unique + "." + AZURE_TEST_DOMAIN;
}
}
diff --git a/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsAsyncClientTests.java b/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsAsyncClientTests.java
index dc472774da6f..6fe6e520b73d 100644
--- a/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsAsyncClientTests.java
+++ b/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsAsyncClientTests.java
@@ -3,33 +3,42 @@
package com.azure.communication.rooms;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
+import com.azure.communication.common.CommunicationIdentifier;
+import com.azure.communication.common.CommunicationUserIdentifier;
import com.azure.communication.identity.CommunicationIdentityClient;
-import com.azure.communication.rooms.models.*;
import com.azure.communication.rooms.implementation.models.CommunicationErrorResponseException;
+import com.azure.communication.rooms.models.AddOrUpdateParticipantsResult;
+import com.azure.communication.rooms.models.CommunicationRoom;
+import com.azure.communication.rooms.models.CreateRoomOptions;
+import com.azure.communication.rooms.models.ParticipantRole;
+import com.azure.communication.rooms.models.RemoveParticipantsResult;
+import com.azure.communication.rooms.models.RoomParticipant;
+import com.azure.communication.rooms.models.UpdateRoomOptions;
import com.azure.core.http.HttpClient;
-import com.azure.core.http.rest.Response;
-import com.azure.core.util.Context;
import com.azure.core.http.rest.PagedFlux;
+import com.azure.core.http.rest.Response;
import com.azure.core.test.http.AssertingHttpClientBuilder;
-import java.util.Arrays;
-import java.util.List;
-
-import com.azure.communication.common.CommunicationIdentifier;
-import com.azure.communication.common.CommunicationUserIdentifier;
-
+import com.azure.core.util.Context;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
-
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
public class RoomsAsyncClientTests extends RoomsTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(RoomsAsyncClientTests.class);
+
private RoomsAsyncClient roomsAsyncClient;
private CommunicationIdentityClient communicationClient;
private final String nonExistRoomId = "NotExistingRoomID";
@@ -78,7 +87,7 @@ public void createRoomFullCycleWithResponseStep(HttpClient httpClient) {
Mono> response3 = roomsAsyncClient.updateRoomWithResponse(roomId, updateOptions);
- System.out.println(VALID_FROM.plusMonths(3).getDayOfYear());
+ LOGGER.log(LogLevel.VERBOSE, () -> String.valueOf(VALID_FROM.plusMonths(3).getDayOfYear()));
StepVerifier.create(response3)
.assertNext(roomResult -> {
@@ -121,10 +130,10 @@ public void createRoomFullCycleWithOutResponseStep(HttpClient httpClient) {
StepVerifier.create(response1)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertTrue(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -139,7 +148,7 @@ public void createRoomFullCycleWithOutResponseStep(HttpClient httpClient) {
StepVerifier.create(response3)
.assertNext(result3 -> {
- assertEquals(true, result3.getValidUntil().toEpochSecond() > result3.getValidFrom().toEpochSecond());
+ assertTrue(result3.getValidUntil().toEpochSecond() > result3.getValidFrom().toEpochSecond());
assertTrue(result3.isPstnDialOutEnabled());
}).verifyComplete();
@@ -168,10 +177,10 @@ public void createRoomWithNoAttributes(HttpClient httpClient) {
StepVerifier.create(response1)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertFalse(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -210,10 +219,10 @@ public void createRoomWithOnlyParticipantAttributes(HttpClient httpClient) {
StepVerifier.create(response1)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertTrue(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -241,10 +250,10 @@ public void createRoomWithOnlyPstnEnabledAttribute(HttpClient httpClient) {
StepVerifier.create(response1)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertTrue(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -566,10 +575,10 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
StepVerifier.create(createCommunicationRoom)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertTrue(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -627,7 +636,7 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
StepVerifier.create(updateParticipantResponse)
.assertNext(result -> {
- assertEquals(true, result instanceof AddOrUpdateParticipantsResult);
+ assertInstanceOf(AddOrUpdateParticipantsResult.class, result);
})
.verifyComplete();
@@ -680,7 +689,7 @@ public void addUpdateAndRemoveParticipantsOperationsWithFullFlow(HttpClient http
StepVerifier.create(removeParticipantResponse2)
.assertNext(result -> {
- assertEquals(true, result instanceof RemoveParticipantsResult);
+ assertInstanceOf(RemoveParticipantsResult.class, result);
})
.verifyComplete();
@@ -716,10 +725,10 @@ public void addParticipantsOperationWithOutResponse(HttpClient httpClient) {
StepVerifier.create(createCommunicationRoom)
.assertNext(roomResult -> {
- assertTrue(roomResult.getRoomId() != null);
- assertTrue(roomResult.getCreatedAt() != null);
- assertTrue(roomResult.getValidFrom() != null);
- assertTrue(roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
assertTrue(roomResult.isPstnDialOutEnabled());
}).verifyComplete();
@@ -772,10 +781,10 @@ public void addUpdateInvalidParticipants(HttpClient httpClient) {
StepVerifier.create(createCommunicationRoom)
.assertNext(roomResult -> {
- assertEquals(true, roomResult.getRoomId() != null);
- assertEquals(true, roomResult.getCreatedAt() != null);
- assertEquals(true, roomResult.getValidFrom() != null);
- assertEquals(true, roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
}).verifyComplete();
String roomId = createCommunicationRoom.block().getRoomId();
@@ -822,10 +831,10 @@ public void listRoomTestFirstRoomIsNotNullThenDeleteRoomWithOutResponse(HttpClie
StepVerifier.create(createCommunicationRoom)
.assertNext(roomResult -> {
- assertEquals(true, roomResult.getRoomId() != null);
- assertEquals(true, roomResult.getCreatedAt() != null);
- assertEquals(true, roomResult.getValidFrom() != null);
- assertEquals(true, roomResult.getValidUntil() != null);
+ assertNotNull(roomResult.getRoomId());
+ assertNotNull(roomResult.getCreatedAt());
+ assertNotNull(roomResult.getValidFrom());
+ assertNotNull(roomResult.getValidUntil());
}).verifyComplete();
String roomId = createCommunicationRoom.block().getRoomId();
@@ -835,10 +844,10 @@ public void listRoomTestFirstRoomIsNotNullThenDeleteRoomWithOutResponse(HttpClie
StepVerifier.create(listRoomResponse.take(1))
.assertNext(room -> {
- assertEquals(true, room.getRoomId() != null);
- assertEquals(true, room.getCreatedAt() != null);
- assertEquals(true, room.getValidFrom() != null);
- assertEquals(true, room.getValidUntil() != null);
+ assertNotNull(room.getRoomId());
+ assertNotNull(room.getCreatedAt());
+ assertNotNull(room.getValidFrom());
+ assertNotNull(room.getValidUntil());
})
.expectComplete()
.verify();
diff --git a/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsTestBase.java b/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsTestBase.java
index c78a43f7207b..d845723cd19b 100644
--- a/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsTestBase.java
+++ b/sdk/communication/azure-communication-rooms/src/test/java/com/azure/communication/rooms/RoomsTestBase.java
@@ -5,10 +5,14 @@
import com.azure.communication.common.implementation.CommunicationConnectionString;
import com.azure.communication.identity.CommunicationIdentityClientBuilder;
-import com.azure.communication.rooms.models.*;
+import com.azure.communication.rooms.models.CommunicationRoom;
+import com.azure.communication.rooms.models.RoomParticipant;
import com.azure.core.credential.AzureKeyCredential;
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
+import com.azure.core.http.HttpPipelineNextPolicy;
+import com.azure.core.http.HttpResponse;
+import com.azure.core.http.rest.Response;
import com.azure.core.test.TestMode;
import com.azure.core.test.TestProxyTestBase;
import com.azure.core.test.models.BodilessMatcher;
@@ -16,18 +20,17 @@
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
+import reactor.core.publisher.Mono;
import java.time.OffsetDateTime;
import java.util.Arrays;
-import java.util.Locale;
-import reactor.core.publisher.Mono;
-import com.azure.core.http.HttpPipelineNextPolicy;
-import com.azure.core.http.HttpResponse;
-import com.azure.core.http.rest.Response;
-import static org.junit.jupiter.api.Assertions.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class RoomsTestBase extends TestProxyTestBase {
- protected static final TestMode TEST_MODE = initializeTestMode();
+ private static final ClientLogger LOGGER = new ClientLogger(RoomsTestBase.class);
protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration().get(
"COMMUNICATION_CONNECTION_STRING_ROOMS",
@@ -112,23 +115,6 @@ protected void configureTestMode(RoomsClientBuilder builder) {
}
}
- private static TestMode initializeTestMode() {
- ClientLogger logger = new ClientLogger(RoomsTestBase.class);
- String azureTestMode = Configuration.getGlobalConfiguration().get("AZURE_TEST_MODE");
- if (azureTestMode != null) {
- System.out.println("azureTestMode: " + azureTestMode);
- try {
- return TestMode.valueOf(azureTestMode.toUpperCase(Locale.US));
- } catch (IllegalArgumentException var3) {
- logger.error("Could not parse '{}' into TestEnum. Using 'Playback' mode.", azureTestMode);
- return TestMode.PLAYBACK;
- }
- } else {
- logger.info("Environment variable '{}' has not been set yet. Using 'Playback' mode.", "AZURE_TEST_MODE");
- return TestMode.PLAYBACK;
- }
- }
-
protected RoomsClientBuilder addLoggingPolicy(RoomsClientBuilder builder, String testName) {
return builder.addPolicy((context, next) -> logHeaders(testName, next));
}
@@ -153,8 +139,8 @@ private Mono logHeaders(String testName, HttpPipelineNextPolicy ne
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request " + bufferedResponse.getRequest().getUrl()
- + ": " + bufferedResponse.getHeaderValue("MS-CV"));
+ LOGGER.log(LogLevel.VERBOSE, () -> "MS-CV header for " + testName + " request "
+ + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
return Mono.just(bufferedResponse);
});
}
diff --git a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java
index fdffac7a5479..bbfcda8cc29f 100644
--- a/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java
+++ b/sdk/communication/azure-communication-sms/src/test/java/com/azure/communication/sms/SmsTestBase.java
@@ -15,11 +15,15 @@
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.test.utils.MockTokenCredential;
import com.azure.core.util.Configuration;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import reactor.core.publisher.Mono;
import java.util.Arrays;
public class SmsTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(SmsTestBase.class);
+
protected static final String CONNECTION_STRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", "endpoint=https://REDACTED.communication.azure.com/;accesskey=QWNjZXNzS2V5");
@@ -95,8 +99,8 @@ private Mono logHeaders(String testName, HttpPipelineNextPolicy ne
final HttpResponse bufferedResponse = httpResponse.buffer();
// Should sanitize printed reponse url
- System.out.println("MS-CV header for " + testName + " request "
- + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV"));
+ LOGGER.log(LogLevel.VERBOSE, () -> ("MS-CV header for " + testName + " request "
+ + bufferedResponse.getRequest().getUrl() + ": " + bufferedResponse.getHeaderValue("MS-CV")));
return Mono.just(bufferedResponse);
});
}
diff --git a/sdk/confidentialledger/azure-security-confidentialledger/src/test/java/com/azure/security/confidentialledger/ConfidentialLedgerClientTestBase.java b/sdk/confidentialledger/azure-security-confidentialledger/src/test/java/com/azure/security/confidentialledger/ConfidentialLedgerClientTestBase.java
index c91b8d5c6cf1..d9c220dd946f 100644
--- a/sdk/confidentialledger/azure-security-confidentialledger/src/test/java/com/azure/security/confidentialledger/ConfidentialLedgerClientTestBase.java
+++ b/sdk/confidentialledger/azure-security-confidentialledger/src/test/java/com/azure/security/confidentialledger/ConfidentialLedgerClientTestBase.java
@@ -18,6 +18,8 @@
import com.azure.core.test.models.TestProxySanitizer;
import com.azure.core.test.models.TestProxySanitizerType;
import com.azure.core.util.BinaryData;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.security.confidentialledger.certificate.ConfidentialLedgerCertificateClient;
import com.azure.security.confidentialledger.certificate.ConfidentialLedgerCertificateClientBuilder;
@@ -39,6 +41,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
class ConfidentialLedgerClientTestBase extends TestProxyTestBase {
+ private static final ClientLogger LOGGER = new ClientLogger(ConfidentialLedgerClientTestBase.class);
protected static final String TRANSACTION_ID = "transactionId";
protected static final String COLLECTION_ID = "collectionId";
@@ -82,7 +85,7 @@ protected void beforeTest() {
try {
jsonNode = mapper.readTree(identityResponse.toBytes());
} catch (IOException ex) {
- System.out.println("Caught IO exception " + ex);
+ LOGGER.log(LogLevel.VERBOSE, () -> "Caught IO exception", ex);
Assertions.fail();
}
@@ -104,7 +107,7 @@ protected void beforeTest() {
reactorClient = reactor.netty.http.client.HttpClient.create()
.secure(sslContextSpec -> sslContextSpec.sslContext(sslContext));
} catch (SSLException ex) {
- System.out.println("Caught SSL exception " + ex);
+ LOGGER.log(LogLevel.VERBOSE, () -> "Caught SSL exception", ex);
Assertions.fail();
}
diff --git a/sdk/containerregistry/azure-containers-containerregistry/src/test/java/com/azure/containers/containerregistry/TestUtils.java b/sdk/containerregistry/azure-containers-containerregistry/src/test/java/com/azure/containers/containerregistry/TestUtils.java
index d844c0558d86..839f886a4b87 100644
--- a/sdk/containerregistry/azure-containers-containerregistry/src/test/java/com/azure/containers/containerregistry/TestUtils.java
+++ b/sdk/containerregistry/azure-containers-containerregistry/src/test/java/com/azure/containers/containerregistry/TestUtils.java
@@ -125,7 +125,6 @@ static TokenCredential getCredentialByAuthority(TestMode testMode, String author
static void importImage(TestMode mode, String repository, List tags) {
try {
importImage(mode, REGISTRY_NAME, repository, tags, REGISTRY_ENDPOINT);
- Thread.sleep(SLEEP_TIME_IN_MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
}
@@ -190,6 +189,8 @@ static void importImage(TestMode mode, String registryName, String repository, L
Thread.sleep(SLEEP_TIME_IN_MILLISECONDS);
}
} while (++index < 3);
+
+ Thread.sleep(SLEEP_TIME_IN_MILLISECONDS);
}
private static OciImageManifest createManifest() {
diff --git a/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/implementation/JdkHttpUtils.java b/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/implementation/JdkHttpUtils.java
index 85ae06b2f5a3..bc9a29d746c2 100644
--- a/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/implementation/JdkHttpUtils.java
+++ b/sdk/core/azure-core-http-jdk-httpclient/src/main/java/com/azure/core/http/jdk/httpclient/implementation/JdkHttpUtils.java
@@ -3,6 +3,7 @@
package com.azure.core.http.jdk.httpclient.implementation;
import com.azure.core.http.HttpHeaders;
+import com.azure.core.implementation.util.HttpHeadersAccessHelper;
import com.azure.core.util.CoreUtils;
import java.nio.ByteBuffer;
@@ -25,13 +26,14 @@ public final class JdkHttpUtils {
* @param headers the JDK Http headers
* @return the azure-core Http headers
*/
- @SuppressWarnings("deprecation")
public static HttpHeaders fromJdkHttpHeaders(java.net.http.HttpHeaders headers) {
final HttpHeaders httpHeaders = new HttpHeaders((int) (headers.map().size() / 0.75F));
for (Map.Entry> kvp : headers.map().entrySet()) {
if (!CoreUtils.isNullOrEmpty(kvp.getValue())) {
- httpHeaders.set(kvp.getKey(), kvp.getValue());
+ // JDK HttpClient parses headers to lower case, use the access helper to bypass lowercasing the header
+ // name (or in this case, just checking that the header name is lowercased).
+ HttpHeadersAccessHelper.setInternal(httpHeaders, kvp.getKey(), kvp.getKey(), kvp.getValue());
}
}
diff --git a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/NettyAsyncHttpResponseBase.java b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/NettyAsyncHttpResponseBase.java
index 5346aeb2948a..6621a80eea46 100644
--- a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/NettyAsyncHttpResponseBase.java
+++ b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/NettyAsyncHttpResponseBase.java
@@ -7,10 +7,13 @@
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
+import com.azure.core.implementation.util.HttpHeadersAccessHelper;
+import io.netty.util.AsciiString;
import reactor.netty.http.client.HttpClientResponse;
import java.util.Iterator;
import java.util.Map;
+import java.util.Objects;
/**
* Base response class for Reactor Netty with implementations for response metadata.
@@ -40,8 +43,19 @@ public abstract class NettyAsyncHttpResponseBase extends HttpResponse {
while (nettyHeadersIterator.hasNext()) {
Map.Entry next = nettyHeadersIterator.next();
// Value may be null and that needs to be guarded but key should never be null.
- CharSequence value = next.getValue();
- this.headers.add(next.getKey().toString(), (value == null) ? null : value.toString());
+ String value = Objects.toString(next.getValue(), null);
+ CharSequence key = next.getKey();
+
+ // Check for the header name being a Netty AsciiString as it has optimizations around lowercasing.
+ if (key instanceof AsciiString) {
+ // Hook into optimizations exposed through shared implementation to speed up the conversion.
+ AsciiString asciiString = (AsciiString) key;
+ HttpHeadersAccessHelper.addInternal(headers, asciiString.toLowerCase().toString(),
+ asciiString.toString(), value);
+ } else {
+ // If it isn't an AsciiString, then fallback to the shared, albeit, slower path.
+ this.headers.add(key.toString(), value);
+ }
}
} else {
this.headers = new NettyToAzureCoreHttpHeadersWrapper(nettyHeaders);
diff --git a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/Utility.java b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/Utility.java
index 33a18a4fe343..670e41710e34 100644
--- a/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/Utility.java
+++ b/sdk/core/azure-core-http-netty/src/main/java/com/azure/core/http/netty/implementation/Utility.java
@@ -51,10 +51,9 @@ public final class Utility {
* @return A newly allocated {@link ByteBuffer} containing the copied bytes.
*/
public static ByteBuffer deepCopyBuffer(ByteBuf byteBuf) {
- ByteBuffer buffer = ByteBuffer.allocate(byteBuf.readableBytes());
- byteBuf.readBytes(buffer);
- buffer.rewind();
- return buffer;
+ byte[] bytes = new byte[byteBuf.readableBytes()];
+ byteBuf.getBytes(byteBuf.readerIndex(), bytes);
+ return ByteBuffer.wrap(bytes);
}
/**
diff --git a/sdk/core/azure-core-management/src/test/java/com/azure/core/management/implementation/polling/LROPollerTests.java b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/implementation/polling/LROPollerTests.java
index d20086bf9d0c..031ed96e6cd0 100644
--- a/sdk/core/azure-core-management/src/test/java/com/azure/core/management/implementation/polling/LROPollerTests.java
+++ b/sdk/core/azure-core-management/src/test/java/com/azure/core/management/implementation/polling/LROPollerTests.java
@@ -22,6 +22,8 @@
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.logging.LogLevel;
import com.azure.core.util.polling.AsyncPollResponse;
import com.azure.core.util.polling.LongRunningOperationStatus;
import com.azure.core.util.polling.PollerFlux;
@@ -61,6 +63,7 @@
@SuppressWarnings("unchecked")
public class LROPollerTests {
+ private static final ClientLogger LOGGER = new ClientLogger(LROPollerTests.class);
private static final SerializerAdapter SERIALIZER = SerializerFactory.createDefaultManagementSerializerAdapter();
@@ -678,8 +681,12 @@ public void lroRetryAfter() {
long nanoTime = System.nanoTime();
- FooWithProvisioningState result = lroFlux.doOnNext(response -> System.out.printf("[%s] status %s%n",
- OffsetDateTime.now(), response.getStatus().toString())).blockLast().getFinalResult().block();
+ FooWithProvisioningState result = lroFlux
+ .doOnNext(response -> LOGGER.log(LogLevel.VERBOSE,
+ () -> String.format("[%s] status %s%n", OffsetDateTime.now(), response.getStatus())))
+ .blockLast()
+ .getFinalResult()
+ .block();
Assertions.assertNotNull(result);
Duration pollingDuration = Duration.ofNanos(System.nanoTime() - nanoTime);
@@ -879,7 +886,8 @@ public com.github.tomakehurst.wiremock.http.Response transform(Request request,
.build();
}
if (request.getMethod().isOneOf(RequestMethod.PUT)) {
- System.out.printf("[%s] PUT status %s%n", OffsetDateTime.now(), "IN_PROGRESS");
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> String.format("[%s] PUT status %s%n", OffsetDateTime.now(), "IN_PROGRESS"));
return new com.github.tomakehurst.wiremock.http.Response.Builder()
.headers(serverConfigure.additionalHeaders)
.body(toJson(new FooWithProvisioningState("IN_PROGRESS")))
@@ -888,13 +896,15 @@ public com.github.tomakehurst.wiremock.http.Response transform(Request request,
if (request.getMethod().isOneOf(RequestMethod.GET)) {
getCallCount[0]++;
if (getCallCount[0] < serverConfigure.pollingCountTillSuccess) {
- System.out.printf("[%s] GET status %s%n", OffsetDateTime.now(), "IN_PROGRESS");
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> String.format("[%s] GET status %s%n", OffsetDateTime.now(), "IN_PROGRESS"));
return new com.github.tomakehurst.wiremock.http.Response.Builder()
.headers(serverConfigure.additionalHeaders)
.body(toJson(new FooWithProvisioningState("IN_PROGRESS")))
.build();
} else if (getCallCount[0] == serverConfigure.pollingCountTillSuccess) {
- System.out.printf("[%s] GET status %s%n", OffsetDateTime.now(), "SUCCEEDED");
+ LOGGER.log(LogLevel.VERBOSE,
+ () -> String.format("[%s] GET status %s%n", OffsetDateTime.now(), "SUCCEEDED"));
return new com.github.tomakehurst.wiremock.http.Response.Builder()
.body(toJson(new FooWithProvisioningState("SUCCEEDED", UUID.randomUUID().toString())))
.build();
diff --git a/sdk/core/azure-core/spotbugs-exclude.xml b/sdk/core/azure-core/spotbugs-exclude.xml
index 4fd09a2c2551..2ffee6a08a69 100644
--- a/sdk/core/azure-core/spotbugs-exclude.xml
+++ b/sdk/core/azure-core/spotbugs-exclude.xml
@@ -449,4 +449,10 @@
+
+
+
+
+
+
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpHeaders.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpHeaders.java
index b42992287c1a..c52fa19e5cbd 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpHeaders.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpHeaders.java
@@ -33,7 +33,22 @@ public class HttpHeaders implements Iterable {
private final Map headers;
static {
- HttpHeadersAccessHelper.setAccessor(headers -> headers.headers);
+ HttpHeadersAccessHelper.setAccessor(new HttpHeadersAccessHelper.HttpHeadersAccessor() {
+ @Override
+ public Map getRawHeaderMap(HttpHeaders headers) {
+ return headers.headers;
+ }
+
+ @Override
+ public void addInternal(HttpHeaders headers, String formattedName, String name, String value) {
+ headers.addInternal(formattedName, name, value);
+ }
+
+ @Override
+ public void setInternal(HttpHeaders headers, String formattedName, String name, List values) {
+ headers.setInternal(formattedName, name, values);
+ }
+ });
}
/**
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java
index 615f231971c3..b37eb2c46b7f 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/BearerTokenAuthenticationPolicy.java
@@ -123,16 +123,11 @@ public Mono process(HttpPipelineCallContext context, HttpPipelineN
return authorizeRequest(context).then(Mono.defer(next::process)).flatMap(httpResponse -> {
String authHeader = httpResponse.getHeaderValue(HttpHeaderName.WWW_AUTHENTICATE);
if (httpResponse.getStatusCode() == 401 && authHeader != null) {
- return authorizeRequestOnChallenge(context, httpResponse).flatMap(retry -> {
- if (retry) {
- // Both Netty and OkHttp expect the requestBody to be closed after the response has been read.
- // Failure to do so results in memory leak.
- // In case of StreamResponse (or other scenarios where we do not eagerly read the response)
- // the response body may not be consumed.
- // This can cause potential leaks in the scenarios like above, where the policy
- // may intercept the response and it may never be read.
- // Forcing the read here - so that the memory can be released.
- return httpResponse.getBody().ignoreElements().then(nextPolicy.process());
+ return authorizeRequestOnChallenge(context, httpResponse).flatMap(authorized -> {
+ if (authorized) {
+ // body needs to be closed or read to the end to release the connection
+ httpResponse.close();
+ return nextPolicy.process();
} else {
return Mono.just(httpResponse);
}
@@ -155,13 +150,8 @@ public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNex
String authHeader = httpResponse.getHeaderValue(HttpHeaderName.WWW_AUTHENTICATE);
if (httpResponse.getStatusCode() == 401 && authHeader != null) {
if (authorizeRequestOnChallengeSync(context, httpResponse)) {
- // Both Netty and OkHttp expect the requestBody to be closed after the response has been read.
- // Failure to do so results in memory leak.
- // In case of StreamResponse (or other scenarios where we do not eagerly read the response)
- // the response body may not be consumed.
- // This can cause potential leaks in the scenarios like above, where the policy
- // may intercept the response and it may never be read.
- // Forcing the read here - so that the memory can be released.
+ // body needs to be closed or read to the end to release the connection
+ httpResponse.close();
return nextPolicy.processSync();
} else {
return httpResponse;
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/RedirectPolicy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/RedirectPolicy.java
index fcc969e5216f..d0758d6b7d5d 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/RedirectPolicy.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/policy/RedirectPolicy.java
@@ -89,7 +89,6 @@ private Mono attemptRedirect(final HttpPipelineCallContext context
return next.clone().process().flatMap(httpResponse -> {
if (redirectStrategy.shouldAttemptRedirect(context, httpResponse, redirectAttempt, attemptedRedirectUrls)) {
-
HttpRequest redirectRequestCopy = createRedirectRequest(httpResponse);
return attemptRedirect(context, next, redirectRequestCopy, redirectAttempt + 1, attemptedRedirectUrls);
} else {
@@ -111,7 +110,6 @@ private HttpResponse attemptRedirectSync(final HttpPipelineCallContext context,
HttpResponse httpResponse = next.clone().processSync();
if (redirectStrategy.shouldAttemptRedirect(context, httpResponse, redirectAttempt, attemptedRedirectUrls)) {
-
HttpRequest redirectRequestCopy = createRedirectRequest(httpResponse);
return attemptRedirectSync(context, next, redirectRequestCopy, redirectAttempt + 1, attemptedRedirectUrls);
} else {
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java
index 6e3c8d9a611e..de36dac2045e 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java
@@ -82,8 +82,6 @@ public Mono send(HttpRequest request, Context contextData) {
@Override
public Object invoke(Object proxy, final Method method, Object[] args) {
- RestProxyUtils.validateResumeOperationIsNotPresent(method);
-
// Note: request options need to be evaluated here, as it is a public class with package private methods.
// Evaluating here allows the package private methods to be invoked here for downstream use.
final SwaggerMethodParser methodParser = getMethodParser(method);
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/AsyncRestProxy.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/AsyncRestProxy.java
index a09db64f1d79..2548bec2a64f 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/AsyncRestProxy.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/AsyncRestProxy.java
@@ -75,8 +75,6 @@ Mono send(HttpRequest request, Context contextData) {
@SuppressWarnings({ "try", "unused" })
public Object invoke(Object proxy, Method method, RequestOptions options, EnumSet errorOptions,
Consumer requestCallback, SwaggerMethodParser methodParser, HttpRequest request, Context context) {
- RestProxyUtils.validateResumeOperationIsNotPresent(method);
-
context = startTracingSpan(methodParser, context);
// If there is 'RequestOptions' apply its request callback operations before validating the body.
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/RestProxyBase.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/RestProxyBase.java
index af018bfc0d95..67f4ea40662e 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/RestProxyBase.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/RestProxyBase.java
@@ -98,8 +98,6 @@ public RestProxyBase(HttpPipeline httpPipeline, SerializerAdapter serializer,
*/
public final Object invoke(Object proxy, Method method, RequestOptions options, EnumSet errorOptions,
Consumer requestCallback, SwaggerMethodParser methodParser, boolean isAsync, Object[] args) {
- RestProxyUtils.validateResumeOperationIsNotPresent(method);
-
try {
HttpRequest request = createHttpRequest(methodParser, serializer, isAsync, args);
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/SwaggerMethodParser.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/SwaggerMethodParser.java
index 7401e138f985..94f1674f3348 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/SwaggerMethodParser.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/rest/SwaggerMethodParser.java
@@ -285,6 +285,8 @@ public SwaggerMethodParser(Method swaggerMethod) {
this.responseEagerlyRead = isResponseEagerlyRead(unwrappedReturnType);
this.ignoreResponseBody = isResponseBodyIgnored(unwrappedReturnType);
this.spanName = interfaceParser.getServiceName() + "." + swaggerMethod.getName();
+
+ RestProxyUtils.validateResumeOperationIsNotPresent(swaggerMethod);
}
/**
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/util/HttpHeadersAccessHelper.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/util/HttpHeadersAccessHelper.java
index 304f082277fa..bbf6c87e2250 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/util/HttpHeadersAccessHelper.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/util/HttpHeadersAccessHelper.java
@@ -5,6 +5,8 @@
import com.azure.core.http.HttpHeader;
import com.azure.core.http.HttpHeaders;
+import java.util.List;
+import java.util.Locale;
import java.util.Map;
/**
@@ -24,6 +26,34 @@ public interface HttpHeadersAccessor {
* @return The raw header map.
*/
Map getRawHeaderMap(HttpHeaders headers);
+
+ /**
+ * Adds a header value to the backing map in {@link HttpHeaders}.
+ *
+ * This bypasses using {@link HttpHeaders#add(String, String)} which uses {@link String#toLowerCase(Locale)},
+ * which may be slower than options available by implementing HTTP stacks (such as Netty which has an ASCII
+ * string class which has optimizations around lowercasing due to ASCII constraints).
+ *
+ * @param headers The {@link HttpHeaders} to add the header to.
+ * @param formattedName The lower-cased header name.
+ * @param name The original header name.
+ * @param value The header value.
+ */
+ void addInternal(HttpHeaders headers, String formattedName, String name, String value);
+
+ /**
+ * Sets a header value to the backing map in {@link HttpHeaders}.
+ *
+ * This bypasses using {@link HttpHeaders#set(String, List)} which uses {@link String#toLowerCase(Locale)},
+ * which may be slower than options available by implementing HTTP stacks (such as JDK HttpClient where all
+ * response header names are already lowercased).
+ *
+ * @param headers The {@link HttpHeaders} to set the header to.
+ * @param formattedName The lower-cased header name.
+ * @param name The original header name.
+ * @param values The header values.
+ */
+ void setInternal(HttpHeaders headers, String formattedName, String name, List values);
}
/**
@@ -36,6 +66,38 @@ public static Map getRawHeaderMap(HttpHeaders headers) {
return accessor.getRawHeaderMap(headers);
}
+ /**
+ * Adds a header value to the backing map in {@link HttpHeaders}.
+ *
+ * This bypasses using {@link HttpHeaders#add(String, String)} which uses {@link String#toLowerCase(Locale)},
+ * which may be slower than options available by implementing HTTP stacks (such as Netty which has an ASCII
+ * string class which has optimizations around lowercasing due to ASCII constraints).
+ *
+ * @param headers The {@link HttpHeaders} to add the header to.
+ * @param formattedName The lower-cased header name.
+ * @param name The original header name.
+ * @param value The header value.
+ */
+ public static void addInternal(HttpHeaders headers, String formattedName, String name, String value) {
+ accessor.addInternal(headers, formattedName, name, value);
+ }
+
+ /**
+ * Sets a header value to the backing map in {@link HttpHeaders}.
+ *
+ * This bypasses using {@link HttpHeaders#set(String, List)} which uses {@link String#toLowerCase(Locale)},
+ * which may be slower than options available by implementing HTTP stacks (such as JDK HttpClient where all
+ * response header names are already lowercased).
+ *
+ * @param headers The {@link HttpHeaders} to set the header to.
+ * @param formattedName The lower-cased header name.
+ * @param name The original header name.
+ * @param values The header values.
+ */
+ public static void setInternal(HttpHeaders headers, String formattedName, String name, List values) {
+ accessor.setInternal(headers, formattedName, name, values);
+ }
+
/**
* Sets the {@link HttpHeadersAccessor}.
*
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/SerializerEncoding.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/SerializerEncoding.java
index 4d4bf4985d5f..c8207428a790 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/SerializerEncoding.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/SerializerEncoding.java
@@ -9,9 +9,6 @@
import com.azure.core.util.logging.ClientLogger;
import com.azure.core.util.logging.LogLevel;
-import java.util.Map;
-import java.util.TreeMap;
-
/**
* Supported serialization encoding formats.
*/
@@ -32,20 +29,6 @@ public enum SerializerEncoding {
TEXT;
private static final ClientLogger LOGGER = new ClientLogger(SerializerEncoding.class);
- private static final Map SUPPORTED_MIME_TYPES;
-
- static {
- // Encodings and suffixes from: https://tools.ietf.org/html/rfc6838
- SUPPORTED_MIME_TYPES = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- SUPPORTED_MIME_TYPES.put("text/xml", XML);
- SUPPORTED_MIME_TYPES.put("application/xml", XML);
- SUPPORTED_MIME_TYPES.put("application/json", JSON);
- SUPPORTED_MIME_TYPES.put("text/css", TEXT);
- SUPPORTED_MIME_TYPES.put("text/csv", TEXT);
- SUPPORTED_MIME_TYPES.put("text/html", TEXT);
- SUPPORTED_MIME_TYPES.put("text/javascript", TEXT);
- SUPPORTED_MIME_TYPES.put("text/plain", TEXT);
- }
/**
* Determines the serializer encoding to use based on the Content-Type header.
@@ -63,7 +46,7 @@ public static SerializerEncoding fromHeaders(HttpHeaders headers) {
int contentTypeEnd = mimeContentType.indexOf(';');
String contentType = (contentTypeEnd == -1) ? mimeContentType : mimeContentType.substring(0, contentTypeEnd);
- final SerializerEncoding encoding = SUPPORTED_MIME_TYPES.get(contentType);
+ SerializerEncoding encoding = checkForKnownEncoding(contentType);
if (encoding != null) {
return encoding;
}
@@ -97,4 +80,43 @@ public static SerializerEncoding fromHeaders(HttpHeaders headers) {
return JSON;
}
+
+ /*
+ * There is a limited set of serialization encodings that are known ahead of time. Instead of using a TreeMap with
+ * a case-insensitive comparator, use an optimized search specifically for the known encodings.
+ */
+ private static SerializerEncoding checkForKnownEncoding(String contentType) {
+ int length = contentType.length();
+
+ // Check the length of the content type first as it is a quick check.
+ if (length != 8 && length != 9 && length != 10 && length != 15 && length != 16) {
+ return null;
+ }
+
+ if ("text/".regionMatches(true, 0, contentType, 0, 5)) {
+ if (length == 8) {
+ if ("xml".regionMatches(true, 0, contentType, 5, 3)) {
+ return XML;
+ } else if ("csv".regionMatches(true, 0, contentType, 5, 3)) {
+ return TEXT;
+ } else if ("css".regionMatches(true, 0, contentType, 5, 3)) {
+ return TEXT;
+ }
+ } else if (length == 9 && "html".regionMatches(true, 0, contentType, 5, 4)) {
+ return TEXT;
+ } else if (length == 10 && "plain".regionMatches(true, 0, contentType, 5, 5)) {
+ return TEXT;
+ } else if (length == 15 && "javascript".regionMatches(true, 0, contentType, 5, 10)) {
+ return TEXT;
+ }
+ } else if ("application/".regionMatches(true, 0, contentType, 0, 12)) {
+ if (length == 16 && "json".regionMatches(true, 0, contentType, 12, 4)) {
+ return JSON;
+ } else if (length == 15 && "xml".regionMatches(true, 0, contentType, 12, 3)) {
+ return XML;
+ }
+ }
+
+ return null;
+ }
}
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/PolicyConsumesResponseBodyTest.java b/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/PolicyConsumesResponseBodyTest.java
new file mode 100644
index 000000000000..06573971f1f9
--- /dev/null
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/http/policy/PolicyConsumesResponseBodyTest.java
@@ -0,0 +1,430 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.core.http.policy;
+
+import com.azure.core.SyncAsyncExtension;
+import com.azure.core.SyncAsyncTest;
+import com.azure.core.credential.AccessToken;
+import com.azure.core.credential.TokenCredential;
+import com.azure.core.http.*;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.Context;
+import com.azure.core.util.FluxUtil;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.AsynchronousByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.time.OffsetDateTime;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.function.Function;
+
+import static com.azure.core.http.HttpHeaderName.*;
+import static org.junit.jupiter.api.Assertions.*;
+
+public class PolicyConsumesResponseBodyTest {
+
+ private static final TokenCredential NOOP_CREDENTIAL
+ = request -> Mono.just(new AccessToken("token", OffsetDateTime.MAX));
+
+ @ParameterizedTest
+ @ValueSource(booleans = { true, false })
+ public void testResponseClosureOn401Sync(boolean authorizeOnChallenge) {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference response401 = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new BearerPolicyImpl(authorizeOnChallenge, NOOP_CREDENTIAL, "scope"))
+ .httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse r401 = createWithSyncBody(r, 401, 424242);
+ r401.headers.set(WWW_AUTHENTICATE, "Bearer");
+ response401.set(r401);
+ return r401;
+ }
+ return createWithSyncBody(r, 200, 42);
+ }))
+ .build();
+
+ HttpResponse response = pipeline.sendSync(new HttpRequest(HttpMethod.GET, "https://fake"), Context.NONE);
+ assertEquals(authorizeOnChallenge ? 200 : 401, response.getStatusCode());
+ assertEquals(authorizeOnChallenge ? 2 : 1, tryCount.get());
+
+ if (authorizeOnChallenge) {
+ assertTrue(response401.get().isConsumedOrClosed());
+ }
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @ParameterizedTest
+ @ValueSource(booleans = { true, false })
+ public void testResponseClosureOn401Async(boolean authorizeOnChallenge) {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference response401 = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new BearerPolicyImpl(authorizeOnChallenge, NOOP_CREDENTIAL, "scope"))
+ .httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse r401 = createWithAsyncBody(r, 401, 424242);
+ r401.headers.set(WWW_AUTHENTICATE, "Bearer");
+ response401.set(r401);
+ return r401;
+ }
+ return createWithAsyncBody(r, 200, 42);
+ }))
+ .build();
+
+ HttpResponse response = pipeline.send(new HttpRequest(HttpMethod.GET, "https://fake")).block();
+ assertEquals(authorizeOnChallenge ? 200 : 401, response.getStatusCode());
+ assertEquals(authorizeOnChallenge ? 2 : 1, tryCount.get());
+
+ if (authorizeOnChallenge) {
+ assertTrue(response401.get().isConsumedOrClosed());
+ }
+
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @SyncAsyncTest
+ public void testResponseClosureOn401AndException() throws Exception {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference responseException = new AtomicReference<>();
+ HttpPipeline pipeline = new HttpPipelineBuilder().policies(new BearerPolicyImpl(true, NOOP_CREDENTIAL, "scope"))
+ .httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse r401
+ = createWithAsyncBodyAndException(r, 401, 424242, new IOException("Fake exception"));
+ r401.headers.set(WWW_AUTHENTICATE, "Bearer");
+ responseException.set(r401);
+ return r401;
+ }
+ return createWithSyncBody(r, 200, 42);
+ }))
+ .build();
+
+ HttpRequest request = new HttpRequest(HttpMethod.GET, "https://fake");
+ HttpResponse response = SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE),
+ () -> pipeline.send(request).block());
+
+ assertEquals(200, response.getStatusCode());
+
+ assertEquals(2, tryCount.get());
+ assertTrue(responseException.get().isConsumedOrClosed());
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @SyncAsyncTest
+ public void testResponseClosureOn302() throws Exception {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference response302 = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new RedirectPolicy()).httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse r302 = createWithAsyncBody(r, 302, 424242);
+ r302.headers.set(LOCATION, "https://fake");
+ response302.set(r302);
+ return r302;
+ }
+ return createWithAsyncBody(r, 200, 42);
+ })).build();
+
+ HttpRequest request = new HttpRequest(HttpMethod.GET, "https://fake");
+ HttpResponse response = SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE),
+ () -> pipeline.send(request).block());
+
+ assertEquals(200, response.getStatusCode());
+
+ assertEquals(2, tryCount.get());
+ assertTrue(response302.get().isConsumedOrClosed());
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @SyncAsyncTest
+ public void testResponseClosureOn302AndException() throws Exception {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference responseException = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new RedirectPolicy()).httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse rEx
+ = createWithAsyncBodyAndException(r, 302, 424242, new IOException("Fake exception"));
+ rEx.headers.set(LOCATION, "https://fake");
+ responseException.set(rEx);
+ return rEx;
+ }
+ return createWithSyncBody(r, 200, 42);
+ })).build();
+
+ HttpRequest request = new HttpRequest(HttpMethod.GET, "https://fake");
+ HttpResponse response = SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE),
+ () -> pipeline.send(request).block());
+
+ assertEquals(200, response.getStatusCode());
+
+ assertEquals(2, tryCount.get());
+ assertTrue(responseException.get().isConsumedOrClosed());
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @SyncAsyncTest
+ public void testResponseClosureOn503() throws Exception {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference response503 = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new RetryPolicy()).httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ response503.set(createWithSyncBody(r, 503, 424242));
+ return response503.get();
+ }
+ return createWithSyncBody(r, 200, 42);
+ })).build();
+
+ HttpRequest request = new HttpRequest(HttpMethod.GET, "https://fake");
+ HttpResponse response = SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE),
+ () -> pipeline.send(request).block());
+
+ assertEquals(200, response.getStatusCode());
+
+ assertEquals(2, tryCount.get());
+ assertTrue(response503.get().isConsumedOrClosed());
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ @SyncAsyncTest
+ public void testResponseClosureOn503AndException() throws Exception {
+ AtomicInteger tryCount = new AtomicInteger(0);
+
+ AtomicReference responseException = new AtomicReference<>();
+ HttpPipeline pipeline
+ = new HttpPipelineBuilder().policies(new RetryPolicy()).httpClient(new TestHttpClient(r -> {
+ if (tryCount.getAndIncrement() == 0) {
+ TestHttpResponse rEx
+ = createWithAsyncBodyAndException(r, 503, 424242, new IOException("Fake exception"));
+ responseException.set(rEx);
+ return rEx;
+ }
+ return createWithSyncBody(r, 200, 42);
+ })).build();
+
+ HttpRequest request = new HttpRequest(HttpMethod.GET, "https://fake");
+ HttpResponse response = SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE),
+ () -> pipeline.send(request).block());
+
+ assertEquals(200, response.getStatusCode());
+
+ assertEquals(2, tryCount.get());
+ assertTrue(responseException.get().isConsumedOrClosed());
+ assertInstanceOf(TestHttpResponse.class, response);
+ assertFalse(((TestHttpResponse) response).isConsumedOrClosed());
+ }
+
+ private TestHttpResponse createWithSyncBody(HttpRequest request, int statusCode, int contentLength) {
+ HttpHeaders headers = new HttpHeaders().set(CONTENT_LENGTH, Integer.toString(contentLength));
+ return new TestHttpResponse(request, statusCode, headers, new ByteArrayInputStream(new byte[contentLength]));
+ }
+
+ private TestHttpResponse createWithAsyncBody(HttpRequest request, int statusCode, int contentLength) {
+ HttpHeaders headers = new HttpHeaders().set(CONTENT_LENGTH, Integer.toString(contentLength));
+ return new TestHttpResponse(request, statusCode, headers, Flux.create(s -> {
+ for (int remaining = contentLength; remaining > 0; remaining -= 10) {
+ byte[] bytes = new byte[Math.min(10, remaining)];
+ s.next(ByteBuffer.wrap(bytes));
+ }
+ s.complete();
+ }));
+ }
+
+ private TestHttpResponse createWithAsyncBodyAndException(HttpRequest request, int statusCode, int contentLength,
+ Exception exception) {
+ HttpHeaders headers = new HttpHeaders().set(CONTENT_LENGTH, Integer.toString(contentLength));
+ return new TestHttpResponse(request, statusCode, headers, Flux.create(s -> {
+ byte[] bytes = new byte[Math.min(10, contentLength)];
+ s.next(ByteBuffer.wrap(bytes));
+ s.error(exception);
+ }));
+ }
+
+ private class BearerPolicyImpl extends BearerTokenAuthenticationPolicy {
+ private final boolean authorize;
+
+ BearerPolicyImpl(boolean authorize, TokenCredential credential, String... scopes) {
+ super(credential, scopes);
+ this.authorize = authorize;
+ }
+
+ @Override
+ public boolean authorizeRequestOnChallengeSync(HttpPipelineCallContext context, HttpResponse response) {
+ return authorize;
+ }
+
+ @Override
+ public Mono authorizeRequestOnChallenge(HttpPipelineCallContext context, HttpResponse response) {
+ return Mono.just(authorize);
+ }
+ }
+
+ private static class TestHttpClient implements HttpClient {
+ private final Function responseProvider;
+
+ TestHttpClient(Function responseProvider) {
+ this.responseProvider = responseProvider;
+ }
+
+ @Override
+ public Mono send(HttpRequest request) {
+ return Mono.just(responseProvider.apply(request));
+ }
+
+ @Override
+ public HttpResponse sendSync(HttpRequest request, Context context) {
+ return responseProvider.apply(request);
+ }
+ }
+
+ public class TestHttpResponse extends HttpResponse {
+
+ private final int statusCode;
+
+ private final HttpHeaders headers;
+
+ private final Flux bodyFlux;
+ private final ByteArrayInputStream bodyStream;
+ private boolean closed = false;
+ private boolean consumed = false;
+
+ public TestHttpResponse(HttpRequest request, int statusCode, HttpHeaders headers, Flux body) {
+ super(request);
+ this.statusCode = statusCode;
+ this.headers = headers;
+ this.bodyFlux = body.doFinally(__ -> consumed = true);
+ this.bodyStream = null;
+ }
+
+ public TestHttpResponse(HttpRequest request, int statusCode, HttpHeaders headers, ByteArrayInputStream body) {
+ super(request);
+ this.statusCode = statusCode;
+ this.headers = headers;
+ this.bodyStream = body;
+ this.bodyFlux = null;
+ }
+
+ public boolean isConsumedOrClosed() {
+ return closed || (bodyStream != null ? bodyStream.available() == 0 : consumed);
+ }
+
+ @Override
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ @Override
+ @Deprecated
+ public String getHeaderValue(String name) {
+ return headers.getValue(name);
+ }
+
+ @Override
+ public String getHeaderValue(HttpHeaderName headerName) {
+ return headers.getValue(headerName);
+ }
+
+ @Override
+ public HttpHeaders getHeaders() {
+ return this.headers;
+ }
+
+ @Override
+ public Mono getBodyAsByteArray() {
+ if (bodyStream != null) {
+ return Mono.just(BinaryData.fromStream(bodyStream).toBytes());
+ } else {
+ return FluxUtil.collectBytesInByteBufferStream(bodyFlux);
+ }
+ }
+
+ @Override
+ public Flux getBody() {
+ if (bodyStream != null) {
+ return FluxUtil.toFluxByteBuffer(bodyStream);
+ } else {
+ return bodyFlux;
+ }
+ }
+
+ @Override
+ public Mono getBodyAsString() {
+ return getBodyAsString(StandardCharsets.UTF_8);
+ }
+
+ @Override
+ public Mono getBodyAsString(Charset charset) {
+ return getBodyAsByteArray().map(bytes -> new String(bytes, charset));
+ }
+
+ @Override
+ public BinaryData getBodyAsBinaryData() {
+ if (bodyStream != null) {
+ return BinaryData.fromStream(bodyStream);
+ } else {
+ return BinaryData.fromFlux(bodyFlux).block();
+ }
+ }
+
+ @Override
+ public Mono getBodyAsInputStream() {
+ if (bodyStream != null) {
+ return Mono.just(bodyStream);
+ } else {
+ return getBodyAsByteArray().map(ByteArrayInputStream::new);
+ }
+ }
+
+ @Override
+ public HttpResponse buffer() {
+ return new MockHttpResponse(getRequest(), getStatusCode(), getHeaders(), getBodyAsBinaryData().toBytes());
+ }
+
+ @Override
+ public Mono writeBodyToAsync(AsynchronousByteChannel channel) {
+ return FluxUtil.writeToAsynchronousByteChannel(getBody(), channel);
+ }
+
+ @Override
+ public void writeBodyTo(WritableByteChannel channel) throws IOException {
+ FluxUtil.writeToWritableByteChannel(getBody(), channel).block();
+ }
+
+ @Override
+ public void close() {
+ this.closed = true;
+ if (bodyStream != null) {
+ try {
+ bodyStream.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+}
diff --git a/sdk/cosmos/azure-cosmos-kafka-connect/pom.xml b/sdk/cosmos/azure-cosmos-kafka-connect/pom.xml
index ae5e2dfef8f8..627124a3d33d 100644
--- a/sdk/cosmos/azure-cosmos-kafka-connect/pom.xml
+++ b/sdk/cosmos/azure-cosmos-kafka-connect/pom.xml
@@ -101,7 +101,7 @@ Licensed under the MIT License.
com.azure
azure-cosmos-test
- 1.0.0-beta.7
+ 1.0.0-beta.8
test
diff --git a/sdk/cosmos/azure-cosmos-test/CHANGELOG.md b/sdk/cosmos/azure-cosmos-test/CHANGELOG.md
index bb5bbe06a853..42e76a6c34c0 100644
--- a/sdk/cosmos/azure-cosmos-test/CHANGELOG.md
+++ b/sdk/cosmos/azure-cosmos-test/CHANGELOG.md
@@ -1,5 +1,14 @@
## Release History
+### 1.0.0-beta.8 (Unreleased)
+
+#### Features Added
+
+#### Breaking Changes
+
+#### Bugs Fixed
+* Fixed an issue where `FaultInjectionRule` can not apply on partition level when using `Gateway` Mode and non-session consistency - See [40005](https://github.com/Azure/azure-sdk-for-java/pull/40005)
+
### 1.0.0-beta.7 (2024-05-03)
#### Bugs Fixed
diff --git a/sdk/cosmos/azure-cosmos-test/pom.xml b/sdk/cosmos/azure-cosmos-test/pom.xml
index cb2d32eb7ac6..7e5429c2cf40 100644
--- a/sdk/cosmos/azure-cosmos-test/pom.xml
+++ b/sdk/cosmos/azure-cosmos-test/pom.xml
@@ -13,7 +13,7 @@ Licensed under the MIT License.
com.azure
azure-cosmos-test
- 1.0.0-beta.7
+ 1.0.0-beta.8
Microsoft Azure Java Cosmos Test Library
This package contains core fault injection types for Azure Java Cosmos client.
jar
diff --git a/sdk/cosmos/azure-cosmos-tests/pom.xml b/sdk/cosmos/azure-cosmos-tests/pom.xml
index b55fefbf13ea..cecbe9dc1fd9 100644
--- a/sdk/cosmos/azure-cosmos-tests/pom.xml
+++ b/sdk/cosmos/azure-cosmos-tests/pom.xml
@@ -104,7 +104,7 @@ Licensed under the MIT License.
com.azure
azure-cosmos-test
- 1.0.0-beta.7
+ 1.0.0-beta.8
commons-io
diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md
index 28c11dc76f12..686ee7b6b8e2 100644
--- a/sdk/cosmos/azure-cosmos/CHANGELOG.md
+++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md
@@ -4,6 +4,8 @@
#### Features Added
+* Added support for non-streaming OrderBy query and a query feature `NonStreamingOrderBy` to support Vector Search queries. - See [PR 39897](https://github.com/Azure/azure-sdk-for-java/pull/39897/)
+
#### Breaking Changes
#### Bugs Fixed
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java
index da368de5360d..c643379b2fe6 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Configs.java
@@ -166,6 +166,13 @@ public class Configs {
public static final String MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED = "COSMOS.MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED";
private static final int DEFAULT_MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED = 1;
+ private static final String MAX_ITEM_SIZE_FOR_VECTOR_SEARCH = "COSMOS.MAX_ITEM_SIZE_FOR_VECTOR_SEARCH";
+ private static final int DEFAULT_MAX_ITEM_SIZE_FOR_VECTOR_SEARCH = 50000;
+
+ private static final String MAX_ITEM_SIZE_FOR_VECTOR_SEARCH_ENABLED = "COSMOS.MAX_ITEM_SIZE_FOR_VECTOR_SEARCH_ENABLED";
+
+ private static final boolean DEFAULT_MAX_ITEM_SIZE_FOR_VECTOR_SEARCH_ENABLED = true;
+
public static final int MIN_MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED = 1;
public static final String TCP_CONNECTION_ACQUISITION_TIMEOUT_IN_MS = "COSMOS.TCP_CONNECTION_ACQUISITION_TIMEOUT_IN_MS";
@@ -484,6 +491,14 @@ public static int getMaxRetriesInLocalRegionWhenRemoteRegionPreferred() {
MIN_MAX_RETRIES_IN_LOCAL_REGION_WHEN_REMOTE_REGION_PREFERRED);
}
+ public static int getMaxItemSizeForVectorSearch() {
+ return getJVMConfigAsInt(MAX_ITEM_SIZE_FOR_VECTOR_SEARCH, DEFAULT_MAX_ITEM_SIZE_FOR_VECTOR_SEARCH);
+ }
+
+ public static boolean getMaxItemSizeForVectorSearchEnabled() {
+ return getJVMConfigAsBoolean(MAX_ITEM_SIZE_FOR_VECTOR_SEARCH_ENABLED, DEFAULT_MAX_ITEM_SIZE_FOR_VECTOR_SEARCH_ENABLED);
+ }
+
public static Duration getMinRetryTimeInLocalRegionWhenRemoteRegionPreferred() {
return
Duration.ofMillis(Math.max(
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/CosmosQueryRequestOptionsImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/CosmosQueryRequestOptionsImpl.java
index 4dc62089acc5..c70ded3a906f 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/CosmosQueryRequestOptionsImpl.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/CosmosQueryRequestOptionsImpl.java
@@ -25,6 +25,7 @@ public final class CosmosQueryRequestOptionsImpl extends CosmosQueryRequestOptio
private boolean queryPlanRetrievalDisallowed;
private boolean emptyPageDiagnosticsEnabled;
private String queryName;
+ private Integer maxItemSizeForVectorSearch;
private List cancelledRequestDiagnosticsTracker = new ArrayList<>();
/**
@@ -62,6 +63,7 @@ public CosmosQueryRequestOptionsImpl(CosmosQueryRequestOptionsImpl options) {
this.queryName = options.queryName;
this.feedRange = options.feedRange;
this.cancelledRequestDiagnosticsTracker = options.cancelledRequestDiagnosticsTracker;
+ this.maxItemSizeForVectorSearch = options.maxItemSizeForVectorSearch;
}
/**
@@ -196,6 +198,26 @@ public CosmosQueryRequestOptionsImpl setMaxItemCount(Integer maxItemCount) {
return this;
}
+ /**
+ * Gets the maximum item size to fetch during non-streaming order by queries.
+ *
+ * @return the max number of items for vector search.
+ */
+ public Integer getMaxItemSizeForVectorSearch() {
+ return maxItemSizeForVectorSearch;
+ }
+
+ /**
+ * Sets the maximum item size to fetch during non-streaming order by queries.
+ *
+ * @param maxItemSizeForVectorSearch the max number of items for vector search.
+ * return the CosmosQueryRequestOptions.
+ */
+ public CosmosQueryRequestOptionsImpl setMaxItemSizeForVectorSearch(Integer maxItemSizeForVectorSearch) {
+ this.maxItemSizeForVectorSearch = maxItemSizeForVectorSearch;
+ return this;
+ }
+
/**
* Gets the request continuation token.
*
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextFactory.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextFactory.java
index a13cfc65348d..7a530816856b 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextFactory.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentQueryExecutionContextFactory.java
@@ -4,9 +4,11 @@
import com.azure.cosmos.BridgeInternal;
import com.azure.cosmos.implementation.BadRequestException;
+import com.azure.cosmos.implementation.Configs;
import com.azure.cosmos.implementation.Constants;
import com.azure.cosmos.implementation.DiagnosticsClientContext;
import com.azure.cosmos.implementation.DocumentCollection;
+import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
import com.azure.cosmos.implementation.OperationType;
import com.azure.cosmos.implementation.PartitionKeyRange;
@@ -239,7 +241,8 @@ private static boolean canCacheQuery(QueryInfo queryInfo) {
&& !queryInfo.hasTop()
&& !queryInfo.hasOffset()
&& !queryInfo.hasDCount()
- && !queryInfo.hasOrderBy();
+ && !queryInfo.hasOrderBy()
+ && !queryInfo.hasNonStreamingOrderBy();
}
private static boolean isScopedToSinglePartition(CosmosQueryRequestOptions cosmosQueryRequestOptions) {
@@ -358,6 +361,37 @@ public static Flux extends IDocumentQueryExecutionContext> createSpecia
boolean getLazyFeedResponse = queryInfo.hasTop();
+ // We need to compute the optimal initial age size for non-streaming order-by queries
+ if (queryInfo.hasNonStreamingOrderBy() && Configs.getMaxItemSizeForVectorSearchEnabled()) {
+ // Validate the TOP or LIMIT for non-streaming order-by queries
+ if (!queryInfo.hasTop() && !queryInfo.hasLimit() && queryInfo.getTop() < 0 && queryInfo.getLimit() < 0) {
+ throw new NonStreamingOrderByBadRequestException(HttpConstants.StatusCodes.BADREQUEST,
+ "Executing a vector search query without TOP or LIMIT can consume a large number of RUs" +
+ "very fast and have long runtimes. Please ensure you are using one of the above two filters" +
+ "with you vector search query.");
+ }
+ // Validate the size of TOP or LIMIT against MaxItemSizeForVectorSearch
+ int maxLimit = Math.max(queryInfo.hasTop() ? queryInfo.getTop() : 0,
+ queryInfo.hasLimit() ? queryInfo.getLimit() : 0);
+ int maxItemSizeForVectorSearch = Math.max(Configs.getMaxItemSizeForVectorSearch(),
+ ModelBridgeInternal.getMaxItemSizeForVectorSearchFromQueryRequestOptions(cosmosQueryRequestOptions));
+ if (maxLimit > maxItemSizeForVectorSearch) {
+ throw new NonStreamingOrderByBadRequestException(HttpConstants.StatusCodes.BADREQUEST,
+ "Executing a vector search query with TOP or LIMIT larger than the maxItemSizeForVectorSearch " +
+ "is not allowed");
+ }
+ // Set initialPageSize based on the smallest of TOP or LIMIT
+ if (queryInfo.hasTop() || queryInfo.hasLimit()) {
+ int pageSizeWithTopOrLimit = Math.min(queryInfo.hasTop() ? queryInfo.getTop() : Integer.MAX_VALUE,
+ queryInfo.hasLimit() ? queryInfo.getLimit() : Integer.MAX_VALUE);
+ if (initialPageSize > 0) {
+ initialPageSize = Math.min(pageSizeWithTopOrLimit, initialPageSize);
+ } else {
+ initialPageSize = pageSizeWithTopOrLimit;
+ }
+ }
+ }
+
// We need to compute the optimal initial page size for order-by queries
if (queryInfo.hasOrderBy()) {
int top;
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByBadRequestException.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByBadRequestException.java
new file mode 100644
index 000000000000..4b3b41fbc675
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByBadRequestException.java
@@ -0,0 +1,20 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.cosmos.implementation.query;
+
+import com.azure.cosmos.CosmosException;
+
+public class NonStreamingOrderByBadRequestException extends CosmosException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Creates a new instance of the NonStreamingOrderByBadRequestException class.
+ *
+ * @param statusCode the http status code of the response.
+ * @param errorMessage the error message.
+ */
+ public NonStreamingOrderByBadRequestException(int statusCode, String errorMessage) {
+ super(statusCode, errorMessage);
+ }
+}
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentProducer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentProducer.java
new file mode 100644
index 000000000000..c64ef5d1fbda
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentProducer.java
@@ -0,0 +1,43 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.cosmos.implementation.query;
+
+import com.azure.cosmos.implementation.Document;
+import com.azure.cosmos.implementation.DocumentClientRetryPolicy;
+import com.azure.cosmos.implementation.RxDocumentServiceRequest;
+import com.azure.cosmos.implementation.feedranges.FeedRangeEpkImpl;
+import com.azure.cosmos.implementation.query.orderbyquery.OrderbyRowComparer;
+import com.azure.cosmos.models.CosmosQueryRequestOptions;
+import com.azure.cosmos.models.FeedResponse;
+import reactor.core.publisher.Mono;
+
+import java.util.UUID;
+import java.util.function.Function;
+import java.util.function.Supplier;
+
+public class NonStreamingOrderByDocumentProducer extends DocumentProducer {
+ private final OrderbyRowComparer consumeComparer;
+
+ NonStreamingOrderByDocumentProducer(
+ OrderbyRowComparer consumeComparer,
+ IDocumentQueryClient client,
+ String collectionResourceId,
+ CosmosQueryRequestOptions cosmosQueryRequestOptions,
+ TriFunction createRequestFunc,
+ Function>> executeRequestFunc,
+ FeedRangeEpkImpl feedRange,
+ String collectionLink,
+ Supplier createRetryPolicyFunc,
+ Class resourceType,
+ UUID correlatedActivityId,
+ int initialPageSize,
+ String initialContinuationToken,
+ int top,
+ Supplier operationContextTextProvider) {
+ super(client, collectionResourceId, cosmosQueryRequestOptions, createRequestFunc, executeRequestFunc,
+ collectionLink, createRetryPolicyFunc, resourceType, correlatedActivityId, initialPageSize,
+ initialContinuationToken, top, feedRange, operationContextTextProvider);
+ this.consumeComparer = consumeComparer;
+ }
+}
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentQueryExecutionContext.java
new file mode 100644
index 000000000000..89a8a3065443
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByDocumentQueryExecutionContext.java
@@ -0,0 +1,264 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.cosmos.implementation.query;
+
+import com.azure.cosmos.BridgeInternal;
+import com.azure.cosmos.CosmosException;
+import com.azure.cosmos.implementation.ClientSideRequestStatistics;
+import com.azure.cosmos.implementation.DiagnosticsClientContext;
+import com.azure.cosmos.implementation.Document;
+import com.azure.cosmos.implementation.DocumentClientRetryPolicy;
+import com.azure.cosmos.implementation.DocumentCollection;
+import com.azure.cosmos.implementation.HttpConstants;
+import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
+import com.azure.cosmos.implementation.QueryMetrics;
+import com.azure.cosmos.implementation.RequestChargeTracker;
+import com.azure.cosmos.implementation.ResourceType;
+import com.azure.cosmos.implementation.RxDocumentServiceRequest;
+import com.azure.cosmos.implementation.Utils;
+import com.azure.cosmos.implementation.feedranges.FeedRangeEpkImpl;
+import com.azure.cosmos.implementation.query.orderbyquery.OrderByRowResult;
+import com.azure.cosmos.implementation.query.orderbyquery.OrderbyRowComparer;
+import com.azure.cosmos.models.CosmosQueryRequestOptions;
+import com.azure.cosmos.models.FeedResponse;
+import com.azure.cosmos.models.ModelBridgeInternal;
+import com.azure.cosmos.models.SqlQuerySpec;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Mono;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.function.Function;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+public class NonStreamingOrderByDocumentQueryExecutionContext
+ extends ParallelDocumentQueryExecutionContextBase {
+
+ private final static
+ ImplementationBridgeHelpers.CosmosDiagnosticsHelper.CosmosDiagnosticsAccessor diagnosticsAccessor =
+ ImplementationBridgeHelpers.CosmosDiagnosticsHelper.getCosmosDiagnosticsAccessor();
+
+ private static final ImplementationBridgeHelpers.FeedResponseHelper.FeedResponseAccessor feedResponseAccessor =
+ ImplementationBridgeHelpers.FeedResponseHelper.getFeedResponseAccessor();
+
+ private final static String FormatPlaceHolder = "{documentdb-formattableorderbyquery-filter}";
+ private final static String True = "true";
+
+ private final OrderbyRowComparer consumeComparer;
+ private final RequestChargeTracker tracker;
+ private final ConcurrentMap queryMetricMap;
+ private final Collection clientSideRequestStatistics;
+ private Flux> orderByObservable;
+
+ private int maxPageSizePerPartition;
+
+ public NonStreamingOrderByDocumentQueryExecutionContext(
+ DiagnosticsClientContext diagnosticsClientContext,
+ IDocumentQueryClient client,
+ ResourceType resourceTypeEnum,
+ SqlQuerySpec query,
+ CosmosQueryRequestOptions cosmosQueryRequestOptions,
+ String resourceLink,
+ String rewrittenQuery,
+ OrderbyRowComparer consumeComparer,
+ UUID correlatedActivityId,
+ boolean hasSelectValue,
+ final AtomicBoolean isQueryCancelledOnTimeout) {
+ super(diagnosticsClientContext, client, resourceTypeEnum, Document.class, query, cosmosQueryRequestOptions,
+ resourceLink, rewrittenQuery, correlatedActivityId, hasSelectValue, isQueryCancelledOnTimeout);
+ this.consumeComparer = consumeComparer;
+ this.tracker = new RequestChargeTracker();
+ this.queryMetricMap = new ConcurrentHashMap<>();
+ this.clientSideRequestStatistics = ConcurrentHashMap.newKeySet();
+ }
+
+ public static Flux> createAsync(
+ DiagnosticsClientContext diagnosticsClientContext,
+ IDocumentQueryClient client,
+ PipelinedDocumentQueryParams initParams,
+ DocumentCollection collection) {
+
+ QueryInfo queryInfo = initParams.getQueryInfo();
+
+ NonStreamingOrderByDocumentQueryExecutionContext context = new NonStreamingOrderByDocumentQueryExecutionContext(
+ diagnosticsClientContext,
+ client,
+ initParams.getResourceTypeEnum(),
+ initParams.getQuery(),
+ initParams.getCosmosQueryRequestOptions(),
+ initParams.getResourceLink(),
+ initParams.getQueryInfo().getRewrittenQuery(),
+ new OrderbyRowComparer<>(queryInfo.getOrderBy()),
+ initParams.getCorrelatedActivityId(),
+ queryInfo.hasSelectValue(),
+ initParams.isQueryCancelledOnTimeout());
+
+ context.setTop(initParams.getTop());
+
+ try {
+ context.initialize(
+ initParams.getFeedRanges(),
+ initParams.getQueryInfo().getOrderBy(),
+ initParams.getQueryInfo().getOrderByExpressions(),
+ initParams.getInitialPageSize(),
+ collection);
+
+ return Flux.just(context);
+ } catch (CosmosException dce) {
+ return Flux.error(dce);
+ }
+ }
+
+ private void initialize(
+ List feedRanges, List sortOrders,
+ Collection orderByExpressions,
+ int initialPageSize,
+ DocumentCollection collection) throws CosmosException {
+ // Since the continuation token will always be null,
+ // we don't need to handle any initialization based on continuationToken.
+ // We can directly initialize without any consideration for continuationToken.
+ super.initialize(collection,
+ feedRanges.stream().collect(Collectors.toMap(
+ feedRangeEpk -> feedRangeEpk,
+ feedRangeEpk -> null)),
+ initialPageSize,
+ new SqlQuerySpec(querySpec.getQueryText().replace(FormatPlaceHolder, True),
+ querySpec.getParameters()));
+
+ orderByObservable = NonStreamingOrderByUtils.nonStreamingOrderedMerge(
+ consumeComparer,
+ tracker,
+ documentProducers,
+ initialPageSize,
+ queryMetricMap,
+ clientSideRequestStatistics);
+ }
+
+ @Override
+ protected NonStreamingOrderByDocumentProducer createDocumentProducer(
+ String collectionRid,
+ String continuationToken,
+ int initialPageSize,
+ CosmosQueryRequestOptions cosmosQueryRequestOptions,
+ SqlQuerySpec querySpecForInit,
+ Map commonRequestHeaders,
+ TriFunction createRequestFunc,
+ Function>> executeFunc,
+ Supplier createRetryPolicyFunc,
+ FeedRangeEpkImpl feedRange) {
+ return new NonStreamingOrderByDocumentProducer(
+ consumeComparer,
+ client,
+ collectionRid,
+ cosmosQueryRequestOptions,
+ createRequestFunc,
+ executeFunc,
+ feedRange,
+ collectionRid,
+ createRetryPolicyFunc,
+ Document.class,
+ correlatedActivityId,
+ maxPageSizePerPartition,
+ continuationToken,
+ top,
+ this.getOperationContextTextProvider());
+ }
+
+ @Override
+ public Flux> drainAsync(int maxPageSize) {
+ return this.orderByObservable.transformDeferred(new ItemToPageTransformer(tracker,
+ maxPageSize,
+ this.queryMetricMap,
+ this.clientSideRequestStatistics));
+ }
+
+ @Override
+ public Flux> executeAsync() {
+ return drainAsync(ModelBridgeInternal.getMaxItemCountFromQueryRequestOptions(cosmosQueryRequestOptions));
+ }
+
+ private static class ItemToPageTransformer implements
+ Function>, Flux>> {
+ private final static int DEFAULT_PAGE_SIZE = 100;
+ private final RequestChargeTracker tracker;
+ private final int maxPageSize;
+ private final ConcurrentMap queryMetricMap;
+ private final Collection clientSideRequestStatistics;
+
+ public ItemToPageTransformer(RequestChargeTracker tracker,
+ int maxPageSize,
+ ConcurrentMap queryMetricsMap,
+ Collection clientSideRequestStatistics) {
+ this.tracker = tracker;
+ this.maxPageSize = maxPageSize > 0 ? maxPageSize : DEFAULT_PAGE_SIZE;
+ this.queryMetricMap = queryMetricsMap;
+ this.clientSideRequestStatistics = clientSideRequestStatistics;
+ }
+
+ private static Map headerResponse(double requestCharge) {
+ return Utils.immutableMapOf(HttpConstants.HttpHeaders.REQUEST_CHARGE, String.valueOf(requestCharge));
+ }
+
+ @Override
+ public Flux> apply(Flux> source) {
+ return source
+ .window(maxPageSize).map(Flux::collectList)
+ .flatMap(resultListObs -> resultListObs, 1)
+ .map(orderByRowResults -> {
+ // construct a page from result with request charge
+ FeedResponse> feedResponse = feedResponseAccessor.createFeedResponse(
+ orderByRowResults,
+ headerResponse(tracker.getAndResetCharge()),
+ null);
+ if (!queryMetricMap.isEmpty()) {
+ for (Map.Entry entry : queryMetricMap.entrySet()) {
+ BridgeInternal.putQueryMetricsIntoMap(feedResponse,
+ entry.getKey(),
+ entry.getValue());
+ }
+ }
+ return feedResponse;
+ })
+ .concatWith(Flux.defer(() -> {
+ return Flux.just(feedResponseAccessor.createFeedResponse(Utils.immutableListOf(),
+ null, null));
+ }))
+ .map(feedOfOrderByRowResults -> {
+ List unwrappedResults = new ArrayList<>();
+ for (OrderByRowResult orderByRowResult : feedOfOrderByRowResults.getResults()) {
+ unwrappedResults.add(orderByRowResult.getPayload());
+ }
+ FeedResponse feedResponse = BridgeInternal.createFeedResponseWithQueryMetrics(unwrappedResults,
+ feedOfOrderByRowResults.getResponseHeaders(),
+ BridgeInternal.queryMetricsFromFeedResponse(feedOfOrderByRowResults),
+ ModelBridgeInternal.getQueryPlanDiagnosticsContext(feedOfOrderByRowResults),
+ false,
+ false, feedOfOrderByRowResults.getCosmosDiagnostics());
+ diagnosticsAccessor.addClientSideDiagnosticsToFeed(
+ feedResponse.getCosmosDiagnostics(), clientSideRequestStatistics);
+ return feedResponse;
+ }).switchIfEmpty(Flux.defer(() -> {
+ // create an empty page if there is no result
+ FeedResponse frp = BridgeInternal.createFeedResponseWithQueryMetrics(Utils.immutableListOf(),
+ headerResponse(
+ tracker.getAndResetCharge()),
+ queryMetricMap,
+ null,
+ false,
+ false,
+ null);
+ diagnosticsAccessor.addClientSideDiagnosticsToFeed(
+ frp.getCosmosDiagnostics(), clientSideRequestStatistics);
+ return Flux.just(frp);
+ }));
+ }
+ }
+}
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByUtils.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByUtils.java
new file mode 100644
index 000000000000..1b4191e26413
--- /dev/null
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/NonStreamingOrderByUtils.java
@@ -0,0 +1,111 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+package com.azure.cosmos.implementation.query;
+
+import com.azure.cosmos.BridgeInternal;
+import com.azure.cosmos.implementation.ClientSideRequestStatistics;
+import com.azure.cosmos.implementation.Configs;
+import com.azure.cosmos.implementation.Document;
+import com.azure.cosmos.implementation.ImplementationBridgeHelpers;
+import com.azure.cosmos.implementation.QueryMetrics;
+import com.azure.cosmos.implementation.RequestChargeTracker;
+import com.azure.cosmos.implementation.Resource;
+import com.azure.cosmos.implementation.query.orderbyquery.OrderByRowResult;
+import com.azure.cosmos.implementation.query.orderbyquery.OrderbyRowComparer;
+import reactor.core.publisher.Flux;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.function.Function;
+
+public class NonStreamingOrderByUtils {
+ private final static
+ ImplementationBridgeHelpers.CosmosDiagnosticsHelper.CosmosDiagnosticsAccessor diagnosticsAccessor =
+ ImplementationBridgeHelpers.CosmosDiagnosticsHelper.getCosmosDiagnosticsAccessor();
+
+ public static Flux> nonStreamingOrderedMerge(OrderbyRowComparer consumeComparer,
+ RequestChargeTracker tracker,
+ List> documentProducers,
+ int initialPageSize,
+ Map queryMetricsMap,
+ Collection clientSideRequestStatistics) {
+ @SuppressWarnings("unchecked")
+ Flux>[] fluxes = documentProducers
+ .subList(0, documentProducers.size())
+ .stream()
+ .map(producer ->
+ toNonStreamingOrderByQueryResultObservable(producer, tracker, queryMetricsMap, initialPageSize,
+ consumeComparer, clientSideRequestStatistics))
+ .toArray(Flux[]::new);
+ return Flux.mergeComparingDelayError(1,consumeComparer, fluxes);
+ }
+
+ private static Flux> toNonStreamingOrderByQueryResultObservable(DocumentProducer producer,
+ RequestChargeTracker tracker,
+ Map queryMetricsMap,
+ int initialPageSize,
+ OrderbyRowComparer consumeComparer,
+ Collection clientSideRequestStatisticsList) {
+ return producer
+ .produceAsync()
+ .transformDeferred(new NonStreamingOrderByUtils.PageToItemTransformer(tracker, queryMetricsMap, initialPageSize,
+ consumeComparer, clientSideRequestStatisticsList));
+ }
+
+ private static class PageToItemTransformer implements
+ Function.DocumentProducerFeedResponse>, Flux>> {
+ private final RequestChargeTracker tracker;
+ private final Map queryMetricsMap;
+ private final Integer initialPageSize;
+ private final OrderbyRowComparer consumeComparer;
+ private final Collection clientSideRequestStatistics;
+
+ private PageToItemTransformer(RequestChargeTracker tracker, Map queryMetricsMap,
+ Integer initialPageSize, OrderbyRowComparer consumeComparer,
+ Collection clientSideRequestStatistics) {
+ this.tracker = tracker;
+ this.queryMetricsMap = queryMetricsMap;
+ this.initialPageSize = initialPageSize;
+ this.consumeComparer = consumeComparer;
+ this.clientSideRequestStatistics = clientSideRequestStatistics;
+ }
+
+ @Override
+ public Flux> apply(Flux.DocumentProducerFeedResponse> source) {
+ PriorityBlockingQueue> priorityQueue = new PriorityBlockingQueue<>(initialPageSize, consumeComparer);
+
+ return source.flatMap(documentProducerFeedResponse -> {
+ clientSideRequestStatistics.addAll(
+ diagnosticsAccessor.getClientSideRequestStatisticsForQueryPipelineAggregations(documentProducerFeedResponse
+ .pageResult.getCosmosDiagnostics()));
+
+ QueryMetrics.mergeQueryMetricsMap(queryMetricsMap,
+ BridgeInternal.queryMetricsFromFeedResponse(documentProducerFeedResponse.pageResult));
+ List results = documentProducerFeedResponse.pageResult.getResults();
+ results.forEach(r -> {
+ OrderByRowResult orderByRowResult = new OrderByRowResult(
+ r.toJson(),
+ documentProducerFeedResponse.sourceFeedRange,
+ null);
+ if (Configs.getMaxItemSizeForVectorSearchEnabled()) {
+ if (priorityQueue.size() < initialPageSize) {
+ priorityQueue.add(orderByRowResult);
+ } else {
+ priorityQueue.add(orderByRowResult);
+ priorityQueue.poll();
+ }
+ } else {
+ priorityQueue.add(orderByRowResult);
+ }
+
+ });
+ tracker.addCharge(documentProducerFeedResponse.pageResult.getRequestCharge());
+ // Returning an empty Flux since we are only processing and managing state here
+ return Flux.empty();
+ }, 1)
+ .thenMany(Flux.defer(() -> Flux.fromIterable(priorityQueue)));
+ }
+ }
+}
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/ParallelDocumentQueryExecutionContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/ParallelDocumentQueryExecutionContext.java
index 020b8633d2be..6ed30d3a7fbe 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/ParallelDocumentQueryExecutionContext.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/ParallelDocumentQueryExecutionContext.java
@@ -106,7 +106,8 @@ public static