From 93c25d89399d7790d6e5d92ffbdfc123675c6308 Mon Sep 17 00:00:00 2001 From: Alan Zimmer <48699787+alzimmermsft@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:45:00 -0400 Subject: [PATCH] Enable Spotless for azure-data-appconfiguration and azure-data-appconfiguration-perf (#41950) --- .../azure-data-appconfiguration-perf/pom.xml | 1 + .../azure/data/appconfiguration/perf/App.java | 2 +- .../perf/ListConfigurationSettingsTest.java | 8 +- .../perf/core/ServiceTest.java | 6 +- .../azure-data-appconfiguration/pom.xml | 1 + .../ConfigurationAsyncClient.java | 132 +-- .../appconfiguration/ConfigurationClient.java | 109 ++- .../ConfigurationClientBuilder.java | 44 +- .../ConfigurationClientCredentials.java | 18 +- .../ConfigurationCredentialsPolicy.java | 1 - ...igurationSettingDeserializationHelper.java | 33 +- .../ConfigurationSettingHelper.java | 4 +- ...nfigurationSettingSerializationHelper.java | 4 +- .../CreateSnapshotUtilClient.java | 73 +- .../implementation/SyncToken.java | 13 +- .../implementation/SyncTokenPolicy.java | 9 +- .../implementation/Utility.java | 37 +- .../models/ConfigurationSetting.java | 11 +- .../FeatureFlagConfigurationSetting.java | 17 +- .../SecretReferenceConfigurationSetting.java | 9 +- .../models/SettingSelector.java | 4 +- .../models/SnapshotSelector.java | 23 +- .../ConfigurationAsyncClientTest.java | 857 +++++++++--------- .../ConfigurationClientBuilderTest.java | 72 +- .../ConfigurationClientTest.java | 659 ++++++++------ .../ConfigurationClientTestBase.java | 156 ++-- .../FeatureFlagSettingUnitTest.java | 47 +- ...ReferenceConfigurationSettingUnitTest.java | 7 +- .../appconfiguration/SettingSelectorTest.java | 10 +- .../data/appconfiguration/TestHelper.java | 8 +- .../ConfigurationCredentialPolicyTest.java | 8 +- .../ConfigurationSettingDeserializerTest.java | 41 +- .../ConfigurationSettingSerializerTest.java | 18 +- .../implementation/SyncTokenPolicyTest.java | 26 +- 34 files changed, 1275 insertions(+), 1193 deletions(-) diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml index e80d7fb995415..4aec69571d129 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml +++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/pom.xml @@ -21,6 +21,7 @@ com.azure.data.appconfiguration.perf.App azure-data-appconfiguration-perf + false diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java index b09d0b2b88def..8f30182c4799f 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java +++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/App.java @@ -25,6 +25,6 @@ public class App { * @param args Arguments to the performance tests. */ public static void main(String[] args) { - PerfStressProgram.run(new Class[]{ListConfigurationSettingsTest.class}, args); + PerfStressProgram.run(new Class[] { ListConfigurationSettingsTest.class }, args); } } diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java index 03ae9c519dbf0..033452ccf802d 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/ListConfigurationSettingsTest.java @@ -37,8 +37,8 @@ public ListConfigurationSettingsTest(PerfStressOptions options) { public Mono globalSetupAsync() { List> settingMonoList = new ArrayList<>(); for (int i = 0; i < settingCount; i++) { - settingMonoList.add(configurationAsyncClient.setConfigurationSetting( - new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE))); + settingMonoList.add(configurationAsyncClient + .setConfigurationSetting(new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE))); } return Flux.concat(settingMonoList).then(); @@ -48,8 +48,8 @@ public Mono globalSetupAsync() { public Mono globalCleanupAsync() { List> settingMonoList = new ArrayList<>(); for (int i = 0; i < settingCount; i++) { - settingMonoList.add(configurationAsyncClient.deleteConfigurationSetting( - new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE))); + settingMonoList.add(configurationAsyncClient + .deleteConfigurationSetting(new ConfigurationSetting().setKey(KEY_PREFIX + i).setValue(SETTING_VALUE))); } return Flux.concat(settingMonoList).then(); diff --git a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java index c7416a0b1115e..3969cbd57fb43 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration-perf/src/main/java/com/azure/data/appconfiguration/perf/core/ServiceTest.java @@ -15,8 +15,8 @@ * Base class for Azure App Configuration performance tests. */ public abstract class ServiceTest extends PerfStressTest { - private static final String CONFIGURATION_ERROR = "Configuration %s must be set in either environment variables " - + "or system properties.%n"; + private static final String CONFIGURATION_ERROR + = "Configuration %s must be set in either environment variables " + "or system properties.%n"; protected final ConfigurationClient configurationClient; protected final ConfigurationAsyncClient configurationAsyncClient; @@ -39,6 +39,6 @@ public ServiceTest(TOptions options) { ConfigurationClientBuilder builder = new ConfigurationClientBuilder().connectionString(connectionString); this.configurationClient = builder.buildClient(); - this.configurationAsyncClient = builder.buildAsyncClient(); + this.configurationAsyncClient = builder.buildAsyncClient(); } } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml index cccfef3e1c6a0..48ed21c0a8e40 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml +++ b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml @@ -45,6 +45,7 @@ false --initialize-at-build-time=com.azure.data.appconfiguration.TestHelper + false diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java index 9ddca332521ec..111ab29765b3a 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationAsyncClient.java @@ -291,7 +291,9 @@ * @see ConfigurationClientBuilder * @see ConfigurationSetting */ -@ServiceClient(builder = ConfigurationClientBuilder.class, isAsync = true, +@ServiceClient( + builder = ConfigurationClientBuilder.class, + isAsync = true, serviceInterfaces = AzureAppConfigurationImpl.AzureAppConfigurationService.class) public final class ConfigurationAsyncClient { private static final ClientLogger LOGGER = new ClientLogger(ConfigurationAsyncClient.class); @@ -427,11 +429,10 @@ public Mono> addConfigurationSettingWithResponse( // This service method call is similar to setConfigurationSetting except we're passing If-Not-Match = "*". // If the service finds any existing configuration settings, then its e-tag will match and the service will // return an error. - return withContext( - context -> validateSettingAsync(setting).flatMap( - settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(), - settingInternal.getLabel(), null, ETAG_ANY, toKeyValue(settingInternal), context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); + return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient + .putKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(), null, ETAG_ANY, + toKeyValue(settingInternal), context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); } /** @@ -570,12 +571,10 @@ public Mono setConfigurationSetting(ConfigurationSetting s @ServiceMethod(returns = ReturnType.SINGLE) public Mono> setConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) { - return withContext( - context -> validateSettingAsync(setting).flatMap( - settingInternal -> serviceClient.putKeyValueWithResponseAsync(settingInternal.getKey(), - settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), null, - toKeyValue(settingInternal), context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); + return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient + .putKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(), + getETag(ifUnchanged, settingInternal), null, toKeyValue(settingInternal), context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); } /** @@ -592,7 +591,7 @@ public Mono> setConfigurationSettingWithResponse( * response.getKey(), response.getLabel(), response.getValue())); * * - + * @param key The key of the setting to retrieve. * @param label The label of the configuration setting to retrieve. If {@code null} no label will be used. * @return The {@link ConfigurationSetting} stored in the service, or an empty Mono if the configuration value does @@ -716,20 +715,21 @@ 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, 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))); + 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))); } /** @@ -848,10 +848,10 @@ public Mono deleteConfigurationSetting(ConfigurationSettin @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged) { - return withContext(context -> validateSettingAsync(setting).flatMap( - settingInternal -> serviceClient.deleteKeyValueWithResponseAsync(settingInternal.getKey(), - settingInternal.getLabel(), getETag(ifUnchanged, settingInternal), context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); + return withContext(context -> validateSettingAsync(setting).flatMap(settingInternal -> serviceClient + .deleteKeyValueWithResponseAsync(settingInternal.getKey(), settingInternal.getLabel(), + getETag(ifUnchanged, settingInternal), context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse))); } /** @@ -1001,7 +1001,7 @@ public Mono> setReadOnlyWithResponse(Configuratio return (isReadOnly ? serviceClient.putLockWithResponseAsync(key, label, null, null, context) : serviceClient.deleteLockWithResponseAsync(key, label, null, null, context)) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse); + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithResponse); })); } @@ -1036,20 +1036,18 @@ public PagedFlux listConfigurationSettings(SettingSelector final List matchConditionsList = selector == null ? null : selector.getMatchConditions(); final List tagsFilter = selector == null ? null : selector.getTagsFilter(); AtomicInteger pageETagIndex = new AtomicInteger(0); - return new PagedFlux<>(() -> withContext(context -> serviceClient.getKeyValuesSinglePageAsync(keyFilter, - labelFilter, null, acceptDateTime, settingFields, null, null, + return new PagedFlux<>(() -> withContext(context -> serviceClient + .getKeyValuesSinglePageAsync(keyFilter, labelFilter, null, acceptDateTime, settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex), tagsFilter, context) .onErrorResume(HttpResponseException.class, - (Function>>) - Utility::handleNotModifiedErrorToValidResponse) + (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)) - ); + nextLink -> withContext(context -> serviceClient + .getKeyValuesNextSinglePageAsync(nextLink, acceptDateTime, null, + getPageETag(matchConditionsList, pageETagIndex), context) + .onErrorResume(HttpResponseException.class, + (Function>>) Utility::handleNotModifiedErrorToValidResponse) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))); } /** @@ -1107,12 +1105,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, null, context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)), - nextLink -> withContext(context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null, - context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))); + return new PagedFlux<>( + () -> withContext(context -> serviceClient + .getKeyValuesSinglePageAsync(null, null, null, null, fields, snapshotName, null, null, null, context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)), + nextLink -> withContext( + context -> serviceClient.getKeyValuesNextSinglePageAsync(nextLink, null, null, null, context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))); } /** @@ -1148,12 +1147,13 @@ public PagedFlux listRevisions(SettingSelector selector) { final String acceptDateTime = selector == null ? null : selector.getAcceptDateTime(); final List settingFields = selector == null ? null : toSettingFieldsList(selector.getFields()); List tags = selector == null ? null : selector.getTagsFilter(); - return new PagedFlux<>(() -> withContext(context -> serviceClient.getRevisionsSinglePageAsync(keyFilter, - labelFilter, null, acceptDateTime, settingFields, tags, context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)), - nextLink -> withContext(context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime, - context) - .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))); + return new PagedFlux<>( + () -> withContext(context -> serviceClient + .getRevisionsSinglePageAsync(keyFilter, labelFilter, null, acceptDateTime, settingFields, tags, context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse)), + nextLink -> withContext( + context -> serviceClient.getRevisionsNextSinglePageAsync(nextLink, acceptDateTime, context) + .map(ConfigurationSettingDeserializationHelper::toConfigurationSettingWithPagedResponse))); } /** @@ -1186,8 +1186,8 @@ public PagedFlux listRevisions(SettingSelector selector) { * has failed. The completed operation returns a {@link ConfigurationSnapshot}. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public PollerFlux beginCreateSnapshot( - String snapshotName, ConfigurationSnapshot snapshot) { + public PollerFlux beginCreateSnapshot(String snapshotName, + ConfigurationSnapshot snapshot) { return createSnapshotUtilClient.beginCreateSnapshot(snapshotName, snapshot); } @@ -1371,8 +1371,8 @@ public Mono recoverSnapshot(String snapshotName) { * @return A {@link Mono} of {@link ConfigurationSnapshot}. */ @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> recoverSnapshotWithResponse( - String snapshotName, MatchConditions matchConditions) { + public Mono> recoverSnapshotWithResponse(String snapshotName, + MatchConditions matchConditions) { return updateSnapshotAsync(snapshotName, matchConditions, ConfigurationSnapshotStatus.READY, serviceClient); } @@ -1398,11 +1398,12 @@ 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(), - context)), nextLink -> withContext(context -> - serviceClient.getSnapshotsNextSinglePageAsync(nextLink, 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)); } @@ -1456,7 +1457,8 @@ public PagedFlux listLabels() { @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listLabels(SettingLabelSelector selector) { final String labelNameFilter = selector == null ? null : selector.getNameFilter(); - final String acceptDatetime = selector == null ? null + final String acceptDatetime = selector == null + ? null : selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString(); final List labelFields = selector == null ? null : selector.getFields(); return serviceClient.getLabelsAsync(labelNameFilter, null, acceptDatetime, labelFields); 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 e7e5f47d61a56..d329eea00d41e 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 @@ -292,7 +292,8 @@ * @see ConfigurationClientBuilder * @see ConfigurationSetting */ -@ServiceClient(builder = ConfigurationClientBuilder.class, +@ServiceClient( + builder = ConfigurationClientBuilder.class, serviceInterfaces = AzureAppConfigurationImpl.AzureAppConfigurationService.class) public final class ConfigurationClient { private static final ClientLogger LOGGER = new ClientLogger(ConfigurationClient.class); @@ -432,9 +433,8 @@ public Response addConfigurationSettingWithResponse(Config // This service method call is similar to setConfigurationSetting except we're passing If-Not-Match = "*". // If the service finds any existing configuration settings, then its e-tag will match and the service will // return an error. - final ResponseBase response = - serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), null, ETAG_ANY, - toKeyValue(setting), context); + final ResponseBase response = serviceClient.putKeyValueWithResponse( + setting.getKey(), setting.getLabel(), null, ETAG_ANY, toKeyValue(setting), context); return toConfigurationSettingWithResponse(response); } @@ -578,9 +578,8 @@ public ConfigurationSetting setConfigurationSetting(ConfigurationSetting setting public Response setConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged, Context context) { validateSetting(setting); - final ResponseBase response = - serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), - null, toKeyValue(setting), context); + final ResponseBase response = serviceClient.putKeyValueWithResponse( + setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), null, toKeyValue(setting), context); return toConfigurationSettingWithResponse(response); } @@ -723,10 +722,9 @@ public Response getConfigurationSettingWithResponse(Config OffsetDateTime acceptDateTime, boolean ifChanged, Context context) { validateSetting(setting); try { - final ResponseBase response = - serviceClient.getKeyValueWithResponse(setting.getKey(), setting.getLabel(), - acceptDateTime == null ? null : acceptDateTime.toString(), null, getETag(ifChanged, setting), null, - context); + final ResponseBase response = serviceClient.getKeyValueWithResponse( + setting.getKey(), setting.getLabel(), acceptDateTime == null ? null : acceptDateTime.toString(), null, + getETag(ifChanged, setting), null, context); return toConfigurationSettingWithResponse(response); } catch (HttpResponseException ex) { final HttpResponse httpResponse = ex.getResponse(); @@ -762,8 +760,8 @@ public Response getConfigurationSettingWithResponse(Config */ @ServiceMethod(returns = ReturnType.SINGLE) public ConfigurationSetting deleteConfigurationSetting(String key, String label) { - return deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey(key).setLabel(label), - false, Context.NONE).getValue(); + return deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey(key).setLabel(label), false, + Context.NONE).getValue(); } /** @@ -850,9 +848,8 @@ public ConfigurationSetting deleteConfigurationSetting(ConfigurationSetting sett public Response deleteConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged, Context context) { validateSetting(setting); - final ResponseBase response = - serviceClient.deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(), - getETag(ifUnchanged, setting), context); + final ResponseBase response = serviceClient + .deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), context); return toConfigurationSettingWithResponse(response); } @@ -1062,29 +1059,25 @@ public PagedIterable listConfigurationSettings(SettingSele final List tagsFilter = selector == null ? null : selector.getTagsFilter(); AtomicInteger pageETagIndex = new AtomicInteger(0); - return new PagedIterable<>( - () -> { - PagedResponse pagedResponse; - try { - pagedResponse = serviceClient.getKeyValuesSinglePage(keyFilter, labelFilter, null, acceptDateTime, - settingFields, null, null, getPageETag(matchConditionsList, pageETagIndex), - tagsFilter, context); - } catch (HttpResponseException ex) { - return handleNotModifiedErrorToValidResponse(ex, LOGGER); - } - return toConfigurationSettingWithPagedResponse(pagedResponse); - }, - nextLink -> { - PagedResponse pagedResponse; - try { - pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null, - getPageETag(matchConditionsList, pageETagIndex), 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), tagsFilter, context); + } catch (HttpResponseException ex) { + return handleNotModifiedErrorToValidResponse(ex, LOGGER); + } + return toConfigurationSettingWithPagedResponse(pagedResponse); + }, nextLink -> { + PagedResponse pagedResponse; + try { + pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null, + getPageETag(matchConditionsList, pageETagIndex), context); + } catch (HttpResponseException ex) { + return handleNotModifiedErrorToValidResponse(ex, LOGGER); + } + return toConfigurationSettingWithPagedResponse(pagedResponse); + }); } /** @@ -1148,8 +1141,8 @@ public PagedIterable listConfigurationSettingsForSnapshot( fields, snapshotName, null, null, null, context); return toConfigurationSettingWithPagedResponse(pagedResponse); }, nextLink -> { - final PagedResponse pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null, - null, context); + final PagedResponse pagedResponse + = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null, null, context); return toConfigurationSettingWithPagedResponse(pagedResponse); }); } @@ -1224,11 +1217,11 @@ public PagedIterable listRevisions(SettingSelector selecto final PagedResponse pagedResponse = serviceClient.getRevisionsSinglePage( selector == null ? null : selector.getKeyFilter(), selector == null ? null : selector.getLabelFilter(), null, acceptDateTime, selector == null ? null : toSettingFieldsList(selector.getFields()), - selector == null ? null : selector.getTagsFilter(), context); + selector == null ? null : selector.getTagsFilter(), context); return toConfigurationSettingWithPagedResponse(pagedResponse); }, nextLink -> { - final PagedResponse pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink, - acceptDateTime, context); + final PagedResponse pagedResponse + = serviceClient.getRevisionsNextSinglePage(nextLink, acceptDateTime, context); return toConfigurationSettingWithPagedResponse(pagedResponse); }); } @@ -1265,8 +1258,8 @@ public PagedIterable listRevisions(SettingSelector selecto * has failed. The completed operation returns a {@link ConfigurationSnapshot}. */ @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION) - public SyncPoller beginCreateSnapshot( - String snapshotName, ConfigurationSnapshot snapshot, Context context) { + public SyncPoller beginCreateSnapshot(String snapshotName, + ConfigurationSnapshot snapshot, Context context) { return createSnapshotUtilClient.beginCreateSnapshot(snapshotName, snapshot, context); } @@ -1324,9 +1317,9 @@ public ConfigurationSnapshot getSnapshot(String snapshotName) { */ @ServiceMethod(returns = ReturnType.SINGLE) public Response getSnapshotWithResponse(String snapshotName, List fields, - Context context) { - final ResponseBase response = - serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context); + Context context) { + final ResponseBase response + = serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context); return new SimpleResponse<>(response, response.getValue()); } @@ -1349,8 +1342,8 @@ public Response getSnapshotWithResponse(String snapshotNa */ @ServiceMethod(returns = ReturnType.SINGLE) public ConfigurationSnapshot archiveSnapshot(String snapshotName) { - return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.ARCHIVED, serviceClient, - Context.NONE).getValue(); + return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.ARCHIVED, serviceClient, Context.NONE) + .getValue(); } /** @@ -1408,8 +1401,8 @@ public Response archiveSnapshotWithResponse(String snapsh */ @ServiceMethod(returns = ReturnType.SINGLE) public ConfigurationSnapshot recoverSnapshot(String snapshotName) { - return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.READY, serviceClient, - Context.NONE).getValue(); + return updateSnapshotSync(snapshotName, null, ConfigurationSnapshotStatus.READY, serviceClient, Context.NONE) + .getValue(); } /** @@ -1496,9 +1489,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(), 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)); } @@ -1580,7 +1574,8 @@ public PagedIterable listLabels(SettingLabelSelector selector) { public PagedIterable listLabels(SettingLabelSelector selector, Context context) { final String labelNameFilter = selector == null ? null : selector.getNameFilter(); final String acceptDatetime = selector == null - ? null : selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString(); + ? null + : selector.getAcceptDateTime() == null ? null : selector.getAcceptDateTime().toString(); final List labelFields = selector == null ? null : selector.getFields(); return serviceClient.getLabels(labelNameFilter, null, acceptDatetime, labelFields, 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 700a764f4accf..864f7402064dd 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 @@ -108,13 +108,10 @@ * @see ConfigurationAsyncClient * @see ConfigurationClient */ -@ServiceClientBuilder(serviceClients = {ConfigurationAsyncClient.class, ConfigurationClient.class}) -public final class ConfigurationClientBuilder implements - TokenCredentialTrait, - ConnectionStringTrait, - HttpTrait, - ConfigurationTrait, - EndpointTrait { +@ServiceClientBuilder(serviceClients = { ConfigurationAsyncClient.class, ConfigurationClient.class }) +public final class ConfigurationClientBuilder implements TokenCredentialTrait, + ConnectionStringTrait, HttpTrait, + ConfigurationTrait, EndpointTrait { private static final String CLIENT_NAME; private static final String CLIENT_VERSION; @@ -125,8 +122,7 @@ public final class ConfigurationClientBuilder implements Map properties = CoreUtils.getProperties("azure-data-appconfiguration.properties"); CLIENT_NAME = properties.getOrDefault("name", "UnknownName"); CLIENT_VERSION = properties.getOrDefault("version", "UnknownVersion"); - ADD_HEADERS_POLICY = new AddHeadersPolicy(new HttpHeaders() - .set("x-ms-return-client-request-id", "true") + ADD_HEADERS_POLICY = new AddHeadersPolicy(new HttpHeaders().set("x-ms-return-client-request-id", "true") .set(HttpHeaderName.CONTENT_TYPE, "application/json") .set(HttpHeaderName.ACCEPT, "application/vnd.microsoft.azconfig.kv+json")); } @@ -221,8 +217,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli + "TokenCredential should be null if using connection string, vice versa.")); } else if (tokenCredential == null) { if (connectionString.isEmpty()) { - throw LOGGER.logExceptionAsError( - new IllegalArgumentException("'connectionString' cannot be an empty string.")); + throw LOGGER + .logExceptionAsError(new IllegalArgumentException("'connectionString' cannot be an empty string.")); } credentialsLocal = new ConfigurationClientCredentials(connectionString); endpointLocal = credentialsLocal.getBaseUri(); @@ -231,9 +227,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli } // Service version - ConfigurationServiceVersion serviceVersion = (version != null) - ? version - : ConfigurationServiceVersion.getLatest(); + ConfigurationServiceVersion serviceVersion + = (version != null) ? version : ConfigurationServiceVersion.getLatest(); // Don't share the default auto-created pipeline between App Configuration client instances. HttpPipeline buildPipeline = (pipeline == null) ? createDefaultHttpPipeline(syncTokenPolicy, credentialsLocal, tokenCredentialLocal) @@ -245,9 +240,8 @@ private AzureAppConfigurationImpl buildInnerClient(SyncTokenPolicy syncTokenPoli private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy, ConfigurationClientCredentials credentials, TokenCredential tokenCredential) { // Global Env configuration store - Configuration buildConfiguration = (configuration == null) - ? Configuration.getGlobalConfiguration() - : configuration; + Configuration buildConfiguration + = (configuration == null) ? Configuration.getGlobalConfiguration() : configuration; // Endpoint String buildEndpoint = endpoint; @@ -260,8 +254,8 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy, ClientOptions localClientOptions = clientOptions != null ? clientOptions : DEFAULT_CLIENT_OPTIONS; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy( - getApplicationId(localClientOptions, httpLogOptions), CLIENT_NAME, CLIENT_VERSION, buildConfiguration)); + policies.add(new UserAgentPolicy(getApplicationId(localClientOptions, httpLogOptions), CLIENT_NAME, + CLIENT_VERSION, buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersFromContextPolicy()); policies.add(ADD_HEADERS_POLICY); @@ -276,8 +270,7 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy, if (tokenCredential != null) { // User token based policy - policies.add( - new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint))); + policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, String.format("%s/.default", endpoint))); } else if (credentials != null) { // Use credentialS based policy policies.add(new ConfigurationCredentialsPolicy(credentials)); @@ -290,17 +283,15 @@ private HttpPipeline createDefaultHttpPipeline(SyncTokenPolicy syncTokenPolicy, policies.addAll(perRetryPolicies); List httpHeaderList = new ArrayList<>(); - localClientOptions.getHeaders().forEach( - header -> httpHeaderList.add(new HttpHeader(header.getName(), header.getValue()))); + localClientOptions.getHeaders() + .forEach(header -> httpHeaderList.add(new HttpHeader(header.getName(), header.getValue()))); policies.add(new AddHeadersPolicy(new HttpHeaders(httpHeaderList))); - HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); // customized pipeline - return new HttpPipelineBuilder() - .policies(policies.toArray(new HttpPipelinePolicy[0])) + return new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0])) .httpClient(httpClient) .tracer(createTracer(clientOptions)) .clientOptions(localClientOptions) @@ -547,4 +538,3 @@ public ConfigurationClientBuilder serviceVersion(ConfigurationServiceVersion ver return this; } } - diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java index bf89f3e7eb86f..5378093574c76 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationClientCredentials.java @@ -61,7 +61,6 @@ public String getBaseUri() { return this.credentials.baseUri().toString(); } - /** * Sets the {@code Authorization} header on the request. * @@ -96,17 +95,16 @@ void setAuthorizationHeaders(HttpRequest httpRequest) { String signed = url.getHost() + ";" + date + ";" + contentHash; - headers.set(HttpHeaderName.HOST, url.getHost()) - .set(X_MS_CONTENT_SHA256, contentHash); + headers.set(HttpHeaderName.HOST, url.getHost()).set(X_MS_CONTENT_SHA256, contentHash); // String-To-Sign=HTTP_METHOD + '\n' + path_and_query + '\n' + signed_headers_values // Signed headers: "host;x-ms-date;x-ms-content-sha256" // The line separator has to be \n. Using %n with String.format will result in a 401 from the service. - String stringToSign = httpRequest.getHttpMethod().toString().toUpperCase(Locale.US) - + "\n" + pathAndQuery + "\n" + signed; + String stringToSign + = httpRequest.getHttpMethod().toString().toUpperCase(Locale.US) + "\n" + pathAndQuery + "\n" + signed; - String signature = Base64.getEncoder() - .encodeToString(sha256HMAC.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8))); + String signature + = Base64.getEncoder().encodeToString(sha256HMAC.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8))); headers.set(HttpHeaderName.AUTHORIZATION, "HMAC-SHA256 Credential=" + credentials.id() + "&SignedHeaders=Host;Date;x-ms-content-sha256&Signature=" + signature); } catch (GeneralSecurityException e) { @@ -170,8 +168,10 @@ byte[] secret() { this.id = id; this.secret = secret; - if (this.baseUri == null || CoreUtils.isNullOrEmpty(this.id) - || this.secret == null || this.secret.length == 0) { + if (this.baseUri == null + || CoreUtils.isNullOrEmpty(this.id) + || this.secret == null + || this.secret.length == 0) { throw new IllegalArgumentException("Could not parse 'connectionString'." + " Expected format: 'endpoint={endpoint};id={id};secret={secret}'. Actual:" + connectionString); } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java index 7e0323605a94a..cdc1910f6f756 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialsPolicy.java @@ -69,4 +69,3 @@ public HttpResponse processSync(HttpPipelineCallContext context, HttpPipelineNex return next.processSync(); } } - diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java index 18a7406ae89b2..a64ca2f7542c0 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializationHelper.java @@ -39,14 +39,14 @@ public final class ConfigurationSettingDeserializationHelper { private static final ClientLogger LOGGER = new ClientLogger(Utility.class); static final String FEATURE_FLAG_CONTENT_TYPE = "application/vnd.microsoft.appconfig.ff+json;charset=utf-8"; - static final String SECRET_REFERENCE_CONTENT_TYPE = - "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"; + static final String SECRET_REFERENCE_CONTENT_TYPE + = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"; /* * Utility method for translating KeyValue to ConfigurationSetting with PagedResponse. */ - public static PagedResponseBase toConfigurationSettingWithPagedResponse( - PagedResponse pagedResponse) { + public static PagedResponseBase + toConfigurationSettingWithPagedResponse(PagedResponse pagedResponse) { List settings = new ArrayList<>(pagedResponse.getValue().size()); pagedResponse.getValue().forEach(keyValue -> settings.add(toConfigurationSetting(keyValue))); @@ -74,8 +74,7 @@ public static ConfigurationSetting toConfigurationSetting(KeyValue keyValue) { final String label = keyValue.getLabel(); final String etag = keyValue.getEtag(); final Map tags = keyValue.getTags(); - final ConfigurationSetting setting = new ConfigurationSetting() - .setKey(key) + final ConfigurationSetting setting = new ConfigurationSetting().setKey(key) .setValue(value) .setLabel(label) .setContentType(contentType) @@ -94,26 +93,25 @@ public static ConfigurationSetting toConfigurationSetting(KeyValue keyValue) { .setTags(setting.getTags()); } else if (SECRET_REFERENCE_CONTENT_TYPE.equals(contentType)) { return subclassConfigurationSettingReflection(setting, - parseSecretReferenceFieldValue(setting.getKey(), setting.getValue())) - .setValue(value) - .setLabel(label) - .setETag(etag) - .setContentType(contentType) - .setTags(tags); + parseSecretReferenceFieldValue(setting.getKey(), setting.getValue())).setValue(value) + .setLabel(label) + .setETag(etag) + .setContentType(contentType) + .setTags(tags); } else { // Configuration Setting return setting; } } catch (Exception exception) { - throw LOGGER.logExceptionAsError(new RuntimeException( - "The setting is neither a 'FeatureFlagConfigurationSetting' nor " + throw LOGGER.logExceptionAsError( + new RuntimeException("The setting is neither a 'FeatureFlagConfigurationSetting' nor " + "'SecretReferenceConfigurationSetting', return the setting as 'ConfigurationSetting'. " + "Error: ", exception)); } } - private static ConfigurationSetting subclassConfigurationSettingReflection( - ConfigurationSetting setting, T derivedClassSetting) { + private static ConfigurationSetting + subclassConfigurationSettingReflection(ConfigurationSetting setting, T derivedClassSetting) { ConfigurationSettingHelper.setReadOnly(derivedClassSetting, setting.isReadOnly()); ConfigurationSettingHelper.setLastModified(derivedClassSetting, setting.getLastModified()); return derivedClassSetting; @@ -183,8 +181,7 @@ private static FeatureFlagConfigurationSetting getFeatureFlagPropertyValue(JsonR } } - return new FeatureFlagConfigurationSetting(featureId, isEnabled) - .setDescription(description) + return new FeatureFlagConfigurationSetting(featureId, isEnabled).setDescription(description) .setDisplayName(displayName) .setClientFilters(clientFilters); }); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingHelper.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingHelper.java index 2ec399bb6e780..5b98f165953a7 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingHelper.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingHelper.java @@ -13,13 +13,15 @@ public final class ConfigurationSettingHelper { private static ConfigurationSettingAccessor accessor; - private ConfigurationSettingHelper() { } + private ConfigurationSettingHelper() { + } /** * Type defining the methods to set the non-public properties of an {@link ConfigurationSetting} instance. */ public interface ConfigurationSettingAccessor { ConfigurationSetting setReadOnly(ConfigurationSetting setting, boolean readOnly); + ConfigurationSetting setLastModified(ConfigurationSetting setting, OffsetDateTime lastModified); } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializationHelper.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializationHelper.java index eedfd8d861083..289948939e6fd 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializationHelper.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializationHelper.java @@ -40,7 +40,7 @@ public static String writeSecretReferenceConfigurationSetting(SecretReferenceCon // so it is better to use another JSON generator to constructor the value as JSON string, flush into the // StringWriter. try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { + JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { jsonWriter.writeStartObject(); jsonWriter.writeStringField(URI, setting.getSecretId()); jsonWriter.writeEndObject(); @@ -64,7 +64,7 @@ public static String writeFeatureFlagConfigurationSetting(FeatureFlagConfigurati // so it is better to use another JSON generator to constructor the value as JSON string, flush into the // StringWriter. try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { + JsonWriter jsonWriter = JsonProviders.createWriter(outputStream)) { jsonWriter.writeStartObject(); jsonWriter.writeStringField(ID, setting.getFeatureId()); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/CreateSnapshotUtilClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/CreateSnapshotUtilClient.java index b695ca6167aac..73ab71191adaf 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/CreateSnapshotUtilClient.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/CreateSnapshotUtilClient.java @@ -3,7 +3,6 @@ package com.azure.data.appconfiguration.implementation; - import com.azure.core.http.rest.Response; import com.azure.core.http.rest.ResponseBase; import com.azure.core.util.BinaryData; @@ -47,24 +46,17 @@ public CreateSnapshotUtilClient(AzureAppConfigurationImpl service) { public PollerFlux beginCreateSnapshot(String name, ConfigurationSnapshot snapshot) { try { - return new PollerFlux<>( - DEFAULT_POLL_INTERVAL, - activationOperation( - service.createSnapshotWithResponseAsync(name, snapshot, Context.NONE) - .map(response -> { - final Map pollResponse = new HashMap<>(); - pollResponse.put("id", response.getDeserializedHeaders().getOperationLocation()); - return BinaryData.fromObject(pollResponse).toObject(PollOperationDetails.class); - })), - pollingOperation( - operationId -> service.getOperationDetailsWithResponseAsync(name, Context.NONE)), - (pollingContext, activationResponse) -> - Mono.error(new RuntimeException("Cancellation is not supported.")), + return new PollerFlux<>(DEFAULT_POLL_INTERVAL, activationOperation( + service.createSnapshotWithResponseAsync(name, snapshot, Context.NONE).map(response -> { + final Map pollResponse = new HashMap<>(); + pollResponse.put("id", response.getDeserializedHeaders().getOperationLocation()); + return BinaryData.fromObject(pollResponse).toObject(PollOperationDetails.class); + })), pollingOperation(operationId -> service.getOperationDetailsWithResponseAsync(name, Context.NONE)), + (pollingContext, activationResponse) -> Mono + .error(new RuntimeException("Cancellation is not supported.")), fetchingOperation( - operationId -> service.getSnapshotWithResponseAsync( - name, null, null, null, Context.NONE) - .flatMap(res -> Mono.justOrEmpty(res.getValue()))) - ); + operationId -> service.getSnapshotWithResponseAsync(name, null, null, null, Context.NONE) + .flatMap(res -> Mono.justOrEmpty(res.getValue())))); } catch (Exception e) { return PollerFlux.error(e); } @@ -74,19 +66,14 @@ public SyncPoller beginCreateSnapsh ConfigurationSnapshot snapshot, Context context) { try { final Context finalContext = getNotNullContext(context); - return SyncPoller.createPoller( - DEFAULT_POLL_INTERVAL, + return SyncPoller.createPoller(DEFAULT_POLL_INTERVAL, cxt -> new PollResponse<>(LongRunningOperationStatus.NOT_STARTED, activationOperationSync(name, snapshot, finalContext).apply(cxt)), - pollingOperationSync( - operationId -> service.getOperationDetailsWithResponse(name, finalContext)), + pollingOperationSync(operationId -> service.getOperationDetailsWithResponse(name, finalContext)), (pollingContext, activationResponse) -> { throw LOGGER.logExceptionAsError(new RuntimeException("Cancellation is not supported.")); - }, - fetchingOperationSync( - operationId -> service.getSnapshotWithResponse(name, null, null, - null, finalContext).getValue()) - ); + }, fetchingOperationSync( + operationId -> service.getSnapshotWithResponse(name, null, null, null, finalContext).getValue())); } catch (Exception e) { throw LOGGER.logExceptionAsError(new RuntimeException(e)); } @@ -104,13 +91,13 @@ public SyncPoller beginCreateSnapsh }; } - private Function, PollOperationDetails> - activationOperationSync(String name, ConfigurationSnapshot snapshot, Context context) { + private Function, PollOperationDetails> activationOperationSync(String name, + ConfigurationSnapshot snapshot, Context context) { return pollingContext -> { try { final Context finalContext = getNotNullContext(context); - final ResponseBase snapshotWithResponse = - service.createSnapshotWithResponse(name, snapshot, finalContext); + final ResponseBase snapshotWithResponse + = service.createSnapshotWithResponse(name, snapshot, finalContext); final Map pollResponse = new HashMap<>(); pollResponse.put("id", snapshotWithResponse.getDeserializedHeaders().getOperationLocation()); return BinaryData.fromObject(pollResponse).toObject(PollOperationDetails.class); @@ -125,12 +112,10 @@ public SyncPoller beginCreateSnapsh pollingOperation(Function>> pollingFunction) { return pollingContext -> { try { - final PollResponse pollResponse = - pollingContext.getLatestResponse(); + final PollResponse pollResponse = pollingContext.getLatestResponse(); final String operationId = pollResponse.getValue().getOperationId(); return pollingFunction.apply(operationId) - .flatMap(modelResponse -> - Mono.just(processResponse(modelResponse, pollResponse))); + .flatMap(modelResponse -> Mono.just(processResponse(modelResponse, pollResponse))); } catch (RuntimeException ex) { return monoError(LOGGER, ex); } @@ -141,8 +126,7 @@ public SyncPoller beginCreateSnapsh pollingOperationSync(Function> pollingFunction) { return pollingContext -> { try { - final PollResponse pollResponse = - pollingContext.getLatestResponse(); + final PollResponse pollResponse = pollingContext.getLatestResponse(); return processResponse(pollingFunction.apply(pollResponse.getValue().getOperationId()), pollResponse); } catch (RuntimeException ex) { throw LOGGER.logExceptionAsError(ex); @@ -151,9 +135,8 @@ public SyncPoller beginCreateSnapsh } // Fetching operation - private Function, - Mono> fetchingOperation( - Function> fetchingFunction) { + private Function, Mono> + fetchingOperation(Function> fetchingFunction) { return pollingContext -> { try { String operationId = pollingContext.getLatestResponse().getValue().getOperationId(); @@ -164,8 +147,8 @@ Mono> fetchingOperation( }; } - private Function, ConfigurationSnapshot> fetchingOperationSync( - Function fetchingFunction) { + private Function, ConfigurationSnapshot> + fetchingOperationSync(Function fetchingFunction) { return pollingContext -> { try { String operationId = pollingContext.getLatestResponse().getValue().getOperationId(); @@ -176,8 +159,7 @@ private Function, ConfigurationSnapshot> fe }; } - private PollResponse processResponse( - Response response, + private PollResponse processResponse(Response response, PollResponse operationResultPollResponse) { LongRunningOperationStatus status; State state = response.getValue().getStatus(); @@ -186,8 +168,7 @@ private PollResponse processResponse( } else if (SUCCEEDED.equals(state)) { status = LongRunningOperationStatus.SUCCESSFULLY_COMPLETED; } else { - status = LongRunningOperationStatus.fromString( - response.getValue().toString(), true); + status = LongRunningOperationStatus.fromString(response.getValue().toString(), true); } return new PollResponse<>(status, operationResultPollResponse.getValue()); } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncToken.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncToken.java index 0295fe978a0d0..d8b0ea707c62d 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncToken.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncToken.java @@ -21,8 +21,8 @@ public final class SyncToken { private static final String EQUAL = "="; private static final String SEMICOLON = ";"; private static final String SEQUENCE_NUMBER_CANNOT_PARSED = "Sequence number cannot be parsed to long."; - private static final String VALID_FORMAT_ERROR_MESSAGE = - "Expected sync-token valid format should be =;sn=. For multiple sync tokens, " + private static final String VALID_FORMAT_ERROR_MESSAGE + = "Expected sync-token valid format should be =;sn=. For multiple sync tokens, " + "=;sn=,=;sn=."; private static final ClientLogger LOGGER = new ClientLogger(SyncToken.class); @@ -53,9 +53,12 @@ public static SyncToken createSyncToken(String syncToken) { final String[] idParts = syncTokenParts[0].split(EQUAL, 2); final String[] snParts = syncTokenParts[1].split(EQUAL, 2); - if (idParts.length != 2 || snParts.length != 2 - || idParts[0].isEmpty() || idParts[1].isEmpty() - || snParts[0].isEmpty() || snParts[1].isEmpty()) { + if (idParts.length != 2 + || snParts.length != 2 + || idParts[0].isEmpty() + || idParts[1].isEmpty() + || snParts[0].isEmpty() + || snParts[1].isEmpty()) { throw LOGGER.logExceptionAsError(new IllegalArgumentException(VALID_FORMAT_ERROR_MESSAGE)); } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicy.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicy.java index 37f7ef8ace3a2..078d48872b0a3 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicy.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicy.java @@ -39,7 +39,6 @@ protected HttpResponse afterReceivedResponse(HttpPipelineCallContext context, Ht return response; } - /** * Get all latest sync-tokens from the concurrent map and convert to one sync-token string. * All sync-tokens concatenated by a comma delimiter. @@ -47,8 +46,10 @@ protected HttpResponse afterReceivedResponse(HttpPipelineCallContext context, Ht * @return sync-token string */ private String getSyncTokenHeader() { - return syncTokenMap.values().stream().map(syncToken -> syncToken.getId() + EQUAL + syncToken.getValue()) - .collect(Collectors.joining(COMMA)); + return syncTokenMap.values() + .stream() + .map(syncToken -> syncToken.getId() + EQUAL + syncToken.getValue()) + .collect(Collectors.joining(COMMA)); } /** @@ -77,7 +78,7 @@ public void updateSyncToken(String token) { // to ensure the entire operation is atomic. syncTokenMap.compute(tokenId, (key, existingSyncToken) -> { if (existingSyncToken == null - || syncToken.getSequenceNumber() > existingSyncToken.getSequenceNumber()) { + || syncToken.getSequenceNumber() > existingSyncToken.getSequenceNumber()) { return syncToken; } return existingSyncToken; 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 7132e98b2348b..ee7c029a92791 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 @@ -54,15 +54,14 @@ public class Utility { * Translate public ConfigurationSetting to KeyValue autorest generated class. */ public static KeyValue toKeyValue(ConfigurationSetting setting) { - return new KeyValue() - .setKey(setting.getKey()) - .setValue(setting.getValue()) - .setLabel(setting.getLabel()) - .setContentType(setting.getContentType()) - .setEtag(setting.getETag()) - .setLastModified(setting.getLastModified()) - .setLocked(setting.isReadOnly()) - .setTags(setting.getTags()); + return new KeyValue().setKey(setting.getKey()) + .setValue(setting.getValue()) + .setLabel(setting.getLabel()) + .setContentType(setting.getContentType()) + .setEtag(setting.getETag()) + .setLastModified(setting.getLastModified()) + .setLocked(setting.isReadOnly()) + .setTags(setting.getTags()); } // SettingFields[] to List @@ -98,6 +97,7 @@ public static void validateSetting(ConfigurationSetting setting) { throw new IllegalArgumentException("Parameter 'key' is required and cannot be null."); } } + /* * Asynchronously validate that setting and key is not null. The key is used in the service URL, * so it cannot be null. @@ -113,22 +113,22 @@ public static Mono validateSettingAsync(ConfigurationSetti } public static Response updateSnapshotSync(String snapshotName, - MatchConditions matchConditions, ConfigurationSnapshotStatus status, - AzureAppConfigurationImpl serviceClient, Context context) { + MatchConditions matchConditions, ConfigurationSnapshotStatus status, AzureAppConfigurationImpl serviceClient, + Context context) { final String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); - final ResponseBase response = - serviceClient.updateSnapshotWithResponse(snapshotName, - new SnapshotUpdateParameters().setStatus(status), ifMatch, null, context); + final ResponseBase response + = serviceClient.updateSnapshotWithResponse(snapshotName, new SnapshotUpdateParameters().setStatus(status), + ifMatch, null, context); return new SimpleResponse<>(response, response.getValue()); } public static Mono> updateSnapshotAsync(String snapshotName, - MatchConditions matchConditions, ConfigurationSnapshotStatus status, - AzureAppConfigurationImpl serviceClient) { + MatchConditions matchConditions, ConfigurationSnapshotStatus status, AzureAppConfigurationImpl serviceClient) { final String ifMatch = matchConditions == null ? null : matchConditions.getIfMatch(); - return serviceClient.updateSnapshotWithResponseAsync(snapshotName, - new SnapshotUpdateParameters().setStatus(status), ifMatch, null) + return serviceClient + .updateSnapshotWithResponseAsync(snapshotName, new SnapshotUpdateParameters().setStatus(status), ifMatch, + null) .map(response -> new SimpleResponse<>(response, response.getValue())); } @@ -160,6 +160,7 @@ public static Mono> handleNotModifiedErrorToValidRespons return Mono.error(error); } + // Sync Handler public static PagedResponse handleNotModifiedErrorToValidResponse(HttpResponseException error, ClientLogger logger) { diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/ConfigurationSetting.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/ConfigurationSetting.java index 3706bb1571064..4a02fc0bfa291 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/ConfigurationSetting.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/ConfigurationSetting.java @@ -210,11 +210,8 @@ public ConfigurationSetting setTags(Map tags) { @Override public String toString() { - return String.format("ConfigurationSetting(key=%s, label=%s, value=%s, etag=%s)", - this.key, - this.label, - this.value, - this.etag); + return String.format("ConfigurationSetting(key=%s, label=%s, value=%s, etag=%s)", this.key, this.label, + this.value, this.etag); } @Override @@ -258,8 +255,8 @@ public static ConfigurationSetting fromJson(JsonReader jsonReader) throws IOExce } else if ("etag".equals(fieldName)) { setting.setETag(reader.getString()); } else if ("last_modified".equals(fieldName)) { - setting.setLastModified(reader.getNullable(nonNullReader -> - OffsetDateTime.parse(nonNullReader.getString()))); + setting.setLastModified( + reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))); } else if ("locked".equals(fieldName)) { setting.setReadOnly(reader.getBoolean()); } else if ("tags".equals(fieldName)) { diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/FeatureFlagConfigurationSetting.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/FeatureFlagConfigurationSetting.java index 9b6e729b54bd5..c1adfc220ad96 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/FeatureFlagConfigurationSetting.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/FeatureFlagConfigurationSetting.java @@ -62,8 +62,8 @@ public final class FeatureFlagConfigurationSetting extends ConfigurationSetting private final List requiredJsonProperties = Arrays.asList(ID, ENABLED, CONDITIONS); // Swagger schema defined properties at first level of FeatureFlagConfigurationSetting. - private final List requiredOrOptionalJsonProperties = - Arrays.asList(ID, DESCRIPTION, DISPLAY_NAME, ENABLED, CONDITIONS); + private final List requiredOrOptionalJsonProperties + = Arrays.asList(ID, DESCRIPTION, DISPLAY_NAME, ENABLED, CONDITIONS); /** * The constructor for a feature flag configuration setting. @@ -119,8 +119,8 @@ public String getValue() { newValue = outputStream.toString(StandardCharsets.UTF_8.name()); outputStream.close(); } catch (IOException exception) { - LOGGER.logExceptionAsError(new IllegalArgumentException( - "Can't parse Feature Flag configuration setting value.", exception)); + LOGGER.logExceptionAsError( + new IllegalArgumentException("Can't parse Feature Flag configuration setting value.", exception)); } super.setValue(newValue); @@ -255,7 +255,7 @@ public boolean isEnabled() { * Set the boolean indicator to show if the setting is turn on or off. * * @param isEnabled the boolean indicator to show if the setting is turn on or off. - + * @return The updated {@link FeatureFlagConfigurationSetting} object. * @throws IllegalArgumentException if the setting's {@code value} is an invalid JSON format. */ @@ -369,27 +369,32 @@ private void checkValid() { // Try to write the known property. If it is a known property, return true. Otherwise, return false. private boolean tryWriteKnownProperty(String propertyName, Object propertyValue, JsonWriter writer, - boolean includeOptionalWhenNull) throws IOException { + boolean includeOptionalWhenNull) throws IOException { switch (propertyName) { case ID: writer.writeStringField(ID, featureId); break; + case DESCRIPTION: if (includeOptionalWhenNull || description != null) { writer.writeStringField(DESCRIPTION, description); } break; + case DISPLAY_NAME: if (includeOptionalWhenNull || displayName != null) { writer.writeStringField(DISPLAY_NAME, displayName); } break; + case ENABLED: writer.writeBooleanField(ENABLED, isEnabled); break; + case CONDITIONS: tryWriteConditions(propertyValue, writer); break; + default: return false; } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SecretReferenceConfigurationSetting.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SecretReferenceConfigurationSetting.java index 17baf11c02267..5df6f9dd865a2 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SecretReferenceConfigurationSetting.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SecretReferenceConfigurationSetting.java @@ -27,14 +27,15 @@ public final class SecretReferenceConfigurationSetting extends ConfigurationSett private static final ClientLogger LOGGER = new ClientLogger(SecretReferenceConfigurationSetting.class); private String secretId; - private static final String SECRET_REFERENCE_CONTENT_TYPE = - "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"; + private static final String SECRET_REFERENCE_CONTENT_TYPE + = "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"; // The flag to indicate if the 'value' field is valid. It is a temporary field to store the flag. // If the 'value' field is not valid, we will throw an exception when user try to access the strongly-typed // properties. private boolean isValidSecretReferenceValue; private final Map parsedProperties = new LinkedHashMap<>(1); + /** * The constructor for a secret reference configuration setting. * @@ -128,8 +129,8 @@ public String getValue() { newValue = outputStream.toString(StandardCharsets.UTF_8.name()); outputStream.close(); } catch (IOException exception) { - LOGGER.logExceptionAsError(new IllegalArgumentException( - "Can't parse Secret Reference configuration setting value.", exception)); + LOGGER.logExceptionAsError( + new IllegalArgumentException("Can't parse Secret Reference configuration setting value.", exception)); } super.setValue(newValue); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SettingSelector.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SettingSelector.java index 593211de03c22..f05175497271f 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SettingSelector.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SettingSelector.java @@ -122,8 +122,8 @@ public String getAcceptDateTime() { * @return The updated SettingSelector object. */ public SettingSelector setAcceptDatetime(OffsetDateTime datetime) { - this.acceptDatetime = datetime == null ? null - : DateTimeFormatter.RFC_1123_DATE_TIME.toFormat().format(datetime); + this.acceptDatetime + = datetime == null ? null : DateTimeFormatter.RFC_1123_DATE_TIME.toFormat().format(datetime); return this; } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SnapshotSelector.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SnapshotSelector.java index 4f29a7506fba5..6f315fb8d541c 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SnapshotSelector.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/models/SnapshotSelector.java @@ -24,7 +24,8 @@ public final class SnapshotSelector { /** * Creates an instance of {@link SnapshotSelector}. */ - public SnapshotSelector() { } + public SnapshotSelector() { + } /** * Gets the snapshot name filter @@ -124,10 +125,12 @@ public String toString() { fields = "ALL_FIELDS"; } else { // join a list of enum values into a comma-separated string - fields = this.fields == null ? null : IterableStream.of(this.fields) - .stream() - .map(fieldsEnumValue -> fieldsEnumValue.toString()) - .collect(Collectors.joining(",")); + fields = this.fields == null + ? null + : IterableStream.of(this.fields) + .stream() + .map(fieldsEnumValue -> fieldsEnumValue.toString()) + .collect(Collectors.joining(",")); } String status; @@ -135,10 +138,12 @@ public String toString() { status = "ALL_STATUS"; } else { // join a list of enum values into a comma-separated string - status = this.status == null ? null : IterableStream.of(this.status) - .stream() - .map(statusEnumValue -> statusEnumValue.toString()) - .collect(Collectors.joining(",")); + status = this.status == null + ? null + : IterableStream.of(this.status) + .stream() + .map(statusEnumValue -> statusEnumValue.toString()) + .collect(Collectors.joining(",")); } return "SnapshotSelector(name=" + nameFilter + ", status=" + status + ", fields=" + fields + ")"; } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationAsyncClientTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationAsyncClientTest.java index 3189c53d183e1..2fc4d4205ec3d 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationAsyncClientTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationAsyncClientTest.java @@ -66,12 +66,15 @@ protected void beforeTest() { protected void afterTest() { logger.info("Cleaning up created key values."); client.listConfigurationSettings(new SettingSelector().setKeyFilter(keyPrefix + "*")) - .flatMap(configurationSetting -> { - logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isReadOnly()); - Mono> unlock = configurationSetting.isReadOnly() ? client.setReadOnlyWithResponse(configurationSetting, false) : Mono.empty(); - return unlock.then(client.deleteConfigurationSettingWithResponse(configurationSetting, false)); - }) - .blockLast(); + .flatMap(configurationSetting -> { + logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), + configurationSetting.getLabel(), configurationSetting.isReadOnly()); + Mono> unlock = configurationSetting.isReadOnly() + ? client.setReadOnlyWithResponse(configurationSetting, false) + : Mono.empty(); + return unlock.then(client.deleteConfigurationSettingWithResponse(configurationSetting, false)); + }) + .blockLast(); logger.info("Finished cleaning up values."); } @@ -79,8 +82,7 @@ protected void afterTest() { private ConfigurationAsyncClient getConfigurationAsyncClient(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { return clientSetup((credentials, endpoint) -> { - ConfigurationClientBuilder builder = new ConfigurationClientBuilder() - .credential(credentials) + ConfigurationClientBuilder builder = new ConfigurationClientBuilder().credential(credentials) .endpoint(endpoint) .serviceVersion(serviceVersion); @@ -109,9 +111,7 @@ private ConfigurationClientBuilder setHttpClient(HttpClient httpClient, Configur } private HttpClient buildAsyncAssertingClient(HttpClient httpClient) { - return new AssertingHttpClientBuilder(httpClient) - .assertAsync() - .build(); + return new AssertingHttpClientBuilder(httpClient).assertAsync().build(); } /** @@ -122,8 +122,8 @@ private HttpClient buildAsyncAssertingClient(HttpClient httpClient) { @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); } @@ -132,11 +132,9 @@ public void addConfigurationSetting(HttpClient httpClient, ConfigurationServiceV @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - addConfigurationSettingRunner( - (expected) -> - StepVerifier.create(client.addConfigurationSetting(expected)) - .assertNext(response -> assertConfigurationEquals(expected, response)) - .verifyComplete()); + addConfigurationSettingRunner((expected) -> StepVerifier.create(client.addConfigurationSetting(expected)) + .assertNext(response -> assertConfigurationEquals(expected, response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -145,11 +143,10 @@ public void addFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); addFeatureFlagConfigurationSettingRunner( - (expected) -> - StepVerifier.create(client.addConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete()); + (expected) -> StepVerifier.create(client.addConfigurationSetting(expected)) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -158,11 +155,10 @@ public void addSecretReferenceConfigurationSettingConvenience(HttpClient httpCli ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); addSecretReferenceConfigurationSettingRunner( - (expected) -> - StepVerifier.create(client.addConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete()); + (expected) -> StepVerifier.create(client.addConfigurationSetting(expected)) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete()); } /** @@ -184,7 +180,8 @@ public void addConfigurationSettingEmptyKey(HttpClient httpClient, Configuration public void addConfigurationSettingEmptyValue(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); addConfigurationSettingEmptyValueRunner((setting) -> { - StepVerifier.create(client.addConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())) + StepVerifier + .create(client.addConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())) .assertNext(response -> assertConfigurationEquals(setting, response)) .verifyComplete(); @@ -217,13 +214,11 @@ public void addConfigurationSettingNullKey(HttpClient httpClient, ConfigurationS @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addExistingSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - addExistingSettingRunner((expected) -> - StepVerifier.create( - client.addConfigurationSettingWithResponse(expected) - .then( - client.addConfigurationSettingWithResponse(expected))) - .verifyErrorSatisfies(ex -> assertRestException(ex, - HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED))); + addExistingSettingRunner((expected) -> StepVerifier + .create(client.addConfigurationSettingWithResponse(expected) + .then(client.addConfigurationSettingWithResponse(expected))) + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED))); } /** @@ -234,21 +229,20 @@ public void addExistingSetting(HttpClient httpClient, ConfigurationServiceVersio @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void setConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - setConfigurationSettingRunner((expected, update) -> - StepVerifier.create(client.setConfigurationSettingWithResponse(expected, false)) - .assertNext(response -> assertConfigurationEquals(expected, response)) - .verifyComplete()); + setConfigurationSettingRunner( + (expected, update) -> StepVerifier.create(client.setConfigurationSettingWithResponse(expected, false)) + .assertNext(response -> assertConfigurationEquals(expected, response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void setConfigurationSettingConvenience(HttpClient httpClient, - ConfigurationServiceVersion serviceVersion) { + public void setConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); setConfigurationSettingRunner( (expected, update) -> StepVerifier.create(client.setConfigurationSetting(expected)) - .assertNext(response -> assertConfigurationEquals(expected, response)) - .verifyComplete()); + .assertNext(response -> assertConfigurationEquals(expected, response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -258,10 +252,9 @@ public void setFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, client = getConfigurationAsyncClient(httpClient, serviceVersion); setFeatureFlagConfigurationSettingRunner( (expected, update) -> StepVerifier.create(client.setConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals( - expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete()); + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -269,31 +262,27 @@ public void setFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, public void featureFlagConfigurationSettingUnknownAttributesArePreserved(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - featureFlagConfigurationSettingUnknownAttributesArePreservedRunner( - (expected) -> { - StepVerifier.create(client.addConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals( - expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.setConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals( - expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.getConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals( - expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.deleteConfigurationSetting(expected)) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.getConfigurationSetting(expected)) - .verifyErrorSatisfies( - ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); - }); + featureFlagConfigurationSettingUnknownAttributesArePreservedRunner((expected) -> { + StepVerifier.create(client.addConfigurationSetting(expected)) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.setConfigurationSetting(expected)) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.getConfigurationSetting(expected)) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.deleteConfigurationSetting(expected)) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.getConfigurationSetting(expected)) + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); + }); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -303,10 +292,9 @@ public void setSecretReferenceConfigurationSettingConvenience(HttpClient httpCli client = getConfigurationAsyncClient(httpClient, serviceVersion); setSecretReferenceConfigurationSettingRunner( (expected, update) -> StepVerifier.create(client.setConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals( - expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete()); + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -314,31 +302,27 @@ public void setSecretReferenceConfigurationSettingConvenience(HttpClient httpCli public void secretReferenceConfigurationSettingUnknownAttributesArePreserved(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - secretReferenceConfigurationSettingUnknownAttributesArePreservedRunner( - (expected) -> { - StepVerifier.create(client.addConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals( - expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.setConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals( - expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.getConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals( - expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.deleteConfigurationSetting(expected)) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete(); - StepVerifier.create(client.getConfigurationSetting(expected)) - .verifyErrorSatisfies( - ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); - }); + secretReferenceConfigurationSettingUnknownAttributesArePreservedRunner((expected) -> { + StepVerifier.create(client.addConfigurationSetting(expected)) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.setConfigurationSetting(expected)) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.getConfigurationSetting(expected)) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.deleteConfigurationSetting(expected)) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete(); + StepVerifier.create(client.getConfigurationSetting(expected)) + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); + }); } /** @@ -353,20 +337,23 @@ public void setConfigurationSettingIfETag(HttpClient httpClient, ConfigurationSe setConfigurationSettingIfETagRunner((initial, update) -> { // This ETag is not the correct format. It is not the correct hash that the service is expecting. StepVerifier.create(client.setConfigurationSettingWithResponse(initial.setETag("badEtag"), true)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); - StepVerifier.create(client.addConfigurationSettingWithResponse(initial) + StepVerifier + .create(client.addConfigurationSettingWithResponse(initial) .map(Response::getValue) .flatMap(val -> client.setConfigurationSettingWithResponse(update.setETag(val.getETag()), true))) - .assertNext(response -> assertConfigurationEquals(update, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(update, response)) + .verifyComplete(); StepVerifier.create(client.setConfigurationSettingWithResponse(initial, true)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); StepVerifier.create(client.getConfigurationSettingWithResponse(update, null, false)) - .assertNext(response -> assertConfigurationEquals(update, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(update, response)) + .verifyComplete(); }); } @@ -421,24 +408,21 @@ public void setConfigurationSettingNullKey(HttpClient httpClient, ConfigurationS @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void getConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - getConfigurationSettingRunner((expected) -> - StepVerifier.create( - client.addConfigurationSettingWithResponse(expected) - .then(client.getConfigurationSettingWithResponse(expected, null, false))) - .assertNext(response -> assertConfigurationEquals(expected, response)) - .verifyComplete()); + getConfigurationSettingRunner((expected) -> StepVerifier + .create(client.addConfigurationSettingWithResponse(expected) + .then(client.getConfigurationSettingWithResponse(expected, null, false))) + .assertNext(response -> assertConfigurationEquals(expected, response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void getConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - getConfigurationSettingRunner( - (expected) -> StepVerifier.create( - client.addConfigurationSetting(expected).then( - client.getConfigurationSetting(expected))) - .assertNext(response -> assertConfigurationEquals(expected, response)) - .verifyComplete()); + getConfigurationSettingRunner((expected) -> StepVerifier + .create(client.addConfigurationSetting(expected).then(client.getConfigurationSetting(expected))) + .assertNext(response -> assertConfigurationEquals(expected, response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -446,13 +430,11 @@ public void getConfigurationSettingConvenience(HttpClient httpClient, Configurat public void getFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - getFeatureFlagConfigurationSettingRunner( - (expected) -> StepVerifier.create( - client.addConfigurationSetting(expected).then( - client.getConfigurationSetting(expected))) - .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) response)) - .verifyComplete()); + getFeatureFlagConfigurationSettingRunner((expected) -> StepVerifier + .create(client.addConfigurationSetting(expected).then(client.getConfigurationSetting(expected))) + .assertNext(response -> assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) response)) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -460,13 +442,11 @@ public void getFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, public void getSecretReferenceConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - getSecretReferenceConfigurationSettingRunner( - (expected) -> StepVerifier.create( - client.addConfigurationSetting(expected).then( - client.getConfigurationSetting(expected))) - .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) response)) - .verifyComplete()); + getSecretReferenceConfigurationSettingRunner((expected) -> StepVerifier + .create(client.addConfigurationSetting(expected).then(client.getConfigurationSetting(expected))) + .assertNext(response -> assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) response)) + .verifyComplete()); } /** @@ -477,19 +457,22 @@ public void getSecretReferenceConfigurationSettingConvenience(HttpClient httpCli public void getConfigurationSettingNotFound(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final String key = getKey(); - final ConfigurationSetting neverRetrievedConfiguration = new ConfigurationSetting().setKey(key).setValue("myNeverRetreivedValue"); - final ConfigurationSetting nonExistentLabel = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); + final ConfigurationSetting neverRetrievedConfiguration + = new ConfigurationSetting().setKey(key).setValue("myNeverRetreivedValue"); + final ConfigurationSetting nonExistentLabel + = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); StepVerifier.create(client.addConfigurationSettingWithResponse(neverRetrievedConfiguration)) .assertNext(response -> assertConfigurationEquals(neverRetrievedConfiguration, response)) .verifyComplete(); StepVerifier.create(client.getConfigurationSetting("myNonExistentKey", null, null)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); - + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); StepVerifier.create(client.getConfigurationSettingWithResponse(nonExistentLabel, null, false)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); } /** @@ -502,7 +485,9 @@ public void getConfigurationSettingNotFound(HttpClient httpClient, Configuration public void deleteConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); deleteConfigurationSettingRunner((expected) -> { - StepVerifier.create(client.addConfigurationSettingWithResponse(expected).then(client.getConfigurationSettingWithResponse(expected, null, false))) + StepVerifier + .create(client.addConfigurationSettingWithResponse(expected) + .then(client.getConfigurationSettingWithResponse(expected, null, false))) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete(); @@ -511,7 +496,8 @@ public void deleteConfigurationSetting(HttpClient httpClient, ConfigurationServi .verifyComplete(); StepVerifier.create(client.getConfigurationSettingWithResponse(expected, null, false)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); }); } @@ -587,21 +573,29 @@ public void deleteSecretReferenceConfigurationSettingConvenience(HttpClient http public void deleteConfigurationSettingNotFound(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final String key = getKey(); - final ConfigurationSetting neverDeletedConfiguration = new ConfigurationSetting().setKey(key).setValue("myNeverDeletedValue"); + final ConfigurationSetting neverDeletedConfiguration + = new ConfigurationSetting().setKey(key).setValue("myNeverDeletedValue"); StepVerifier.create(client.addConfigurationSettingWithResponse(neverDeletedConfiguration)) .assertNext(response -> assertConfigurationEquals(neverDeletedConfiguration, response)) .verifyComplete(); - StepVerifier.create(client.deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey("myNonExistentKey"), false)) + StepVerifier + .create(client.deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey("myNonExistentKey"), + false)) .assertNext(response -> assertConfigurationEquals(null, response, HttpURLConnection.HTTP_NO_CONTENT)) .verifyComplete(); - StepVerifier.create(client.deleteConfigurationSettingWithResponse(new ConfigurationSetting().setKey(neverDeletedConfiguration.getKey()).setLabel("myNonExistentLabel"), false)) + StepVerifier + .create(client.deleteConfigurationSettingWithResponse( + new ConfigurationSetting().setKey(neverDeletedConfiguration.getKey()).setLabel("myNonExistentLabel"), + false)) .assertNext(response -> assertConfigurationEquals(null, response, HttpURLConnection.HTTP_NO_CONTENT)) .verifyComplete(); - StepVerifier.create(client.getConfigurationSetting(neverDeletedConfiguration.getKey(), neverDeletedConfiguration.getLabel(), null)) + StepVerifier + .create(client.getConfigurationSetting(neverDeletedConfiguration.getKey(), + neverDeletedConfiguration.getLabel(), null)) .assertNext(response -> assertConfigurationEquals(neverDeletedConfiguration, response)) .verifyComplete(); } @@ -615,22 +609,26 @@ public void deleteConfigurationSettingNotFound(HttpClient httpClient, Configurat public void deleteConfigurationSettingWithETag(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); deleteConfigurationSettingWithETagRunner((initial, update) -> { - final ConfigurationSetting initiallyAddedConfig = client.addConfigurationSettingWithResponse(initial).block().getValue(); - final ConfigurationSetting updatedConfig = client.setConfigurationSettingWithResponse(update, true).block().getValue(); + final ConfigurationSetting initiallyAddedConfig + = client.addConfigurationSettingWithResponse(initial).block().getValue(); + final ConfigurationSetting updatedConfig + = client.setConfigurationSettingWithResponse(update, true).block().getValue(); StepVerifier.create(client.getConfigurationSettingWithResponse(initial, null, false)) .assertNext(response -> assertConfigurationEquals(update, response)) .verifyComplete(); StepVerifier.create(client.deleteConfigurationSettingWithResponse(initiallyAddedConfig, true)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED)); StepVerifier.create(client.deleteConfigurationSettingWithResponse(updatedConfig, true)) .assertNext(response -> assertConfigurationEquals(update, response)) .verifyComplete(); StepVerifier.create(client.getConfigurationSettingWithResponse(initial, null, false)) - .verifyErrorSatisfies(ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); + .verifyErrorSatisfies( + ex -> assertRestException(ex, HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND)); }); } @@ -641,8 +639,7 @@ public void deleteConfigurationSettingWithETag(HttpClient httpClient, Configurat @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void deleteConfigurationSettingNullKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - StepVerifier.create(client.deleteConfigurationSetting(null, null)) - .verifyError(IllegalArgumentException.class); + StepVerifier.create(client.deleteConfigurationSetting(null, null)).verifyError(IllegalArgumentException.class); StepVerifier.create(client.deleteConfigurationSettingWithResponse(null, false)) .verifyError(NullPointerException.class); } @@ -686,7 +683,8 @@ public void clearReadOnly(HttpClient httpClient, ConfigurationServiceVersion ser */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void clearReadOnlyWithConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void clearReadOnlyWithConfigurationSetting(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); lockUnlockRunner((expected) -> { StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) @@ -832,7 +830,8 @@ public void listWithKeyAndLabel(HttpClient httpClient, ConfigurationServiceVersi .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete(); - StepVerifier.create(client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label))) + StepVerifier + .create(client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label))) .assertNext(configurationSetting -> assertConfigurationEquals(expected, configurationSetting)) .verifyComplete(); @@ -874,17 +873,16 @@ public void listWithMultipleKeys(HttpClient httpClient, ConfigurationServiceVers @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsWithNullSelector(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsWithNullSelector(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final String key = getKey(); final String key2 = getKey(); // Delete all existing settings in the resource - StepVerifier.create( - client.listConfigurationSettings(null) - .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) - .then()) - .verifyComplete(); + StepVerifier.create(client.listConfigurationSettings(null) + .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) + .then()).verifyComplete(); listWithMultipleKeysRunner(key, key2, (setting, setting2) -> { List selected = new ArrayList<>(); @@ -928,7 +926,9 @@ public void listWithMultipleLabels(HttpClient httpClient, ConfigurationServiceVe .assertNext(response -> assertConfigurationEquals(setting2, response)) .verifyComplete(); - StepVerifier.create(client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2))) + StepVerifier + .create(client.listConfigurationSettings( + new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2))) .consumeNextWith(selected::add) .consumeNextWith(selected::add) .verifyComplete(); @@ -942,7 +942,8 @@ public void listWithMultipleLabels(HttpClient httpClient, ConfigurationServiceVe */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFields(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFields(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); listConfigurationSettingsSelectFieldsRunner((settings, selector) -> { final List>> settingsBeingAdded = new ArrayList<>(); @@ -968,7 +969,8 @@ public void listConfigurationSettingsSelectFields(HttpClient httpClient, Configu */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); filterValueTest("*" + getKey(), getLabel()); } @@ -978,7 +980,8 @@ public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpCli */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); filterValueTest("*" + getKey() + "*", getLabel()); } @@ -988,7 +991,8 @@ public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClie */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); filterValueTest(getKey(), "*" + getLabel()); } @@ -998,7 +1002,8 @@ public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpC */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); filterValueTest(getKey(), "*" + getLabel() + "*"); } @@ -1008,35 +1013,41 @@ public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpCl */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsAcceptDateTime(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsAcceptDateTime(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final String keyName = testResourceNamer.randomName(keyPrefix, 16); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. StepVerifier.create(client.setConfigurationSettingWithResponse(original, false)) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); - StepVerifier.create(client.setConfigurationSettingWithResponse(updated, false).delayElement(Duration.ofSeconds(2))) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); + StepVerifier + .create(client.setConfigurationSettingWithResponse(updated, false).delayElement(Duration.ofSeconds(2))) + .assertNext(response -> assertConfigurationEquals(updated, response)) + .verifyComplete(); StepVerifier.create(client.setConfigurationSettingWithResponse(updated2, false)) - .assertNext(response -> assertConfigurationEquals(updated2, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated2, response)) + .verifyComplete(); // 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)).collectList().block(); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).collectList().block(); assertNotNull(revisions); assertEquals(3, revisions.size()); // We want to fetch the configuration setting when we first updated its value. - SettingSelector options = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); + SettingSelector options + = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); StepVerifier.create(client.listConfigurationSettings(options)) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated, response)) + .verifyComplete(); } /** @@ -1049,33 +1060,37 @@ public void listRevisions(HttpClient httpClient, ConfigurationServiceVersion ser client = getConfigurationAsyncClient(httpClient, serviceVersion); final String keyName = testResourceNamer.randomName(keyPrefix, 16); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. StepVerifier.create(client.setConfigurationSettingWithResponse(original, false)) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); StepVerifier.create(client.setConfigurationSettingWithResponse(updated, false)) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated, response)) + .verifyComplete(); StepVerifier.create(client.setConfigurationSettingWithResponse(updated2, false)) - .assertNext(response -> assertConfigurationEquals(updated2, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated2, response)) + .verifyComplete(); // Get all revisions for a key, they are listed in descending order. StepVerifier.create(client.listRevisions(new SettingSelector().setKeyFilter(keyName))) - .assertNext(response -> assertConfigurationEquals(updated2, response)) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated2, response)) + .assertNext(response -> assertConfigurationEquals(updated, response)) + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); // Verifies that we can select specific fields. - StepVerifier.create(client.listRevisions(new SettingSelector().setKeyFilter(keyName).setFields(SettingFields.KEY, SettingFields.ETAG))) - .assertNext(response -> validateListRevisions(updated2, response)) - .assertNext(response -> validateListRevisions(updated, response)) - .assertNext(response -> validateListRevisions(original, response)) - .verifyComplete(); + StepVerifier + .create(client.listRevisions( + new SettingSelector().setKeyFilter(keyName).setFields(SettingFields.KEY, SettingFields.ETAG))) + .assertNext(response -> validateListRevisions(updated2, response)) + .assertNext(response -> validateListRevisions(updated, response)) + .assertNext(response -> validateListRevisions(original, response)) + .verifyComplete(); // Verifies that we have revision list size greater than 0. The count number of revision changes. StepVerifier.create(client.listRevisions(null).count()) @@ -1153,7 +1168,9 @@ public void listRevisionsWithMultipleLabels(HttpClient httpClient, Configuration .assertNext(response -> assertConfigurationEquals(testInput.get(3), response)) .verifyComplete(); - StepVerifier.create(client.listRevisions(new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2))) + StepVerifier + .create( + client.listRevisions(new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2))) .consumeNextWith(selected::add) .consumeNextWith(selected::add) .consumeNextWith(selected::add) @@ -1173,34 +1190,38 @@ public void listRevisionsAcceptDateTime(HttpClient httpClient, ConfigurationServ client = getConfigurationAsyncClient(httpClient, serviceVersion); final String keyName = testResourceNamer.randomName(keyPrefix, 16); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. StepVerifier.create(client.setConfigurationSettingWithResponse(original, false)) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); - StepVerifier.create(client.setConfigurationSettingWithResponse(updated, false).delayElement(Duration.ofSeconds(2))) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); + StepVerifier + .create(client.setConfigurationSettingWithResponse(updated, false).delayElement(Duration.ofSeconds(2))) + .assertNext(response -> assertConfigurationEquals(updated, response)) + .verifyComplete(); StepVerifier.create(client.setConfigurationSettingWithResponse(updated2, false)) - .assertNext(response -> assertConfigurationEquals(updated2, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated2, response)) + .verifyComplete(); // Gets all versions of this value. - List revisions = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).collectList().block(); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).collectList().block(); assertNotNull(revisions); assertEquals(3, revisions.size()); // We want to fetch all the revisions that existed up and including when the first revision was created. // Revisions are returned in descending order from creation date. - SettingSelector options = new SettingSelector().setKeyFilter(keyName) - .setAcceptDatetime(revisions.get(1).getLastModified()); + SettingSelector options + = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); StepVerifier.create(client.listRevisions(options)) - .assertNext(response -> assertConfigurationEquals(updated, response)) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(updated, response)) + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); } /** @@ -1214,19 +1235,16 @@ public void listRevisionsWithPagination(HttpClient httpClient, ConfigurationServ final int numberExpected = 50; List settings = new ArrayList<>(numberExpected); for (int value = 0; value < numberExpected; value++) { - settings.add(new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix)); + settings + .add(new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix)); } for (ConfigurationSetting setting : settings) { - StepVerifier.create(client.setConfigurationSetting(setting)) - .expectNextCount(1) - .verifyComplete(); + StepVerifier.create(client.setConfigurationSetting(setting)).expectNextCount(1).verifyComplete(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix).setLabelFilter(labelPrefix); - StepVerifier.create(client.listRevisions(filter)) - .expectNextCount(numberExpected) - .verifyComplete(); + StepVerifier.create(client.listRevisions(filter)).expectNextCount(numberExpected).verifyComplete(); } /** @@ -1235,16 +1253,16 @@ public void listRevisionsWithPagination(HttpClient httpClient, ConfigurationServ */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final int numberExpected = 50; List settings = new ArrayList<>(numberExpected); for (int value = 0; value < numberExpected; value++) { - ConfigurationSetting setting = new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix); + ConfigurationSetting setting + = new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix); settings.add(setting); - StepVerifier.create(client.setConfigurationSetting(setting)) - .expectNextCount(1) - .verifyComplete(); + StepVerifier.create(client.setConfigurationSetting(setting)).expectNextCount(1).verifyComplete(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix).setLabelFilter(labelPrefix); @@ -1265,12 +1283,14 @@ public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, Co */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final int numberExpected = 50; List settings = new ArrayList<>(numberExpected); for (int value = 0; value < numberExpected; value++) { - ConfigurationSetting setting = new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix); + ConfigurationSetting setting + = new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix); settings.add(setting); StepVerifier.create(client.setConfigurationSetting(setting)).expectNextCount(1).verifyComplete(); } @@ -1294,12 +1314,14 @@ public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, @Disabled("Error code 403 TOO_MANY_REQUESTS https://github.com/Azure/azure-sdk-for-java/issues/36602") @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsWithPagination(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsWithPagination(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final int numberExpected = 50; List settings = new ArrayList<>(numberExpected); for (int value = 0; value < numberExpected; value++) { - settings.add(new ConfigurationSetting().setKey(keyPrefix + "-" + value).setValue("myValue").setLabel(labelPrefix)); + settings.add( + new ConfigurationSetting().setKey(keyPrefix + "-" + value).setValue("myValue").setLabel(labelPrefix)); } for (ConfigurationSetting setting : settings) { @@ -1308,9 +1330,7 @@ public void listConfigurationSettingsWithPagination(HttpClient httpClient, Confi SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix + "-*").setLabelFilter(labelPrefix); - StepVerifier.create(client.listConfigurationSettings(filter)) - .expectNextCount(numberExpected) - .verifyComplete(); + StepVerifier.create(client.listConfigurationSettings(filter)).expectNextCount(numberExpected).verifyComplete(); } /** @@ -1319,7 +1339,8 @@ public void listConfigurationSettingsWithPagination(HttpClient httpClient, Confi */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void getConfigurationSettingWhenValueNotUpdated(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void getConfigurationSettingWhenValueNotUpdated(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final String key = getKey(); final ConfigurationSetting expected = new ConfigurationSetting().setKey(key).setValue("myValue"); @@ -1348,11 +1369,11 @@ public void getConfigurationSettingWhenValueNotUpdated(HttpClient httpClient, Co @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void deleteAllSettings(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); - client.listConfigurationSettings(new SettingSelector().setKeyFilter("*")) - .flatMap(configurationSetting -> { - logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isReadOnly()); - return client.deleteConfigurationSettingWithResponse(configurationSetting, false); - }).blockLast(); + client.listConfigurationSettings(new SettingSelector().setKeyFilter("*")).flatMap(configurationSetting -> { + logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), + configurationSetting.getLabel(), configurationSetting.isReadOnly()); + return client.deleteConfigurationSettingWithResponse(configurationSetting, false); + }).blockLast(); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -1360,14 +1381,14 @@ public void deleteAllSettings(HttpClient httpClient, ConfigurationServiceVersion public void addHeadersFromContextPolicyTest(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); final HttpHeaders headers = getCustomizedHeaders(); - addHeadersFromContextPolicyRunner(expected -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected) + addHeadersFromContextPolicyRunner(expected -> StepVerifier + .create(client.addConfigurationSettingWithResponse(expected) .contextWrite(Context.of(AddHeadersFromContextPolicy.AZURE_REQUEST_HTTP_HEADERS_KEY, headers))) - .assertNext(response -> { - final HttpHeaders requestHeaders = response.getRequest().getHeaders(); - assertContainsHeaders(headers, requestHeaders); - }) - .verifyComplete()); + .assertNext(response -> { + final HttpHeaders requestHeaders = response.getRequest().getHeaders(); + assertContainsHeaders(headers, requestHeaders); + }) + .verifyComplete()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -1375,17 +1396,17 @@ public void addHeadersFromContextPolicyTest(HttpClient httpClient, Configuration public void createSnapshot(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1399,22 +1420,23 @@ public void createSnapshot(HttpClient httpClient, ConfigurationServiceVersion se .verifyComplete(); }); } + @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void getSnapshot(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1423,7 +1445,8 @@ public void getSnapshot(HttpClient httpClient, ConfigurationServiceVersion servi MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Retrieve a snapshot after creation - StepVerifier.create(client.getSnapshotWithResponse(name, + StepVerifier + .create(client.getSnapshotWithResponse(name, Arrays.asList(SnapshotFields.NAME, SnapshotFields.STATUS, SnapshotFields.FILTERS))) .assertNext(getSnapshot -> { assertEquals(200, getSnapshot.getStatusCode()); @@ -1453,17 +1476,17 @@ public void getSnapshot(HttpClient httpClient, ConfigurationServiceVersion servi public void getSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1489,17 +1512,17 @@ public void getSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVe public void archiveSnapshot(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1508,11 +1531,12 @@ public void archiveSnapshot(HttpClient httpClient, ConfigurationServiceVersion s MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot, it will be deleted automatically when retention period expires. - StepVerifier.create(client.archiveSnapshotWithResponse(snapshotResult.getName(), - new MatchConditions().setIfMatch(snapshotResult.getETag()))) - .assertNext(response -> assertConfigurationSnapshotWithResponse(200, name, - ConfigurationSnapshotStatus.ARCHIVED, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) + StepVerifier + .create(client.archiveSnapshotWithResponse(snapshotResult.getName(), + new MatchConditions().setIfMatch(snapshotResult.getETag()))) + .assertNext( + response -> assertConfigurationSnapshotWithResponse(200, name, ConfigurationSnapshotStatus.ARCHIVED, + filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) .verifyComplete(); }); } @@ -1522,17 +1546,17 @@ public void archiveSnapshot(HttpClient httpClient, ConfigurationServiceVersion s public void archiveSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1553,17 +1577,17 @@ public void archiveSnapshotConvenience(HttpClient httpClient, ConfigurationServi public void recoverSnapshot(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1577,11 +1601,12 @@ public void recoverSnapshot(HttpClient httpClient, ConfigurationServiceVersion s .verifyComplete(); // Recover the snapshot, it will be deleted automatically when retention period expires. - StepVerifier.create(client.recoverSnapshotWithResponse(snapshotResult.getName(), + StepVerifier + .create(client.recoverSnapshotWithResponse(snapshotResult.getName(), new MatchConditions().setIfMatch(snapshotResult.getETag()))) - .assertNext(response -> assertConfigurationSnapshotWithResponse(200, name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) + .assertNext( + response -> assertConfigurationSnapshotWithResponse(200, name, ConfigurationSnapshotStatus.READY, + filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) .verifyComplete(); // Archived the snapshot, it will be deleted automatically when retention period expires. @@ -1596,17 +1621,17 @@ public void recoverSnapshot(HttpClient httpClient, ConfigurationServiceVersion s public void recoverSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationAsyncClient(httpClient, serviceVersion); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1621,9 +1646,8 @@ public void recoverSnapshotConvenience(HttpClient httpClient, ConfigurationServi // Recover the snapshot, it will be deleted automatically when retention period expires. StepVerifier.create(client.recoverSnapshot(name)) - .assertNext(response -> assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) + .assertNext(response -> assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, + filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response)) .verifyComplete(); // Archived the snapshot, it will be deleted automatically when retention period expires. @@ -1643,8 +1667,8 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser .blockLast(); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); @@ -1652,10 +1676,10 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // Create first snapshot createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1667,16 +1691,15 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // Create second snapshot createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); - assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, + assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot @@ -1688,8 +1711,7 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // readySnapshots contains only 1 snapshot ConfigurationSnapshot readySnapshot = readySnapshots.get(0); // List only the snapshot with a specific name - StepVerifier.create(client.listSnapshots( - new SnapshotSelector().setNameFilter(readySnapshot.getName()))) + StepVerifier.create(client.listSnapshots(new SnapshotSelector().setNameFilter(readySnapshot.getName()))) .assertNext(snapshotWithName -> { assertEquals(readySnapshot.getName(), snapshotWithName.getName()); assertEquals(readySnapshot.getStatus(), snapshotWithName.getStatus()); @@ -1713,8 +1735,8 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV .blockLast(); // Prepare a setting before creating a snapshot - addConfigurationSettingRunner((expected) -> - StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) + addConfigurationSettingRunner( + (expected) -> StepVerifier.create(client.addConfigurationSettingWithResponse(expected)) .assertNext(response -> assertConfigurationEquals(expected, response)) .verifyComplete()); @@ -1722,10 +1744,10 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // Create first snapshot createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1737,16 +1759,15 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // Create second snapshot createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); - assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, + assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot @@ -1758,11 +1779,9 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // readySnapshots contains only 1 snapshot ConfigurationSnapshot readySnapshot = readySnapshots.get(0); // List only the snapshot with a specific name - StepVerifier.create(client.listSnapshots( - new SnapshotSelector() - .setNameFilter(readySnapshot.getName()) - .setFields(SnapshotFields.NAME, SnapshotFields.FILTERS, SnapshotFields.STATUS) - )) + StepVerifier + .create(client.listSnapshots(new SnapshotSelector().setNameFilter(readySnapshot.getName()) + .setFields(SnapshotFields.NAME, SnapshotFields.FILTERS, SnapshotFields.STATUS))) .assertNext(snapshotFieldFiltered -> { assertEquals(readySnapshot.getName(), snapshotFieldFiltered.getName()); assertNotNull(snapshotFieldFiltered.getFilters()); @@ -1806,10 +1825,10 @@ public void listSettingFromSnapshot(HttpClient httpClient, ConfigurationServiceV .verifyComplete(); // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1849,10 +1868,10 @@ public void listSettingFromSnapshotWithFields(HttpClient httpClient, Configurati .verifyComplete(); // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1861,8 +1880,7 @@ public void listSettingFromSnapshotWithFields(HttpClient httpClient, Configurati MINIMUM_RETENTION_PERIOD, 15000L, (long) numberExpected, null, snapshotResult); StepVerifier.create(client.listConfigurationSettingsForSnapshot(name, - Arrays.asList(SettingFields.KEY, SettingFields.VALUE))) - .assertNext(setting -> { + Arrays.asList(SettingFields.KEY, SettingFields.VALUE))).assertNext(setting -> { assertNotNull(setting.getKey()); assertNotNull(setting.getValue()); assertNull(setting.getLabel()); @@ -1871,9 +1889,7 @@ public void listSettingFromSnapshotWithFields(HttpClient httpClient, Configurati assertNull(setting.getETag()); assertFalse(setting.isReadOnly()); assertTrue(setting.getTags().isEmpty()); - }) - .expectNextCount(numberExpected - 1) - .verifyComplete(); + }).expectNextCount(numberExpected - 1).verifyComplete(); // Archived the snapshot, it will be deleted automatically when retention period expires. StepVerifier.create(client.archiveSnapshot(name)) @@ -1889,8 +1905,8 @@ public void listSettingsWithPageETag(HttpClient httpClient, ConfigurationService // Step 1: Prepare testing data. // Clean all existing settings before this test purpose client.listConfigurationSettings(null) - .flatMap(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)) - .blockLast(); + .flatMap(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)) + .blockLast(); // Add a few setting to form a page of settings final ConfigurationSetting setting = new ConfigurationSetting().setKey(getKey()).setValue("value"); @@ -1900,36 +1916,41 @@ public void listSettingsWithPageETag(HttpClient httpClient, ConfigurationService // Get all page ETags List matchConditionsList = new ArrayList<>(); PagedResponse pagedResponse = client.listConfigurationSettings(null).byPage().blockLast(); - matchConditionsList.add(new MatchConditions().setIfNoneMatch(pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG))); + matchConditionsList + .add(new MatchConditions().setIfNoneMatch(pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG))); // Step 2: Test list settings with page ETag // Validation 1: Validate all pages are not modified and return empty list of settings in each page response. // List settings with page ETag - StepVerifier.create(client.listConfigurationSettings( - new SettingSelector().setMatchConditions(matchConditionsList)).byPage()) - .assertNext(response -> { - // No changes on the server side, so the response should be empty list - assertEquals(0, response.getValue().size()); - }).verifyComplete(); + StepVerifier + .create(client.listConfigurationSettings(new SettingSelector().setMatchConditions(matchConditionsList)) + .byPage()) + .assertNext(response -> { + // No changes on the server side, so the response should be empty list + assertEquals(0, response.getValue().size()); + }) + .verifyComplete(); // Validation 2: validate the page has the updated setting should be returned // Update a setting - final ConfigurationSetting updatedSetting = new ConfigurationSetting().setKey(setting.getKey()).setValue("new value"); + final ConfigurationSetting updatedSetting + = new ConfigurationSetting().setKey(setting.getKey()).setValue("new value"); client.setConfigurationSetting(updatedSetting).block(); // List settings with expired page ETag - StepVerifier.create(client.listConfigurationSettings( - new SettingSelector().setMatchConditions(matchConditionsList)) + StepVerifier + .create(client.listConfigurationSettings(new SettingSelector().setMatchConditions(matchConditionsList)) .byPage()) - .assertNext(response -> { - // The page has the updated setting should be returned, so the response should not be empty list - assertFalse(response.getValue().isEmpty()); - // find the updated setting in the list - ConfigurationSetting updatedSettingFromResponse = response.getValue() - .stream() - .filter(s -> s.getKey().equals(updatedSetting.getKey())) - .findAny() - .get(); - assertConfigurationEquals(updatedSetting, updatedSettingFromResponse); - }).verifyComplete(); + .assertNext(response -> { + // The page has the updated setting should be returned, so the response should not be empty list + assertFalse(response.getValue().isEmpty()); + // find the updated setting in the list + ConfigurationSetting updatedSettingFromResponse = response.getValue() + .stream() + .filter(s -> s.getKey().equals(updatedSetting.getKey())) + .findAny() + .get(); + assertConfigurationEquals(updatedSetting, updatedSettingFromResponse); + }) + .verifyComplete(); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -1938,37 +1959,34 @@ public void listLabels(HttpClient httpClient, ConfigurationServiceVersion servic client = getConfigurationAsyncClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose StepVerifier.create(client.listConfigurationSettings(null) - .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) - .then()) - .verifyComplete(); + .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) + .then()).verifyComplete(); // Prepare two settings with different labels - List preparedSettings = listLabelsRunner(setting -> - StepVerifier.create(client.addConfigurationSettingWithResponse(setting)) - .assertNext(response -> assertConfigurationEquals(setting, response)) - .verifyComplete()); + List preparedSettings + = listLabelsRunner(setting -> StepVerifier.create(client.addConfigurationSettingWithResponse(setting)) + .assertNext(response -> assertConfigurationEquals(setting, response)) + .verifyComplete()); ConfigurationSetting setting = preparedSettings.get(0); ConfigurationSetting setting2 = preparedSettings.get(1); // List only the first label var, 'label' String label = setting.getLabel(); StepVerifier.create(client.listLabels(new SettingLabelSelector().setNameFilter(label))) - .assertNext(actual -> assertEquals(label, actual.getName())) - .verifyComplete(); + .assertNext(actual -> assertEquals(label, actual.getName())) + .verifyComplete(); // List labels with wildcard label filter String label2 = setting2.getLabel(); StepVerifier.create(client.listLabels(new SettingLabelSelector().setNameFilter("label*")) - .map(SettingLabel::getName) - .collectList()) - .assertNext(actualLabels -> { + .map(SettingLabel::getName) + .collectList()).assertNext(actualLabels -> { assertTrue(actualLabels.contains(label)); assertTrue(actualLabels.contains(label2)); - }) - .verifyComplete(); + }).verifyComplete(); // List all labels List selected = new ArrayList<>(); StepVerifier.create(client.listLabels()) - .consumeNextWith(selected::add) - .consumeNextWith(selected::add) - .verifyComplete(); + .consumeNextWith(selected::add) + .consumeNextWith(selected::add) + .verifyComplete(); assertTrue(selected.size() >= 2); } @@ -1978,28 +1996,31 @@ public void listSettingByTagsFilter(HttpClient httpClient, ConfigurationServiceV client = getConfigurationAsyncClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose StepVerifier.create(client.listConfigurationSettings(null) - .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) - .then()) - .verifyComplete(); + .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) + .then()).verifyComplete(); // Prepare two settings with different tags List preparedSettings = listSettingByTagsFilterRunner(setting -> { StepVerifier.create(client.addConfigurationSettingWithResponse(setting)) - .assertNext(response -> assertConfigurationEquals(setting, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(setting, response)) + .verifyComplete(); }); ConfigurationSetting setting = preparedSettings.get(0); ConfigurationSetting setting2 = preparedSettings.get(1); // List setting by first tags filter, it should return all settings - StepVerifier.create(client.listConfigurationSettings(new SettingSelector().setTagsFilter(getTagsFilterInString(setting.getTags())))) - .assertNext(response -> assertConfigurationEquals(setting, response)) - .assertNext(response -> assertConfigurationEquals(setting2, response)) - .verifyComplete(); + StepVerifier + .create(client.listConfigurationSettings( + new SettingSelector().setTagsFilter(getTagsFilterInString(setting.getTags())))) + .assertNext(response -> assertConfigurationEquals(setting, response)) + .assertNext(response -> assertConfigurationEquals(setting2, response)) + .verifyComplete(); // List setting by second tags filter, it should return only one setting - StepVerifier.create(client.listConfigurationSettings(new SettingSelector().setTagsFilter(getTagsFilterInString(setting2.getTags())))) - .assertNext(response -> assertConfigurationEquals(setting2, response)) - .verifyComplete(); + StepVerifier + .create(client.listConfigurationSettings( + new SettingSelector().setTagsFilter(getTagsFilterInString(setting2.getTags())))) + .assertNext(response -> assertConfigurationEquals(setting2, response)) + .verifyComplete(); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -2009,19 +2030,18 @@ public void listRevisionsWithTagsFilter(HttpClient httpClient, ConfigurationServ // Create 3 revisions of the same key. List configurationSettings = listRevisionsWithTagsFilterRunner(setting -> { StepVerifier.create(client.setConfigurationSettingWithResponse(setting, false)) - .assertNext(response -> assertConfigurationEquals(setting, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(setting, response)) + .verifyComplete(); }); ConfigurationSetting original = configurationSettings.get(0); // Get all revisions for a key with tags filter, they are listed in descending order. - StepVerifier.create(client.listRevisions( - new SettingSelector() - .setKeyFilter(original.getKey()) - .setTagsFilter(getTagsFilterInString(original.getTags())))) - .assertNext(response -> assertConfigurationEquals(original, response)) - .verifyComplete(); + StepVerifier + .create(client.listRevisions(new SettingSelector().setKeyFilter(original.getKey()) + .setTagsFilter(getTagsFilterInString(original.getTags())))) + .assertNext(response -> assertConfigurationEquals(original, response)) + .verifyComplete(); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -2030,15 +2050,14 @@ public void createSnapshotWithTagsFilter(HttpClient httpClient, ConfigurationSer client = getConfigurationAsyncClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose StepVerifier.create(client.listConfigurationSettings(null) - .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) - .then()) - .verifyComplete(); + .flatMap(setting -> client.deleteConfigurationSettingWithResponse(setting, false)) + .then()).verifyComplete(); // Prepare settings before creating a snapshot List settings = createSnapshotWithTagsFilterPrepareRunner(setting -> { StepVerifier.create(client.addConfigurationSettingWithResponse(setting)) - .assertNext(response -> assertConfigurationEquals(setting, response)) - .verifyComplete(); + .assertNext(response -> assertConfigurationEquals(setting, response)) + .verifyComplete(); }); ConfigurationSetting setting = settings.get(0); ConfigurationSetting settingWithTag = settings.get(1); @@ -2047,10 +2066,10 @@ public void createSnapshotWithTagsFilter(HttpClient httpClient, ConfigurationSer createSnapshotWithTagsFilterRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot).getSyncPoller(); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot).getSyncPoller(); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -2058,12 +2077,12 @@ public void createSnapshotWithTagsFilter(HttpClient httpClient, ConfigurationSer // The snapshot should only contain the setting with tags StepVerifier.create(client.listConfigurationSettingsForSnapshot(name)) - .assertNext(actual -> assertEquals(settingWithTag.getTags(), actual.getTags())) - .verifyComplete(); + .assertNext(actual -> assertEquals(settingWithTag.getTags(), actual.getTags())) + .verifyComplete(); // Archived the snapshot, it will be deleted automatically when retention period expires. StepVerifier.create(client.archiveSnapshot(name)) - .assertNext(response -> assertEquals(ConfigurationSnapshotStatus.ARCHIVED, response.getStatus())) - .verifyComplete(); + .assertNext(response -> assertEquals(ConfigurationSnapshotStatus.ARCHIVED, response.getStatus())) + .verifyComplete(); }); } @@ -2074,8 +2093,8 @@ public void createSnapshotWithTagsFilter(HttpClient httpClient, ConfigurationSer * @param labelFilter label filter expression */ private void filterValueTest(String keyFilter, String labelFilter) { - listConfigurationSettingsSelectFieldsWithNotSupportedFilterRunner(keyFilter, labelFilter, selector -> - StepVerifier.create(client.listConfigurationSettings(selector)) + listConfigurationSettingsSelectFieldsWithNotSupportedFilterRunner(keyFilter, labelFilter, + selector -> StepVerifier.create(client.listConfigurationSettings(selector)) .verifyError(HttpResponseException.class)); } } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientBuilderTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientBuilderTest.java index 13b6c5095801f..88feb9f969662 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientBuilderTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientBuilderTest.java @@ -48,8 +48,8 @@ public class ConfigurationClientBuilderTest extends TestProxyTestBase { private static final String NAMESPACE_NAME = "dummyNamespaceName"; private final String key = "newKey"; private final String value = "newValue"; - private static final String ENDPOINT = getURI(ClientConstants.ENDPOINT_FORMAT, NAMESPACE_NAME, DEFAULT_DOMAIN_NAME).toString(); - + private static final String ENDPOINT + = getURI(ClientConstants.ENDPOINT_FORMAT, NAMESPACE_NAME, DEFAULT_DOMAIN_NAME).toString(); @Test @DoNotRecord @@ -65,8 +65,7 @@ public void missingEndpoint() { public void clientMissingEndpointButTokenCredentialProvided() { assertThrows(NullPointerException.class, () -> { final ConfigurationClientBuilder builder = new ConfigurationClientBuilder(); - TokenCredential credentials = request -> Mono.just( - new AccessToken("this_is_a_token", OffsetDateTime.MAX)); + TokenCredential credentials = request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)); builder.credential(credentials).buildClient(); }); } @@ -113,8 +112,7 @@ public void multipleCredentialsExist() { assertThrows(IllegalArgumentException.class, () -> { final ConfigurationClientBuilder builder = new ConfigurationClientBuilder(); TokenCredential credentials = request -> Mono.just(new AccessToken("this_is_a_token", OffsetDateTime.MAX)); - builder.connectionString(FAKE_CONNECTION_STRING) - .credential(credentials).buildClient(); + builder.connectionString(FAKE_CONNECTION_STRING).credential(credentials).buildClient(); }); } @@ -157,10 +155,10 @@ public void nullAADCredential() { @Test @DoNotRecord public void timeoutPolicy() { - final ConfigurationClient client = new ConfigurationClientBuilder() - .connectionString(FAKE_CONNECTION_STRING) + final ConfigurationClient client = new ConfigurationClientBuilder().connectionString(FAKE_CONNECTION_STRING) .retryOptions(new RetryOptions(new FixedDelayOptions(0, Duration.ofMillis(1)))) - .addPolicy(new TimeoutPolicy(Duration.ofMillis(1))).buildClient(); + .addPolicy(new TimeoutPolicy(Duration.ofMillis(1))) + .buildClient(); assertThrows(RuntimeException.class, () -> client.setConfigurationSetting(key, null, value)); } @@ -168,11 +166,11 @@ public void timeoutPolicy() { @Test @DoNotRecord public void throwIfBothRetryOptionsAndRetryPolicyIsConfigured() { - final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder() - .connectionString(FAKE_CONNECTION_STRING) - .retryOptions(new RetryOptions(new ExponentialBackoffOptions())) - .retryPolicy(new RetryPolicy()) - .addPolicy(new TimeoutPolicy(Duration.ofMillis(1))); + final ConfigurationClientBuilder clientBuilder + = new ConfigurationClientBuilder().connectionString(FAKE_CONNECTION_STRING) + .retryOptions(new RetryOptions(new ExponentialBackoffOptions())) + .retryPolicy(new RetryPolicy()) + .addPolicy(new TimeoutPolicy(Duration.ofMillis(1))); assertThrows(IllegalStateException.class, clientBuilder::buildClient); } @@ -189,8 +187,7 @@ public void nullServiceVersion(HttpClient httpClient) { Objects.requireNonNull(tokenCredential, "tokenCredential expected to be set."); Objects.requireNonNull(endpoint, "endpoint expected to be set."); - final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder() - .credential(tokenCredential) + final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder().credential(tokenCredential) .endpoint(endpoint) .retryPolicy(new RetryPolicy()) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)) @@ -200,9 +197,7 @@ public void nullServiceVersion(HttpClient httpClient) { clientBuilder.httpClient(interceptorManager.getPlaybackClient()); } if (interceptorManager.isRecordMode()) { - clientBuilder - .httpClient(httpClient) - .addPolicy(interceptorManager.getRecordPolicy()); + clientBuilder.httpClient(httpClient).addPolicy(interceptorManager.getRecordPolicy()); } // Disable `("$.key")` sanitizer if (!interceptorManager.isLiveMode()) { @@ -225,17 +220,14 @@ public void defaultPipeline() { Objects.requireNonNull(tokenCredential, "tokenCredential expected to be set."); Objects.requireNonNull(endpoint, "endpoint expected to be set."); - final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder() - .credential(tokenCredential) + final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder().credential(tokenCredential) .endpoint(endpoint) .retryPolicy(new RetryPolicy()) .configuration(Configuration.getGlobalConfiguration()) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); if (interceptorManager.isRecordMode()) { - clientBuilder - .addPolicy(interceptorManager.getRecordPolicy()) - .httpClient(HttpClient.createDefault()); + clientBuilder.addPolicy(interceptorManager.getRecordPolicy()).httpClient(HttpClient.createDefault()); } if (interceptorManager.isPlaybackMode()) { @@ -247,9 +239,7 @@ public void defaultPipeline() { interceptorManager.removeSanitizers("AZSDK3447"); } - ConfigurationSetting addedSetting = clientBuilder - .buildClient() - .setConfigurationSetting(key, null, value); + ConfigurationSetting addedSetting = clientBuilder.buildClient().setConfigurationSetting(key, null, value); assertEquals(addedSetting.getKey(), key); assertEquals(addedSetting.getValue(), value); @@ -258,16 +248,16 @@ public void defaultPipeline() { @Test @DoNotRecord public void clientOptionsIsPreferredOverLogOptions() { - ConfigurationClient configurationClient = new ConfigurationClientBuilder() - .connectionString(FAKE_CONNECTION_STRING) - .retryOptions(new RetryOptions(new FixedDelayOptions(0, Duration.ofMillis(1)))) - .httpLogOptions(new HttpLogOptions().setApplicationId("anOldApplication")) - .clientOptions(new ClientOptions().setApplicationId("aNewApplication")) - .httpClient(httpRequest -> { - assertTrue(httpRequest.getHeaders().getValue("User-Agent").contains("aNewApplication")); - return Mono.just(new MockHttpResponse(httpRequest, 400)); - }) - .buildClient(); + ConfigurationClient configurationClient + = new ConfigurationClientBuilder().connectionString(FAKE_CONNECTION_STRING) + .retryOptions(new RetryOptions(new FixedDelayOptions(0, Duration.ofMillis(1)))) + .httpLogOptions(new HttpLogOptions().setApplicationId("anOldApplication")) + .clientOptions(new ClientOptions().setApplicationId("aNewApplication")) + .httpClient(httpRequest -> { + assertTrue(httpRequest.getHeaders().getValue("User-Agent").contains("aNewApplication")); + return Mono.just(new MockHttpResponse(httpRequest, 400)); + }) + .buildClient(); assertThrows(HttpResponseException.class, () -> configurationClient.setConfigurationSetting(key, null, value)); } @@ -289,8 +279,8 @@ public void clientOptionHeadersAreAddedLast() { @Test @DoNotRecord public void getEndpointAtClientInstance() { - ConfigurationClientBuilder configurationClientBuilder = new ConfigurationClientBuilder() - .connectionString(FAKE_CONNECTION_STRING); + ConfigurationClientBuilder configurationClientBuilder + = new ConfigurationClientBuilder().connectionString(FAKE_CONNECTION_STRING); final ConfigurationClient client = configurationClientBuilder.buildClient(); final ConfigurationAsyncClient asyncClient = configurationClientBuilder.buildAsyncClient(); assertEquals("https://localhost:8080", client.getEndpoint()); @@ -301,8 +291,8 @@ private static URI getURI(String endpointFormat, String namespace, String domain try { return new URI(String.format(Locale.US, endpointFormat, namespace, domainName)); } catch (URISyntaxException exception) { - throw new IllegalArgumentException(String.format(Locale.US, - "Invalid namespace name: %s", namespace), exception); + throw new IllegalArgumentException(String.format(Locale.US, "Invalid namespace name: %s", namespace), + exception); } } } 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 52ff17329b652..af75a69489676 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 @@ -63,13 +63,15 @@ protected void beforeTest() { @Override protected void afterTest() { logger.info("Cleaning up created key values."); - client.listConfigurationSettings(new SettingSelector().setKeyFilter(keyPrefix + "*")).forEach(configurationSetting -> { - logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isReadOnly()); - if (configurationSetting.isReadOnly()) { - client.setReadOnlyWithResponse(configurationSetting, false, Context.NONE); - } - client.deleteConfigurationSettingWithResponse(configurationSetting, false, Context.NONE).getValue(); - }); + client.listConfigurationSettings(new SettingSelector().setKeyFilter(keyPrefix + "*")) + .forEach(configurationSetting -> { + logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), + configurationSetting.getLabel(), configurationSetting.isReadOnly()); + if (configurationSetting.isReadOnly()) { + client.setReadOnlyWithResponse(configurationSetting, false, Context.NONE); + } + client.deleteConfigurationSettingWithResponse(configurationSetting, false, Context.NONE).getValue(); + }); logger.info("Finished cleaning up values."); } @@ -77,8 +79,7 @@ protected void afterTest() { private ConfigurationClient getConfigurationClient(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { return clientSetup((credentials, endpoint) -> { - ConfigurationClientBuilder builder = new ConfigurationClientBuilder() - .credential(credentials) + ConfigurationClientBuilder builder = new ConfigurationClientBuilder().credential(credentials) .endpoint(endpoint) .serviceVersion(serviceVersion); @@ -107,9 +108,7 @@ private ConfigurationClientBuilder setHttpClient(HttpClient httpClient, Configur } private HttpClient buildSyncAssertingClient(HttpClient httpClient) { - return new AssertingHttpClientBuilder(httpClient) - .assertSync() - .build(); + return new AssertingHttpClientBuilder(httpClient).assertSync().build(); } /** @@ -127,8 +126,8 @@ public void addConfigurationSetting(HttpClient httpClient, ConfigurationServiceV @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - addConfigurationSettingRunner((expected) -> assertConfigurationEquals(expected, - client.addConfigurationSetting(expected))); + addConfigurationSettingRunner( + (expected) -> assertConfigurationEquals(expected, client.addConfigurationSetting(expected))); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -145,9 +144,8 @@ public void addFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, public void addSecretReferenceConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - addSecretReferenceConfigurationSettingRunner( - (expected) -> assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) client.addConfigurationSetting(expected))); + addSecretReferenceConfigurationSettingRunner((expected) -> assertSecretReferenceConfigurationSettingEquals( + expected, (SecretReferenceConfigurationSetting) client.addConfigurationSetting(expected))); } /** @@ -157,7 +155,8 @@ public void addSecretReferenceConfigurationSettingConvenience(HttpClient httpCli @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addConfigurationSettingEmptyKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - assertRestException(() -> client.addConfigurationSetting("", null, "A value"), HttpURLConnection.HTTP_BAD_METHOD); + assertRestException(() -> client.addConfigurationSetting("", null, "A value"), + HttpURLConnection.HTTP_BAD_METHOD); } /** @@ -168,7 +167,8 @@ public void addConfigurationSettingEmptyKey(HttpClient httpClient, Configuration public void addConfigurationSettingEmptyValue(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); addConfigurationSettingEmptyValueRunner((setting) -> { - assertConfigurationEquals(setting, client.addConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())); + assertConfigurationEquals(setting, + client.addConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())); assertConfigurationEquals(setting, client.getConfigurationSetting(setting.getKey(), setting.getLabel())); }); } @@ -180,8 +180,10 @@ public void addConfigurationSettingEmptyValue(HttpClient httpClient, Configurati @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void addConfigurationSettingNullKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - assertRunnableThrowsException(() -> client.addConfigurationSetting(null, null, "A Value"), IllegalArgumentException.class); - assertRunnableThrowsException(() -> client.addConfigurationSettingWithResponse(null, Context.NONE), NullPointerException.class); + assertRunnableThrowsException(() -> client.addConfigurationSetting(null, null, "A Value"), + IllegalArgumentException.class); + assertRunnableThrowsException(() -> client.addConfigurationSettingWithResponse(null, Context.NONE), + NullPointerException.class); } /** @@ -206,15 +208,13 @@ public void addExistingSetting(HttpClient httpClient, ConfigurationServiceVersio @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void setConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - setConfigurationSettingRunner( - (expected, update) -> assertConfigurationEquals(expected, - client.setConfigurationSettingWithResponse(expected, false, Context.NONE).getValue())); + setConfigurationSettingRunner((expected, update) -> assertConfigurationEquals(expected, + client.setConfigurationSettingWithResponse(expected, false, Context.NONE).getValue())); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void setConfigurationSettingConvenience(HttpClient httpClient, - ConfigurationServiceVersion serviceVersion) { + public void setConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); setConfigurationSettingRunner( (expected, update) -> assertConfigurationEquals(expected, client.setConfigurationSetting(expected))); @@ -225,9 +225,8 @@ public void setConfigurationSettingConvenience(HttpClient httpClient, public void setFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - setFeatureFlagConfigurationSettingRunner( - (expected, update) -> assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) client.setConfigurationSetting(expected))); + setFeatureFlagConfigurationSettingRunner((expected, update) -> assertFeatureFlagConfigurationSettingEquals( + expected, (FeatureFlagConfigurationSetting) client.setConfigurationSetting(expected))); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -235,19 +234,18 @@ public void setFeatureFlagConfigurationSettingConvenience(HttpClient httpClient, public void featureFlagConfigurationSettingUnknownAttributesArePreserved(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - featureFlagConfigurationSettingUnknownAttributesArePreservedRunner( - (expected) -> { - assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) client.addConfigurationSetting(expected)); - assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) client.setConfigurationSetting(expected)); - assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) client.getConfigurationSetting(expected)); - assertFeatureFlagConfigurationSettingEquals(expected, - (FeatureFlagConfigurationSetting) client.deleteConfigurationSetting(expected)); - assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), - HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); - }); + featureFlagConfigurationSettingUnknownAttributesArePreservedRunner((expected) -> { + assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) client.addConfigurationSetting(expected)); + assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) client.setConfigurationSetting(expected)); + assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) client.getConfigurationSetting(expected)); + assertFeatureFlagConfigurationSettingEquals(expected, + (FeatureFlagConfigurationSetting) client.deleteConfigurationSetting(expected)); + assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + }); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -265,19 +263,18 @@ public void setSecretReferenceConfigurationSettingConvenience(HttpClient httpCli public void secretReferenceConfigurationSettingUnknownAttributesArePreserved(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - secretReferenceConfigurationSettingUnknownAttributesArePreservedRunner( - (expected) -> { - assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) client.addConfigurationSetting(expected)); - assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) client.setConfigurationSetting(expected)); - assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) client.getConfigurationSetting(expected)); - assertSecretReferenceConfigurationSettingEquals(expected, - (SecretReferenceConfigurationSetting) client.deleteConfigurationSetting(expected)); - assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), - HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); - }); + secretReferenceConfigurationSettingUnknownAttributesArePreservedRunner((expected) -> { + assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) client.addConfigurationSetting(expected)); + assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) client.setConfigurationSetting(expected)); + assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) client.getConfigurationSetting(expected)); + assertSecretReferenceConfigurationSettingEquals(expected, + (SecretReferenceConfigurationSetting) client.deleteConfigurationSetting(expected)); + assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + }); } /** @@ -291,14 +288,18 @@ public void setConfigurationSettingIfETag(HttpClient httpClient, ConfigurationSe client = getConfigurationClient(httpClient, serviceVersion); setConfigurationSettingIfETagRunner((initial, update) -> { // This ETag is not the correct format. It is not the correct hash that the service is expecting. - assertRestException(() -> client.setConfigurationSettingWithResponse(initial.setETag("badETag"), - true, Context.NONE).getValue(), HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); + assertRestException( + () -> client.setConfigurationSettingWithResponse(initial.setETag("badETag"), true, Context.NONE) + .getValue(), + HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); final String etag = client.addConfigurationSettingWithResponse(initial, Context.NONE).getValue().getETag(); - assertConfigurationEquals(update, client.setConfigurationSettingWithResponse(update.setETag(etag), true, Context.NONE)); - assertRestException(() -> client.setConfigurationSettingWithResponse(initial, true, Context.NONE) - .getValue(), HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); + assertConfigurationEquals(update, + client.setConfigurationSettingWithResponse(update.setETag(etag), true, Context.NONE)); + assertRestException( + () -> client.setConfigurationSettingWithResponse(initial, true, Context.NONE).getValue(), + HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); assertConfigurationEquals(update, client.getConfigurationSetting(update.getKey(), update.getLabel())); }); } @@ -310,7 +311,8 @@ public void setConfigurationSettingIfETag(HttpClient httpClient, ConfigurationSe @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void setConfigurationSettingEmptyKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - assertRestException(() -> client.setConfigurationSetting("", null, "A value"), HttpURLConnection.HTTP_BAD_METHOD); + assertRestException(() -> client.setConfigurationSetting("", null, "A value"), + HttpURLConnection.HTTP_BAD_METHOD); } /** @@ -322,7 +324,8 @@ public void setConfigurationSettingEmptyKey(HttpClient httpClient, Configuration public void setConfigurationSettingEmptyValue(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); setConfigurationSettingEmptyValueRunner((setting) -> { - assertConfigurationEquals(setting, client.setConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())); + assertConfigurationEquals(setting, + client.setConfigurationSetting(setting.getKey(), setting.getLabel(), setting.getValue())); assertConfigurationEquals(setting, client.getConfigurationSetting(setting.getKey(), setting.getLabel())); }); } @@ -334,8 +337,11 @@ public void setConfigurationSettingEmptyValue(HttpClient httpClient, Configurati @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void setConfigurationSettingNullKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - assertRunnableThrowsException(() -> client.setConfigurationSetting(null, null, "A Value"), IllegalArgumentException.class); - assertRunnableThrowsException(() -> client.setConfigurationSettingWithResponse(null, false, Context.NONE).getValue(), NullPointerException.class); + assertRunnableThrowsException(() -> client.setConfigurationSetting(null, null, "A Value"), + IllegalArgumentException.class); + assertRunnableThrowsException( + () -> client.setConfigurationSettingWithResponse(null, false, Context.NONE).getValue(), + NullPointerException.class); } /** @@ -393,13 +399,19 @@ public void getSecretReferenceConfigurationSettingConvenience(HttpClient httpCli public void getConfigurationSettingNotFound(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final String key = getKey(); - final ConfigurationSetting neverRetrievedConfiguration = new ConfigurationSetting().setKey(key).setValue("myNeverRetreivedValue"); - final ConfigurationSetting nonExistentLabel = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); + final ConfigurationSetting neverRetrievedConfiguration + = new ConfigurationSetting().setKey(key).setValue("myNeverRetreivedValue"); + final ConfigurationSetting nonExistentLabel + = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); - assertConfigurationEquals(neverRetrievedConfiguration, client.addConfigurationSettingWithResponse(neverRetrievedConfiguration, Context.NONE).getValue()); + assertConfigurationEquals(neverRetrievedConfiguration, + client.addConfigurationSettingWithResponse(neverRetrievedConfiguration, Context.NONE).getValue()); - assertRestException(() -> client.getConfigurationSetting("myNonExistentKey", null, null), HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); - assertRestException(() -> client.getConfigurationSetting(nonExistentLabel.getKey(), nonExistentLabel.getLabel()), HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + assertRestException(() -> client.getConfigurationSetting("myNonExistentKey", null, null), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + assertRestException( + () -> client.getConfigurationSetting(nonExistentLabel.getKey(), nonExistentLabel.getLabel()), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); } /** @@ -415,8 +427,10 @@ public void deleteConfigurationSetting(HttpClient httpClient, ConfigurationServi client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue(); assertConfigurationEquals(expected, client.getConfigurationSetting(expected.getKey(), expected.getLabel())); - assertConfigurationEquals(expected, client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE).getValue()); - assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + assertConfigurationEquals(expected, + client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE).getValue()); + assertRestException(() -> client.getConfigurationSetting(expected.getKey(), expected.getLabel()), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); }); } @@ -477,15 +491,21 @@ public void deleteSecretReferenceConfigurationSettingConvenience(HttpClient http public void deleteConfigurationSettingNotFound(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final String key = getKey(); - final ConfigurationSetting neverDeletedConfiguation = new ConfigurationSetting().setKey(key).setValue("myNeverDeletedValue"); - final ConfigurationSetting notFoundDelete = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); + final ConfigurationSetting neverDeletedConfiguation + = new ConfigurationSetting().setKey(key).setValue("myNeverDeletedValue"); + final ConfigurationSetting notFoundDelete + = new ConfigurationSetting().setKey(key).setLabel("myNonExistentLabel"); - assertConfigurationEquals(neverDeletedConfiguation, client.addConfigurationSettingWithResponse(neverDeletedConfiguation, Context.NONE).getValue()); + assertConfigurationEquals(neverDeletedConfiguation, + client.addConfigurationSettingWithResponse(neverDeletedConfiguation, Context.NONE).getValue()); assertConfigurationEquals(null, client.deleteConfigurationSetting("myNonExistentKey", null)); - assertConfigurationEquals(null, client.deleteConfigurationSettingWithResponse(notFoundDelete, false, Context.NONE), HttpURLConnection.HTTP_NO_CONTENT); + assertConfigurationEquals(null, + client.deleteConfigurationSettingWithResponse(notFoundDelete, false, Context.NONE), + HttpURLConnection.HTTP_NO_CONTENT); - assertConfigurationEquals(neverDeletedConfiguation, client.getConfigurationSetting(neverDeletedConfiguation.getKey(), neverDeletedConfiguation.getLabel())); + assertConfigurationEquals(neverDeletedConfiguation, + client.getConfigurationSetting(neverDeletedConfiguation.getKey(), neverDeletedConfiguation.getLabel())); } /** @@ -497,13 +517,20 @@ public void deleteConfigurationSettingNotFound(HttpClient httpClient, Configurat public void deleteConfigurationSettingWithETag(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); deleteConfigurationSettingWithETagRunner((initial, update) -> { - final ConfigurationSetting initiallyAddedConfig = client.addConfigurationSettingWithResponse(initial, Context.NONE).getValue(); - final ConfigurationSetting updatedConfig = client.setConfigurationSettingWithResponse(update, false, Context.NONE).getValue(); + final ConfigurationSetting initiallyAddedConfig + = client.addConfigurationSettingWithResponse(initial, Context.NONE).getValue(); + final ConfigurationSetting updatedConfig + = client.setConfigurationSettingWithResponse(update, false, Context.NONE).getValue(); assertConfigurationEquals(update, client.getConfigurationSetting(initial.getKey(), initial.getLabel())); - assertRestException(() -> client.deleteConfigurationSettingWithResponse(initiallyAddedConfig, true, Context.NONE).getValue(), HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); - assertConfigurationEquals(update, client.deleteConfigurationSettingWithResponse(updatedConfig, true, Context.NONE).getValue()); - assertRestException(() -> client.getConfigurationSetting(initial.getKey(), initial.getLabel()), HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); + assertRestException( + () -> client.deleteConfigurationSettingWithResponse(initiallyAddedConfig, true, Context.NONE) + .getValue(), + HttpResponseException.class, HttpURLConnection.HTTP_PRECON_FAILED); + assertConfigurationEquals(update, + client.deleteConfigurationSettingWithResponse(updatedConfig, true, Context.NONE).getValue()); + assertRestException(() -> client.getConfigurationSetting(initial.getKey(), initial.getLabel()), + HttpResponseException.class, HttpURLConnection.HTTP_NOT_FOUND); }); } @@ -514,8 +541,11 @@ public void deleteConfigurationSettingWithETag(HttpClient httpClient, Configurat @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") public void deleteConfigurationSettingNullKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); - assertRunnableThrowsException(() -> client.deleteConfigurationSetting(null, null), IllegalArgumentException.class); - assertRunnableThrowsException(() -> client.deleteConfigurationSettingWithResponse(null, false, Context.NONE).getValue(), NullPointerException.class); + assertRunnableThrowsException(() -> client.deleteConfigurationSetting(null, null), + IllegalArgumentException.class); + assertRunnableThrowsException( + () -> client.deleteConfigurationSettingWithResponse(null, false, Context.NONE).getValue(), + NullPointerException.class); } /** @@ -531,8 +561,7 @@ public void clearReadOnly(HttpClient httpClient, ConfigurationServiceVersion ser client.setReadOnlyWithResponse(expected, true, Context.NONE).getValue(); // unsuccessfully delete - assertRestException(() -> - client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE), + assertRestException(() -> client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE), HttpResponseException.class, 409); // clear read-only setting and delete @@ -549,7 +578,8 @@ public void clearReadOnly(HttpClient httpClient, ConfigurationServiceVersion ser */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void clearReadOnlyWithConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void clearReadOnlyWithConfigurationSetting(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); lockUnlockRunner((expected) -> { @@ -558,8 +588,7 @@ public void clearReadOnlyWithConfigurationSetting(HttpClient httpClient, Configu client.setReadOnlyWithResponse(expected, true, Context.NONE); // unsuccessfully deleted - assertRestException(() -> - client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE), + assertRestException(() -> client.deleteConfigurationSettingWithResponse(expected, false, Context.NONE), HttpResponseException.class, 409); // unlock setting and delete @@ -650,9 +679,14 @@ public void listWithKeyAndLabel(HttpClient httpClient, ConfigurationServiceVersi final String label = getLabel(); final ConfigurationSetting expected = new ConfigurationSetting().setKey(key).setValue(value).setLabel(label); - assertConfigurationEquals(expected, client.setConfigurationSettingWithResponse(expected, false, Context.NONE).getValue()); - assertConfigurationEquals(expected, client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label)).iterator().next()); - assertConfigurationEquals(expected, client.listConfigurationSettings(new SettingSelector().setKeyFilter(key)).iterator().next()); + assertConfigurationEquals(expected, + client.setConfigurationSettingWithResponse(expected, false, Context.NONE).getValue()); + assertConfigurationEquals(expected, + client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label)) + .iterator() + .next()); + assertConfigurationEquals(expected, + client.listConfigurationSettings(new SettingSelector().setKeyFilter(key)).iterator().next()); } /** @@ -667,8 +701,10 @@ public void listWithMultipleKeys(HttpClient httpClient, ConfigurationServiceVers String key2 = getKey(); listWithMultipleKeysRunner(key, key2, (setting, setting2) -> { - assertConfigurationEquals(setting, client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue()); - assertConfigurationEquals(setting2, client.addConfigurationSettingWithResponse(setting2, Context.NONE).getValue()); + assertConfigurationEquals(setting, + client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue()); + assertConfigurationEquals(setting2, + client.addConfigurationSettingWithResponse(setting2, Context.NONE).getValue()); return client.listConfigurationSettings(new SettingSelector().setKeyFilter(key + "," + key2)); }); @@ -694,8 +730,8 @@ public void listConfigurationSettingsWithNullSelector(HttpClient httpClient, assertConfigurationEquals(setting2, client.addConfigurationSettingWithResponse(setting2, Context.NONE).getValue()); - final PagedIterable configurationSettingIterable = - client.listConfigurationSettings(null); + final PagedIterable configurationSettingIterable + = client.listConfigurationSettings(null); assertEquals(2, configurationSettingIterable.stream().count()); return configurationSettingIterable; }); @@ -714,10 +750,13 @@ public void listWithMultipleLabels(HttpClient httpClient, ConfigurationServiceVe String label2 = getLabel(); listWithMultipleLabelsRunner(key, label, label2, (setting, setting2) -> { - assertConfigurationEquals(setting, client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue()); - assertConfigurationEquals(setting2, client.addConfigurationSettingWithResponse(setting2, Context.NONE).getValue()); + assertConfigurationEquals(setting, + client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue()); + assertConfigurationEquals(setting2, + client.addConfigurationSettingWithResponse(setting2, Context.NONE).getValue()); - return client.listConfigurationSettings(new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2)); + return client.listConfigurationSettings( + new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2)); }); } @@ -726,10 +765,12 @@ public void listWithMultipleLabels(HttpClient httpClient, ConfigurationServiceVe */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFields(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFields(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); listConfigurationSettingsSelectFieldsRunner((settings, selector) -> { - settings.forEach(setting -> client.setConfigurationSettingWithResponse(setting, false, Context.NONE).getValue()); + settings.forEach( + setting -> client.setConfigurationSettingWithResponse(setting, false, Context.NONE).getValue()); return client.listConfigurationSettings(selector); }); } @@ -739,7 +780,8 @@ public void listConfigurationSettingsSelectFields(HttpClient httpClient, Configu */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); filterValueTest("*" + getKey(), getLabel()); } @@ -749,7 +791,8 @@ public void listConfigurationSettingsSelectFieldsWithPrefixStarKeyFilter(HttpCli */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); filterValueTest("*" + getKey() + "*", getLabel()); } @@ -759,7 +802,8 @@ public void listConfigurationSettingsSelectFieldsWithSubstringKeyFilter(HttpClie */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); filterValueTest(getKey(), "*" + getLabel()); } @@ -769,7 +813,8 @@ public void listConfigurationSettingsSelectFieldsWithPrefixStarLabelFilter(HttpC */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); filterValueTest(getKey(), "*" + getLabel() + "*"); } @@ -779,29 +824,38 @@ public void listConfigurationSettingsSelectFieldsWithSubstringLabelFilter(HttpCl */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsAcceptDateTime(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsAcceptDateTime(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final String keyName = getKey(); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. - assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); + assertConfigurationEquals(original, + client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); sleepIfRunningAgainstService(2000); - assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); + assertConfigurationEquals(updated, + client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); sleepIfRunningAgainstService(2000); - assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue()); + 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()); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList()); assertNotNull(revisions); assertEquals(3, revisions.size()); // We want to fetch the configuration setting when we first updated its value. - SettingSelector options = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); - assertConfigurationEquals(updated, (client.listConfigurationSettings(options).stream().collect(Collectors.toList())).get(0)); + SettingSelector options + = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); + assertConfigurationEquals(updated, + (client.listConfigurationSettings(options).stream().collect(Collectors.toList())).get(0)); } /** @@ -814,22 +868,31 @@ public void listRevisions(HttpClient httpClient, ConfigurationServiceVersion ser client = getConfigurationClient(httpClient, serviceVersion); final String keyName = getKey(); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. - assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); - assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); - assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue()); + assertConfigurationEquals(original, + client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); + assertConfigurationEquals(updated, + client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); + assertConfigurationEquals(updated2, + client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue()); // Get all revisions for a key, they are listed in descending order. - List revisions = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList()); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList()); assertConfigurationEquals(updated2, revisions.get(0)); assertConfigurationEquals(updated, revisions.get(1)); assertConfigurationEquals(original, revisions.get(2)); // Verifies that we can select specific fields. - revisions = client.listRevisions(new SettingSelector().setKeyFilter(keyName).setFields(SettingFields.KEY, SettingFields.ETAG)).stream().collect(Collectors.toList()); + revisions = client + .listRevisions(new SettingSelector().setKeyFilter(keyName).setFields(SettingFields.KEY, SettingFields.ETAG)) + .stream() + .collect(Collectors.toList()); validateListRevisions(updated2, revisions.get(0)); validateListRevisions(updated, revisions.get(1)); validateListRevisions(original, revisions.get(2)); @@ -849,10 +912,14 @@ public void listRevisionsWithMultipleKeys(HttpClient httpClient, ConfigurationSe String key2 = getKey(); listRevisionsWithMultipleKeysRunner(key, key2, (testInput) -> { - assertConfigurationEquals(testInput.get(0), client.addConfigurationSettingWithResponse(testInput.get(0), Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(1), client.setConfigurationSettingWithResponse(testInput.get(1), false, Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(2), client.addConfigurationSettingWithResponse(testInput.get(2), Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(3), client.setConfigurationSettingWithResponse(testInput.get(3), false, Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(0), + client.addConfigurationSettingWithResponse(testInput.get(0), Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(1), + client.setConfigurationSettingWithResponse(testInput.get(1), false, Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(2), + client.addConfigurationSettingWithResponse(testInput.get(2), Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(3), + client.setConfigurationSettingWithResponse(testInput.get(3), false, Context.NONE).getValue()); return client.listRevisions(new SettingSelector().setKeyFilter(key + "," + key2)); }); @@ -870,10 +937,14 @@ public void listRevisionsWithMultipleLabels(HttpClient httpClient, Configuration String label2 = getLabel(); listRevisionsWithMultipleLabelsRunner(key, label, label2, (testInput) -> { - assertConfigurationEquals(testInput.get(0), client.addConfigurationSettingWithResponse(testInput.get(0), Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(1), client.setConfigurationSettingWithResponse(testInput.get(1), false, Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(2), client.addConfigurationSettingWithResponse(testInput.get(2), Context.NONE).getValue()); - assertConfigurationEquals(testInput.get(3), client.setConfigurationSettingWithResponse(testInput.get(3), false, Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(0), + client.addConfigurationSettingWithResponse(testInput.get(0), Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(1), + client.setConfigurationSettingWithResponse(testInput.get(1), false, Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(2), + client.addConfigurationSettingWithResponse(testInput.get(2), Context.NONE).getValue()); + assertConfigurationEquals(testInput.get(3), + client.setConfigurationSettingWithResponse(testInput.get(3), false, Context.NONE).getValue()); return client.listRevisions(new SettingSelector().setKeyFilter(key).setLabelFilter(label + "," + label2)); }); @@ -888,25 +959,32 @@ public void listRevisionsAcceptDateTime(HttpClient httpClient, ConfigurationServ client = getConfigurationClient(httpClient, serviceVersion); final String keyName = getKey(); final ConfigurationSetting original = new ConfigurationSetting().setKey(keyName).setValue("myValue"); - final ConfigurationSetting updated = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); - final ConfigurationSetting updated2 = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); + final ConfigurationSetting updated + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue"); + final ConfigurationSetting updated2 + = new ConfigurationSetting().setKey(original.getKey()).setValue("anotherValue2"); // Create 3 revisions of the same key. - assertConfigurationEquals(original, client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); + assertConfigurationEquals(original, + client.setConfigurationSettingWithResponse(original, false, Context.NONE).getValue()); sleepIfRunningAgainstService(2000); - assertConfigurationEquals(updated, client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); + assertConfigurationEquals(updated, + client.setConfigurationSettingWithResponse(updated, false, Context.NONE).getValue()); sleepIfRunningAgainstService(2000); - assertConfigurationEquals(updated2, client.setConfigurationSettingWithResponse(updated2, false, Context.NONE).getValue()); + 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()); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(keyName)).stream().collect(Collectors.toList()); assertNotNull(revisions); assertEquals(3, revisions.size()); // We want to fetch all the revisions that existed up and including when the first revision was created. // Revisions are returned in descending order from creation date. - SettingSelector options = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); + SettingSelector options + = new SettingSelector().setKeyFilter(keyName).setAcceptDatetime(revisions.get(1).getLastModified()); revisions = client.listRevisions(options).stream().collect(Collectors.toList()); assertConfigurationEquals(updated, revisions.get(0)); assertConfigurationEquals(original, revisions.get(1)); @@ -922,7 +1000,11 @@ public void listRevisionsWithPagination(HttpClient httpClient, ConfigurationServ client = getConfigurationClient(httpClient, serviceVersion); final int numberExpected = 50; for (int value = 0; value < numberExpected; value++) { - client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), false, Context.NONE).getValue(); + client + .setConfigurationSettingWithResponse( + new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), + false, Context.NONE) + .getValue(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix).setLabelFilter(labelPrefix); @@ -935,11 +1017,16 @@ public void listRevisionsWithPagination(HttpClient httpClient, ConfigurationServ */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final int numberExpected = 50; for (int value = 0; value < numberExpected; value++) { - client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), false, Context.NONE).getValue(); + client + .setConfigurationSettingWithResponse( + new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), + false, Context.NONE) + .getValue(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix).setLabelFilter(labelPrefix); @@ -955,11 +1042,16 @@ public void listRevisionsWithPaginationAndRepeatStream(HttpClient httpClient, Co */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final int numberExpected = 50; for (int value = 0; value < numberExpected; value++) { - client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), false, Context.NONE).getValue(); + client + .setConfigurationSettingWithResponse( + new ConfigurationSetting().setKey(keyPrefix).setValue("myValue" + value).setLabel(labelPrefix), + false, Context.NONE) + .getValue(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix).setLabelFilter(labelPrefix); @@ -984,11 +1076,14 @@ public void listRevisionsWithPaginationAndRepeatIterator(HttpClient httpClient, @Disabled("Error code 403 TOO_MANY_REQUESTS https://github.com/Azure/azure-sdk-for-java/issues/36602") @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listConfigurationSettingsWithPagination(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listConfigurationSettingsWithPagination(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final int numberExpected = 50; for (int value = 0; value < numberExpected; value++) { - client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey(keyPrefix + "-" + value).setValue("myValue").setLabel(labelPrefix), false, Context.NONE).getValue(); + client.setConfigurationSettingWithResponse( + new ConfigurationSetting().setKey(keyPrefix + "-" + value).setValue("myValue").setLabel(labelPrefix), + false, Context.NONE).getValue(); } SettingSelector filter = new SettingSelector().setKeyFilter(keyPrefix + "-*").setLabelFilter(labelPrefix); @@ -1001,20 +1096,25 @@ public void listConfigurationSettingsWithPagination(HttpClient httpClient, Confi */ @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void getConfigurationSettingWhenValueNotUpdated(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void getConfigurationSettingWhenValueNotUpdated(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); final String key = getKey(); final ConfigurationSetting expected = new ConfigurationSetting().setKey(key).setValue("myValue"); final ConfigurationSetting newExpected = new ConfigurationSetting().setKey(key).setValue("myNewValue"); - final ConfigurationSetting block = client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue(); + final ConfigurationSetting block + = client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue(); assertNotNull(block); assertConfigurationEquals(expected, block); // conditional get, now the setting has not be updated yet, resulting 304 and null value - assertConfigurationEquals(null, client.getConfigurationSettingWithResponse(block, null, true, Context.NONE), 304); - assertConfigurationEquals(newExpected, client.setConfigurationSettingWithResponse(newExpected, false, Context.NONE).getValue()); + assertConfigurationEquals(null, client.getConfigurationSettingWithResponse(block, null, true, Context.NONE), + 304); + assertConfigurationEquals(newExpected, + client.setConfigurationSettingWithResponse(newExpected, false, Context.NONE).getValue()); // conditional get, now the setting is updated and we are able to get a new setting with 200 code - assertConfigurationEquals(newExpected, client.getConfigurationSettingWithResponse(newExpected, null, true, Context.NONE).getValue()); + assertConfigurationEquals(newExpected, + client.getConfigurationSettingWithResponse(newExpected, null, true, Context.NONE).getValue()); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -1023,7 +1123,8 @@ public void deleteAllSettings(HttpClient httpClient, ConfigurationServiceVersion client = getConfigurationClient(httpClient, serviceVersion); client.listConfigurationSettings(new SettingSelector().setKeyFilter("*")).forEach(configurationSetting -> { - logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), configurationSetting.getLabel(), configurationSetting.isReadOnly()); + logger.info("Deleting key:label [{}:{}]. isReadOnly? {}", configurationSetting.getKey(), + configurationSetting.getLabel(), configurationSetting.isReadOnly()); client.deleteConfigurationSettingWithResponse(configurationSetting, false, Context.NONE).getValue(); }); } @@ -1034,12 +1135,10 @@ public void addHeadersFromContextPolicyTest(HttpClient httpClient, Configuration client = getConfigurationClient(httpClient, serviceVersion); final HttpHeaders headers = getCustomizedHeaders(); addHeadersFromContextPolicyRunner(expected -> { - final Response response = - client.addConfigurationSettingWithResponse(expected, - new Context(AddHeadersFromContextPolicy.AZURE_REQUEST_HTTP_HEADERS_KEY, headers)); - assertContainsHeaders(headers, response.getRequest().getHeaders()); - } - ); + final Response response = client.addConfigurationSettingWithResponse(expected, + new Context(AddHeadersFromContextPolicy.AZURE_REQUEST_HTTP_HEADERS_KEY, headers)); + assertContainsHeaders(headers, response.getRequest().getHeaders()); + }); } @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @@ -1051,16 +1150,15 @@ public void createSnapshot(HttpClient httpClient, ConfigurationServiceVersion se client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue())); createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); - assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, + assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot, it will be deleted automatically when retention period expires. @@ -1077,10 +1175,10 @@ public void getSnapshot(HttpClient httpClient, ConfigurationServiceVersion servi client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue())); createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1119,10 +1217,10 @@ public void getSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVe client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue())); createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1132,8 +1230,7 @@ public void getSnapshotConvenience(HttpClient httpClient, ConfigurationServiceVe // Retrieve a snapshot after creation assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, - client.getSnapshot(name)); + MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, client.getSnapshot(name)); // Archived the snapshot, it will be deleted automatically when retention period expires. ConfigurationSnapshot archivedSnapshot = client.archiveSnapshot(name); @@ -1151,10 +1248,10 @@ public void archiveSnapshot(HttpClient httpClient, ConfigurationServiceVersion s createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1163,11 +1260,10 @@ public void archiveSnapshot(HttpClient httpClient, ConfigurationServiceVersion s MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot, it will be deleted automatically when retention period expires. - Response response = client.archiveSnapshotWithResponse(snapshotResult.getName(), - null, Context.NONE); - assertConfigurationSnapshotWithResponse(200, name, - ConfigurationSnapshotStatus.ARCHIVED, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response); + Response response + = client.archiveSnapshotWithResponse(snapshotResult.getName(), null, Context.NONE); + assertConfigurationSnapshotWithResponse(200, name, ConfigurationSnapshotStatus.ARCHIVED, filters, + SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, response); }); } @@ -1181,16 +1277,15 @@ public void archiveSnapshotConvenience(HttpClient httpClient, ConfigurationServi createSnapshotRunner((name, filters) -> { // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); - assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, + assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot, it will be deleted automatically when retention period expires. @@ -1208,10 +1303,10 @@ public void recoverSnapshot(HttpClient httpClient, ConfigurationServiceVersion s client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue())); createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1220,18 +1315,14 @@ public void recoverSnapshot(HttpClient httpClient, ConfigurationServiceVersion s MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, snapshotResult); // Archived the snapshot - assertEqualsConfigurationSnapshot(name, - ConfigurationSnapshotStatus.ARCHIVED, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, - client.archiveSnapshot(name)); + assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.ARCHIVED, filters, + SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, client.archiveSnapshot(name)); // Recover the snapshot, it will be deleted automatically when retention period expires. - Response configurationSnapshotResponse = - client.recoverSnapshotWithResponse(snapshotResult.getName(), null, Context.NONE); - assertConfigurationSnapshotWithResponse(200, name, - ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, - configurationSnapshotResponse); + Response configurationSnapshotResponse + = client.recoverSnapshotWithResponse(snapshotResult.getName(), null, Context.NONE); + assertConfigurationSnapshotWithResponse(200, name, ConfigurationSnapshotStatus.READY, filters, + SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, configurationSnapshotResponse); // Archived the snapshot, it will be deleted automatically when retention period expires. assertEquals(ConfigurationSnapshotStatus.ARCHIVED, client.archiveSnapshot(name).getStatus()); @@ -1247,10 +1338,10 @@ public void recoverSnapshotConvenience(HttpClient httpClient, ConfigurationServi client.addConfigurationSettingWithResponse(expected, Context.NONE).getValue())); createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1263,8 +1354,7 @@ public void recoverSnapshotConvenience(HttpClient httpClient, ConfigurationServi // Recover the snapshot, it will be deleted automatically when retention period expires. assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, - MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, - client.recoverSnapshot(name)); + MINIMUM_RETENTION_PERIOD, 1000L, 0L, null, client.recoverSnapshot(name)); // Archived the snapshot, it will be deleted automatically when retention period expires. assertEquals(ConfigurationSnapshotStatus.ARCHIVED, client.archiveSnapshot(name).getStatus()); @@ -1294,10 +1384,10 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // Create first snapshot createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1310,10 +1400,10 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // Create second snapshot createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1328,11 +1418,10 @@ public void listSnapshots(HttpClient httpClient, ConfigurationServiceVersion ser // readySnapshots contains only 1 snapshot ConfigurationSnapshot readySnapshot = readySnapshots.get(0); // List only the snapshot with a specific name - client.listSnapshots(new SnapshotSelector().setNameFilter(readySnapshot.getName())) - .forEach(response -> { - assertEquals(readySnapshot.getName(), response.getName()); - assertEquals(readySnapshot.getStatus(), response.getStatus()); - }); + client.listSnapshots(new SnapshotSelector().setNameFilter(readySnapshot.getName())).forEach(response -> { + assertEquals(readySnapshot.getName(), response.getName()); + assertEquals(readySnapshot.getStatus(), response.getStatus()); + }); // Archived the snapshot, it will be deleted automatically when retention period expires. assertEquals(ConfigurationSnapshotStatus.ARCHIVED, client.archiveSnapshot(readySnapshot.getName()).getStatus()); } @@ -1360,10 +1449,10 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // Create first snapshot createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1376,10 +1465,10 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // Create second snapshot createSnapshotRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1394,9 +1483,8 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV // readySnapshots contains only 1 snapshot ConfigurationSnapshot readySnapshot = readySnapshots.get(0); // List only the snapshot with a specific name - PagedIterable configurationSnapshots = - client.listSnapshots(new SnapshotSelector() - .setNameFilter(readySnapshot.getName()) + PagedIterable configurationSnapshots + = client.listSnapshots(new SnapshotSelector().setNameFilter(readySnapshot.getName()) .setFields(SnapshotFields.NAME, SnapshotFields.FILTERS, SnapshotFields.STATUS)); for (ConfigurationSnapshot snapshotFieldFiltered : configurationSnapshots) { @@ -1413,7 +1501,8 @@ public void listSnapshotsWithFields(HttpClient httpClient, ConfigurationServiceV assertNull(snapshotFieldFiltered.getTags()); // Archived the snapshot, it will be deleted automatically when retention period expires. - assertEquals(ConfigurationSnapshotStatus.ARCHIVED, client.archiveSnapshot(snapshotFieldFiltered.getName()).getStatus()); + assertEquals(ConfigurationSnapshotStatus.ARCHIVED, + client.archiveSnapshot(snapshotFieldFiltered.getName()).getStatus()); } } @@ -1437,10 +1526,10 @@ public void listSettingFromSnapshot(HttpClient httpClient, ConfigurationServiceV assertEquals(numberExpected, client.listConfigurationSettings(filter).stream().count()); // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1474,10 +1563,10 @@ public void listSettingFromSnapshotWithFields(HttpClient httpClient, Configurati assertEquals(numberExpected, client.listConfigurationSettings(filter).stream().count()); // Retention period can be setup when creating a snapshot and cannot edit. - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); @@ -1485,7 +1574,8 @@ public void listSettingFromSnapshotWithFields(HttpClient httpClient, Configurati assertEqualsConfigurationSnapshot(name, ConfigurationSnapshotStatus.READY, filters, SnapshotComposition.KEY, MINIMUM_RETENTION_PERIOD, 15000L, (long) numberExpected, null, snapshotResult); - PagedIterable configurationSettings = client.listConfigurationSettingsForSnapshot(name, Arrays.asList(SettingFields.KEY, SettingFields.VALUE), Context.NONE); + PagedIterable configurationSettings = client.listConfigurationSettingsForSnapshot( + name, Arrays.asList(SettingFields.KEY, SettingFields.VALUE), Context.NONE); assertEquals(numberExpected, configurationSettings.stream().count()); for (ConfigurationSetting setting : configurationSettings) { @@ -1511,8 +1601,8 @@ public void listSettingsWithPageETag(HttpClient httpClient, ConfigurationService // Step 1: Prepare testing data. // Clean all existing settings before this test purpose client.listConfigurationSettings(null) - .stream() - .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); + .stream() + .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); // Add a few setting to form a page of settings final ConfigurationSetting setting = new ConfigurationSetting().setKey(getKey()).setValue("value"); final ConfigurationSetting setting2 = new ConfigurationSetting().setKey(getKey()).setValue("value"); @@ -1522,21 +1612,23 @@ public void listSettingsWithPageETag(HttpClient httpClient, ConfigurationService PagedIterable configurationSettings = client.listConfigurationSettings(null); List matchConditionsList = new ArrayList<>(); configurationSettings.iterableByPage().forEach(pagedResponse -> { - matchConditionsList.add(new MatchConditions().setIfNoneMatch(pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG))); + matchConditionsList + .add(new MatchConditions().setIfNoneMatch(pagedResponse.getHeaders().getValue(HttpHeaderName.ETAG))); }); // Step 2: Test list settings with page ETag // Validation 1: Validate all pages are not modified and return empty list of settings in each page response. // List settings with page ETag - PagedIterable settings = client.listConfigurationSettings( - new SettingSelector().setMatchConditions(matchConditionsList)); + PagedIterable settings + = client.listConfigurationSettings(new SettingSelector().setMatchConditions(matchConditionsList)); settings.iterableByPage().forEach(pagedResponse -> { // No changes on the server side, so the response should be empty list assertEquals(0, pagedResponse.getValue().size()); }); // Validation 2: validate the page has the updated setting should be returned // Update a setting - final ConfigurationSetting updatedSetting = new ConfigurationSetting().setKey(setting.getKey()).setValue("new value"); + final ConfigurationSetting updatedSetting + = new ConfigurationSetting().setKey(setting.getKey()).setValue("new value"); client.setConfigurationSetting(updatedSetting); // List settings with expired page ETag settings = client.listConfigurationSettings(new SettingSelector().setMatchConditions(matchConditionsList)); @@ -1545,10 +1637,10 @@ public void listSettingsWithPageETag(HttpClient httpClient, ConfigurationService assertFalse(pagedResponse.getValue().isEmpty()); // find the updated setting in the list ConfigurationSetting updatedSettingFromResponse = pagedResponse.getValue() - .stream() - .filter(s -> s.getKey().equals(updatedSetting.getKey())) - .findAny() - .get(); + .stream() + .filter(s -> s.getKey().equals(updatedSetting.getKey())) + .findAny() + .get(); assertConfigurationEquals(updatedSetting, updatedSettingFromResponse); }); } @@ -1559,23 +1651,29 @@ public void listLabels(HttpClient httpClient, ConfigurationServiceVersion servic client = getConfigurationClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose client.listConfigurationSettings(null) - .stream() - .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); + .stream() + .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); // Prepare two settings with different labels List preparedSettings = listLabelsRunner(setting -> assertConfigurationEquals(setting, - client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue())); + client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue())); ConfigurationSetting setting = preparedSettings.get(0); ConfigurationSetting setting2 = preparedSettings.get(1); // List only the first label var, 'label' String label = setting.getLabel(); - PagedIterable labels = client.listLabels(new SettingLabelSelector().setNameFilter(setting.getLabel())); + PagedIterable labels + = client.listLabels(new SettingLabelSelector().setNameFilter(setting.getLabel())); assertEquals(1, labels.stream().count()); assertEquals(label, labels.iterator().next().getName()); // List labels with wildcard label filter String label2 = setting2.getLabel(); - PagedIterable wildCardLabels = client.listLabels(new SettingLabelSelector().setNameFilter("label*")); - List collect = wildCardLabels.stream().collect(Collectors.toList()).stream().map(SettingLabel::getName).collect(Collectors.toList()); + PagedIterable wildCardLabels + = client.listLabels(new SettingLabelSelector().setNameFilter("label*")); + List collect = wildCardLabels.stream() + .collect(Collectors.toList()) + .stream() + .map(SettingLabel::getName) + .collect(Collectors.toList()); assertTrue(collect.contains(label)); assertTrue(collect.contains(label2)); // List all labels @@ -1585,28 +1683,28 @@ public void listLabels(HttpClient httpClient, ConfigurationServiceVersion servic @ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS) @MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters") - public void listSettingByTagsFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { + public void listSettingByTagsFilter(HttpClient httpClient, ConfigurationServiceVersion serviceVersion) { client = getConfigurationClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose client.listConfigurationSettings(null) - .stream() - .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); + .stream() + .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); // Prepare two settings with different tags - List preparedSettings = listSettingByTagsFilterRunner(setting -> - assertConfigurationEquals(setting, - client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue())); + List preparedSettings + = listSettingByTagsFilterRunner(setting -> assertConfigurationEquals(setting, + client.addConfigurationSettingWithResponse(setting, Context.NONE).getValue())); ConfigurationSetting setting = preparedSettings.get(0); ConfigurationSetting setting2 = preparedSettings.get(1); // List setting by first tags filter, it should return all settings - PagedIterable configurationSettings = client.listConfigurationSettings( - new SettingSelector().setTagsFilter(getTagsFilterInString(setting.getTags()))); + PagedIterable configurationSettings = client + .listConfigurationSettings(new SettingSelector().setTagsFilter(getTagsFilterInString(setting.getTags()))); Iterator iterator = configurationSettings.iterator(); assertConfigurationEquals(setting, iterator.next()); assertConfigurationEquals(setting2, iterator.next()); // List setting by second tags filter, it should return only one setting - PagedIterable configurationSettings2 = client.listConfigurationSettings( - new SettingSelector().setTagsFilter(getTagsFilterInString(setting2.getTags()))); + PagedIterable configurationSettings2 = client + .listConfigurationSettings(new SettingSelector().setTagsFilter(getTagsFilterInString(setting2.getTags()))); assertEquals(1, configurationSettings2.stream().count()); assertConfigurationEquals(setting2, configurationSettings2.iterator().next()); } @@ -1617,15 +1715,14 @@ public void listRevisionsWithTagsFilter(HttpClient httpClient, ConfigurationServ client = getConfigurationClient(httpClient, serviceVersion); // Create 3 revisions of the same key. List configurationSettings = listRevisionsWithTagsFilterRunner(setting -> { - assertConfigurationEquals(setting, client.setConfigurationSettingWithResponse(setting, false, Context.NONE).getValue()); + assertConfigurationEquals(setting, + client.setConfigurationSettingWithResponse(setting, false, Context.NONE).getValue()); }); ConfigurationSetting original = configurationSettings.get(0); // Get all revisions for a key with tags filter, they are listed in descending order. - List revisions = client.listRevisions( - new SettingSelector() - .setKeyFilter(original.getKey()) - .setTagsFilter(getTagsFilterInString(original.getTags()))) - .stream().collect(Collectors.toList()); + List revisions + = client.listRevisions(new SettingSelector().setKeyFilter(original.getKey()) + .setTagsFilter(getTagsFilterInString(original.getTags()))).stream().collect(Collectors.toList()); assertEquals(1, revisions.size()); assertConfigurationEquals(original, revisions.get(0)); } @@ -1636,28 +1733,28 @@ public void createSnapshotWithTagsFilter(HttpClient httpClient, ConfigurationSer client = getConfigurationClient(httpClient, serviceVersion); // Clean all existing settings before this test purpose client.listConfigurationSettings(null) - .stream() - .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); + .stream() + .forEach(configurationSetting -> client.deleteConfigurationSetting(configurationSetting)); // Prepare settings before creating a snapshot - List settings = createSnapshotWithTagsFilterPrepareRunner(setting -> - assertConfigurationEquals(setting, client.addConfigurationSetting(setting))); + List settings = createSnapshotWithTagsFilterPrepareRunner( + setting -> assertConfigurationEquals(setting, client.addConfigurationSetting(setting))); ConfigurationSetting setting = settings.get(0); ConfigurationSetting settingWithTag = settings.get(1); assertTrue(setting.getTags().isEmpty()); assertFalse(settingWithTag.getTags().isEmpty()); createSnapshotWithTagsFilterRunner((name, filters) -> { - ConfigurationSnapshot snapshot = new ConfigurationSnapshot(filters) - .setRetentionPeriod(MINIMUM_RETENTION_PERIOD); - SyncPoller poller = - client.beginCreateSnapshot(name, snapshot, Context.NONE); + ConfigurationSnapshot snapshot + = new ConfigurationSnapshot(filters).setRetentionPeriod(MINIMUM_RETENTION_PERIOD); + SyncPoller poller + = client.beginCreateSnapshot(name, snapshot, Context.NONE); poller.setPollInterval(interceptorManager.isPlaybackMode() ? Duration.ofMillis(1) : Duration.ofSeconds(10)); poller.waitForCompletion(); ConfigurationSnapshot snapshotResult = poller.getFinalResult(); assertEquals(name, snapshotResult.getName()); // The snapshot should only contain the setting with tags - PagedIterable configurationSettings = client.listConfigurationSettingsForSnapshot( - name, null, Context.NONE); + PagedIterable configurationSettings + = client.listConfigurationSettingsForSnapshot(name, null, Context.NONE); List list = configurationSettings.stream().collect(Collectors.toList()); assertEquals(settingWithTag.getTags(), list.get(0).getTags()); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTestBase.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTestBase.java index bf0304d8bc298..b21d6e77dd7b4 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTestBase.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientTestBase.java @@ -52,10 +52,10 @@ public abstract class ConfigurationClientTestBase extends TestProxyTestBase { private static final int PREFIX_LENGTH = 8; private static final int RESOURCE_LENGTH = 16; // Disable `("$.key")` and name sanitizer from the list of common sanitizers - public static final String[] REMOVE_SANITIZER_ID = {"AZSDK3493", "AZSDK3447"}; + public static final String[] REMOVE_SANITIZER_ID = { "AZSDK3493", "AZSDK3447" }; - public static final String FAKE_CONNECTION_STRING = - "Endpoint=https://localhost:8080;Id=0000000000000;Secret=fakeSecrePlaceholder"; + public static final String FAKE_CONNECTION_STRING + = "Endpoint=https://localhost:8080;Id=0000000000000;Secret=fakeSecrePlaceholder"; static final Duration MINIMUM_RETENTION_PERIOD = Duration.ofHours(1); @@ -78,14 +78,12 @@ T clientSetup(BiFunction clientBuilder) { ? new ConfigurationClientCredentials(FAKE_CONNECTION_STRING).getBaseUri() : Configuration.getGlobalConfiguration().get("AZ_CONFIG_ENDPOINT"); - Objects.requireNonNull(tokenCredential, "Token Credential expected to be set."); Objects.requireNonNull(endpoint, "Az Config endpoint expected to be set."); return Objects.requireNonNull(clientBuilder.apply(tokenCredential, endpoint)); } - String getKey() { return testResourceNamer.randomName(keyPrefix, RESOURCE_LENGTH); } @@ -106,11 +104,8 @@ void addConfigurationSettingRunner(Consumer testRunner) { tags.put("MyTag", "TagValue"); tags.put("AnotherTag", "AnotherTagValue"); - final ConfigurationSetting newConfiguration = new ConfigurationSetting() - .setKey(getKey()) - .setValue("myNewValue") - .setTags(tags) - .setContentType("text"); + final ConfigurationSetting newConfiguration + = new ConfigurationSetting().setKey(getKey()).setValue("myNewValue").setTags(tags).setContentType("text"); testRunner.accept(newConfiguration); testRunner.accept(newConfiguration.setLabel(getLabel())); @@ -121,10 +116,8 @@ ConfigurationSetting addConfigurationSettingWithTagsRunner(Consumer testRunner) { - final ConfigurationSetting newConfiguration = new ConfigurationSetting().setKey(getKey()).setValue("myNewValue"); + final ConfigurationSetting newConfiguration + = new ConfigurationSetting().setKey(getKey()).setValue("myNewValue"); testRunner.accept(newConfiguration); testRunner.accept(newConfiguration.setLabel(getLabel())); @@ -190,7 +184,8 @@ void setConfigurationSettingRunner(BiConsumer testRunner) { String key = getKey(); FeatureFlagConfigurationSetting featureFlagX = getFeatureFlagConfigurationSetting(key, "Feature Flag X"); - String valueWithAdditionalFieldAtFirstLayer = - String.format( - "{\"id\":\"%s\",\"k1\":\"v1\",\"description\":\"%s\",\"display_name\":\"%s\",\"enabled\":%s," + String valueWithAdditionalFieldAtFirstLayer = String.format( + "{\"id\":\"%s\",\"k1\":\"v1\",\"description\":\"%s\",\"display_name\":\"%s\",\"enabled\":%s," + "\"conditions\":{\"requirement_type\":\"All\",\"client_filters\":" + "[{\"name\":\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]" - + "},\"additional_field\":\"additional_value\"}", featureFlagX.getFeatureId(), - featureFlagX.getDescription(), featureFlagX.getDisplayName(), featureFlagX.isEnabled()); + + "},\"additional_field\":\"additional_value\"}", + featureFlagX.getFeatureId(), featureFlagX.getDescription(), featureFlagX.getDisplayName(), + featureFlagX.isEnabled()); featureFlagX.setValue(valueWithAdditionalFieldAtFirstLayer); testRunner.accept(featureFlagX); } @@ -244,8 +239,8 @@ public abstract void secretReferenceConfigurationSettingUnknownAttributesArePres void secretReferenceConfigurationSettingUnknownAttributesArePreservedRunner( Consumer testRunner) { String key = getKey(); - String valueWithAdditionalFields = - "{\"uri\":\"uriValue\",\"objectFiledName\":{\"unknown\":\"unknown\",\"unknown2\":\"unknown2\"}," + String valueWithAdditionalFields + = "{\"uri\":\"uriValue\",\"objectFiledName\":{\"unknown\":\"unknown\",\"unknown2\":\"unknown2\"}," + "\"arrayFieldName\":[{\"name\":\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]}"; testRunner.accept(new SecretReferenceConfigurationSetting(key, valueWithAdditionalFields)); @@ -260,7 +255,8 @@ void setConfigurationSettingIfETagRunner(BiConsumer test testRunner.accept(setting2); } - @Test public abstract void setConfigurationSettingNullKey(HttpClient httpClient, + @Test + public abstract void setConfigurationSettingNullKey(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); @Test - public abstract void getConfigurationSetting(HttpClient httpClient, - ConfigurationServiceVersion serviceVersion); + public abstract void getConfigurationSetting(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); @Test public abstract void getConfigurationSettingConvenience(HttpClient httpClient, @@ -370,7 +366,8 @@ void deleteConfigurationSettingWithETagRunner(BiConsumer> testRunner) { + void listWithMultipleKeysRunner(String key, String key2, + BiFunction> testRunner) { final ConfigurationSetting setting = new ConfigurationSetting().setKey(key).setValue("value"); final ConfigurationSetting setting2 = new ConfigurationSetting().setKey(key2).setValue("value"); final Set expectedSelection = new HashSet<>(Arrays.asList(setting, setting2)); - testRunner.apply(setting, setting2).forEach(actual -> expectedSelection.removeIf(expected -> equals(expected, cleanResponse(expected, actual)))); + testRunner.apply(setting, setting2) + .forEach( + actual -> expectedSelection.removeIf(expected -> equals(expected, cleanResponse(expected, actual)))); assertTrue(expectedSelection.isEmpty()); } @Test public abstract void listWithMultipleLabels(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); - void listWithMultipleLabelsRunner(String key, String label, String label2, BiFunction> testRunner) { + void listWithMultipleLabelsRunner(String key, String label, String label2, + BiFunction> testRunner) { final ConfigurationSetting setting = new ConfigurationSetting().setKey(key).setValue("value").setLabel(label); final ConfigurationSetting setting2 = new ConfigurationSetting().setKey(key).setValue("value").setLabel(label2); final Set expectedSelection = new HashSet<>(Arrays.asList(setting, setting2)); @@ -450,7 +452,8 @@ void listWithMultipleLabelsRunner(String key, String label, String label2, BiFun public abstract void listConfigurationSettingsSelectFields(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); - void listConfigurationSettingsSelectFieldsRunner(BiFunction, SettingSelector, Iterable> testRunner) { + void listConfigurationSettingsSelectFieldsRunner( + BiFunction, SettingSelector, Iterable> testRunner) { final String label = "my-first-mylabel"; final String label2 = "my-second-mylabel"; final int numberToCreate = 8; @@ -458,8 +461,7 @@ void listConfigurationSettingsSelectFieldsRunner(BiFunction testRunner) { + void listConfigurationSettingsSelectFieldsWithNotSupportedFilterRunner(String keyFilter, String labelFilter, + Consumer testRunner) { final Map tags = new HashMap<>(); tags.put("tag1", "value1"); tags.put("tag2", "value2"); - final SettingSelector selector = new SettingSelector() - .setKeyFilter(keyFilter) + final SettingSelector selector = new SettingSelector().setKeyFilter(keyFilter) .setLabelFilter(labelFilter) .setFields(SettingFields.KEY, SettingFields.ETAG, SettingFields.CONTENT_TYPE, SettingFields.TAGS); testRunner.accept(selector); @@ -529,11 +531,14 @@ static void validateListRevisions(ConfigurationSetting expected, ConfigurationSe public abstract void listRevisionsWithMultipleKeys(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); - void listRevisionsWithMultipleKeysRunner(String key, String key2, Function, Iterable> testRunner) { + void listRevisionsWithMultipleKeysRunner(String key, String key2, + Function, Iterable> testRunner) { final ConfigurationSetting setting = new ConfigurationSetting().setKey(key).setValue("value"); - final ConfigurationSetting settingUpdate = new ConfigurationSetting().setKey(setting.getKey()).setValue("updatedValue"); + final ConfigurationSetting settingUpdate + = new ConfigurationSetting().setKey(setting.getKey()).setValue("updatedValue"); final ConfigurationSetting setting2 = new ConfigurationSetting().setKey(key2).setValue("value"); - final ConfigurationSetting setting2Update = new ConfigurationSetting().setKey(setting2.getKey()).setValue("updatedValue"); + final ConfigurationSetting setting2Update + = new ConfigurationSetting().setKey(setting2.getKey()).setValue("updatedValue"); final List testInput = Arrays.asList(setting, settingUpdate, setting2, setting2Update); final Set expectedSelection = new HashSet<>(testInput); @@ -548,11 +553,15 @@ void listRevisionsWithMultipleKeysRunner(String key, String key2, Function, Iterable> testRunner) { + void listRevisionsWithMultipleLabelsRunner(String key, String label, String label2, + Function, Iterable> testRunner) { final ConfigurationSetting setting = new ConfigurationSetting().setKey(key).setValue("value").setLabel(label); - final ConfigurationSetting settingUpdate = new ConfigurationSetting().setKey(setting.getKey()).setLabel(setting.getLabel()).setValue("updatedValue"); + final ConfigurationSetting settingUpdate + = new ConfigurationSetting().setKey(setting.getKey()).setLabel(setting.getLabel()).setValue("updatedValue"); final ConfigurationSetting setting2 = new ConfigurationSetting().setKey(key).setValue("value").setLabel(label2); - final ConfigurationSetting setting2Update = new ConfigurationSetting().setKey(setting2.getKey()).setLabel(setting2.getLabel()).setValue("updatedValue"); + final ConfigurationSetting setting2Update = new ConfigurationSetting().setKey(setting2.getKey()) + .setLabel(setting2.getLabel()) + .setValue("updatedValue"); final List testInput = Arrays.asList(setting, settingUpdate, setting2, setting2Update); final Set expectedSelection = new HashSet<>(testInput); @@ -639,7 +648,8 @@ void createSnapshotRunner(BiConsumer> public abstract void listSettingFromSnapshot(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); @Test - public abstract void listSettingFromSnapshotWithFields(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); + public abstract void listSettingFromSnapshotWithFields(HttpClient httpClient, + ConfigurationServiceVersion serviceVersion); @Test public abstract void listSettingsWithPageETag(HttpClient httpClient, ConfigurationServiceVersion serviceVersion); @@ -693,9 +703,12 @@ List listRevisionsWithTagsFilterRunner(Consumer listRevisionsWithTagsFilterRunner(Consumer createSnapshotWithTagsFilterPrepareRunner(Consumer testRunner) { String key = getKey(); @@ -777,7 +791,8 @@ static void assertSecretReferenceConfigurationSettingEquals(SecretReferenceConfi * @param response RestResponse returned from the service, the body should contain a ConfigurationSetting * @param expectedStatusCode Expected HTTP status code returned by the service */ - static void assertConfigurationEquals(ConfigurationSetting expected, Response response, final int expectedStatusCode) { + static void assertConfigurationEquals(ConfigurationSetting expected, Response response, + final int expectedStatusCode) { assertNotNull(response); assertConfigurationEquals(expected, response.getValue()); } @@ -807,8 +822,7 @@ static void assertConfigurationEquals(ConfigurationSetting expected, Configurati * @param actual ConfigurationSetting returned by the service. */ private static ConfigurationSetting cleanResponse(ConfigurationSetting expected, ConfigurationSetting actual) { - ConfigurationSetting cleanedActual = new ConfigurationSetting() - .setKey(actual.getKey()) + ConfigurationSetting cleanedActual = new ConfigurationSetting().setKey(actual.getKey()) .setLabel(actual.getLabel()) .setValue(actual.getValue()) .setTags(actual.getTags()) @@ -828,7 +842,8 @@ static void assertRestException(Runnable exceptionThrower, int expectedStatusCod assertRestException(exceptionThrower, HttpResponseException.class, expectedStatusCode); } - static void assertRestException(Runnable exceptionThrower, Class expectedExceptionType, int expectedStatusCode) { + static void assertRestException(Runnable exceptionThrower, + Class expectedExceptionType, int expectedStatusCode) { try { exceptionThrower.run(); fail(); @@ -847,7 +862,8 @@ static void assertRestException(Throwable exception, int expectedStatusCode) { assertRestException(exception, HttpResponseException.class, expectedStatusCode); } - static void assertRestException(Throwable exception, Class expectedExceptionType, int expectedStatusCode) { + static void assertRestException(Throwable exception, Class expectedExceptionType, + int expectedStatusCode) { assertEquals(expectedExceptionType, exception.getClass()); assertEquals(expectedStatusCode, ((HttpResponseException) exception).getResponse().getStatusCode()); } @@ -866,7 +882,6 @@ static void assertRunnableThrowsException(Runnable exceptionThrower, Class - assertEquals(headerContainer.getValue(httpHeader.getName()), httpHeader.getValue())); + headers.stream() + .forEach(httpHeader -> assertEquals(headerContainer.getValue(httpHeader.getName()), httpHeader.getValue())); } private String getFeatureFlagConfigurationSettingValue(String key) { return "{\"id\":\"" + key + "\",\"description\":null,\"display_name\":\"Feature Flag X\"" - + ",\"enabled\":false,\"conditions\":{\"client_filters\":[{\"name\":" - + "\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]}}"; + + ",\"enabled\":false,\"conditions\":{\"client_filters\":[{\"name\":" + + "\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]}}"; } private FeatureFlagConfigurationSetting getFeatureFlagConfigurationSetting(String key, String displayName) { Map parameters = new HashMap<>(); parameters.put("Value", 30); final List filters = new ArrayList<>(); - filters.add(new FeatureFlagFilter("Microsoft.Percentage") - .setParameters(parameters)); + filters.add(new FeatureFlagFilter("Microsoft.Percentage").setParameters(parameters)); - return new FeatureFlagConfigurationSetting(key, false) - .setDisplayName(displayName) - .setClientFilters(filters) - .setValue(getFeatureFlagConfigurationSettingValue(key)); + return new FeatureFlagConfigurationSetting(key, false).setDisplayName(displayName) + .setClientFilters(filters) + .setValue(getFeatureFlagConfigurationSettingValue(key)); } void assertConfigurationSnapshotWithResponse(int expectedStatusCode, String name, ConfigurationSnapshotStatus snapshotStatus, List filters, - SnapshotComposition snapshotComposition, - Duration retentionPeriod, Long size, Long itemCount, Map tags, - Response response) { + SnapshotComposition snapshotComposition, Duration retentionPeriod, Long size, Long itemCount, + Map tags, Response response) { assertNotNull(response); assertEquals(expectedStatusCode, response.getStatusCode()); - assertEqualsConfigurationSnapshot(name, snapshotStatus, filters, snapshotComposition, retentionPeriod, - size, itemCount, tags, response.getValue()); + assertEqualsConfigurationSnapshot(name, snapshotStatus, filters, snapshotComposition, retentionPeriod, size, + itemCount, tags, response.getValue()); } void assertEqualsConfigurationSnapshot(String name, ConfigurationSnapshotStatus snapshotStatus, - List filters, SnapshotComposition snapshotComposition, Duration retentionPeriod, Long size, - Long itemCount, Map tags, ConfigurationSnapshot actualSnapshot) { + List filters, SnapshotComposition snapshotComposition, Duration retentionPeriod, + Long size, Long itemCount, Map tags, ConfigurationSnapshot actualSnapshot) { assertEquals(name, actualSnapshot.getName()); assertEquals(snapshotStatus, actualSnapshot.getStatus()); assertEqualsSnapshotFilters(filters, actualSnapshot.getFilters()); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/FeatureFlagSettingUnitTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/FeatureFlagSettingUnitTest.java index 30cf20c649432..bed88f2631a04 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/FeatureFlagSettingUnitTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/FeatureFlagSettingUnitTest.java @@ -32,12 +32,12 @@ public class FeatureFlagSettingUnitTest { @Test public void accessingStronglyTypedPropertiesAfterSettingDifferentFeatureFlagJSON() { // Create a new feature flag configuration setting, - final List featureFlagFilters = Arrays.asList( - getFlagFilter(FILTER_NAME, getFilterParameters())); + final List featureFlagFilters + = Arrays.asList(getFlagFilter(FILTER_NAME, getFilterParameters())); FeatureFlagConfigurationSetting setting = getFeatureFlagConfigurationSetting(NEW_KEY, DESCRIPTION_VALUE, DISPLAY_NAME_VALUE, IS_ENABLED, featureFlagFilters); - String expectedNewSettingValue = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, - DISPLAY_NAME_VALUE, IS_ENABLED); + String expectedNewSettingValue + = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, DISPLAY_NAME_VALUE, IS_ENABLED); assertEquals(expectedNewSettingValue, setting.getValue()); String expectedUpdatedSettingValue = getFeatureFlagConfigurationSettingValue(UPDATED_KEY, @@ -55,8 +55,8 @@ public void accessingStronglyTypedPropertiesAfterSettingDifferentFeatureFlagJSON @Test public void accessingValueAfterChangingStronglyTypedProperties() { FeatureFlagConfigurationSetting setting = createFeatureFlagConfigurationSetting(); - String expectedNewSettingValue = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, - DISPLAY_NAME_VALUE, IS_ENABLED); + String expectedNewSettingValue + = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, DISPLAY_NAME_VALUE, IS_ENABLED); // Test getValue() assertEquals(expectedNewSettingValue, setting.getValue()); // Update strongly-type properties. @@ -75,8 +75,8 @@ public void accessingValueAfterChangingStronglyTypedProperties() { @Test public void throwExceptionWhenInvalidNonJsonFeatureFlagValue() { FeatureFlagConfigurationSetting setting = createFeatureFlagConfigurationSetting(); - String expectedValue = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, - DISPLAY_NAME_VALUE, IS_ENABLED); + String expectedValue + = getFeatureFlagConfigurationSettingValue(NEW_KEY, DESCRIPTION_VALUE, DISPLAY_NAME_VALUE, IS_ENABLED); String originalValue = setting.getValue(); assertEquals(expectedValue, originalValue); @@ -93,8 +93,8 @@ public void throwExceptionWhenInvalidNonJsonFeatureFlagValue() { @Test public void reserveUnknownPropertiesTest() { FeatureFlagConfigurationSetting setting = createFeatureFlagConfigurationSetting(); - String newSettingValueJSON = getUnknownPropertiesFeatureFlagConfigurationSettingValue( - UPDATED_KEY, UPDATED_DESCRIPTION_VALUE, UPDATED_DISPLAY_NAME_VALUE, UPDATED_IS_ENABLED); + String newSettingValueJSON = getUnknownPropertiesFeatureFlagConfigurationSettingValue(UPDATED_KEY, + UPDATED_DESCRIPTION_VALUE, UPDATED_DISPLAY_NAME_VALUE, UPDATED_IS_ENABLED); setting.setValue(newSettingValueJSON); assertEquals(newSettingValueJSON, setting.getValue()); @@ -126,25 +126,25 @@ public void setKeyShowFeatureFlagPrefix() { private FeatureFlagConfigurationSetting createFeatureFlagConfigurationSetting() { // Create a new feature flag configuration setting, - final List featureFlagFilters = Arrays.asList( - getFlagFilter(FILTER_NAME, getFilterParameters())); - return getFeatureFlagConfigurationSetting(NEW_KEY, DESCRIPTION_VALUE, - DISPLAY_NAME_VALUE, IS_ENABLED, featureFlagFilters); + final List featureFlagFilters + = Arrays.asList(getFlagFilter(FILTER_NAME, getFilterParameters())); + return getFeatureFlagConfigurationSetting(NEW_KEY, DESCRIPTION_VALUE, DISPLAY_NAME_VALUE, IS_ENABLED, + featureFlagFilters); } private String getFeatureFlagConfigurationSettingValue(String id, String description, String displayName, - boolean isEnabled) { - return String.format("{\"id\":\"%s\",\"description\":\"%s\",\"display_name\":\"%s\"," - + "\"enabled\":%s," + boolean isEnabled) { + return String.format( + "{\"id\":\"%s\",\"description\":\"%s\",\"display_name\":\"%s\"," + "\"enabled\":%s," + "\"conditions\":{\"client_filters\":" - + "[{\"name\":\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]" - + "}}", + + "[{\"name\":\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]" + "}}", id, description, displayName, isEnabled); } private String getUnknownPropertiesFeatureFlagConfigurationSettingValue(String id, String description, String displayName, boolean isEnabled) { - return String.format("{\"id\":\"%s\",\"additional_field_1\":\"additional_value_1\",\"description\":\"%s\",\"display_name\":\"%s\",\"enabled\":%s," + return String.format( + "{\"id\":\"%s\",\"additional_field_1\":\"additional_value_1\",\"description\":\"%s\",\"display_name\":\"%s\",\"enabled\":%s," + "\"conditions\":{\"requirement_type\":\"All\",\"client_filters\":" + "[{\"name\":\"Microsoft.Percentage\",\"parameters\":{\"Value\":30}}]" + "},\"objectFiledName\":{\"unknown\":\"unknown\",\"unknown2\":\"unknown2\"}," @@ -154,10 +154,9 @@ private String getUnknownPropertiesFeatureFlagConfigurationSettingValue(String i private FeatureFlagConfigurationSetting getFeatureFlagConfigurationSetting(String id, String description, String displayName, boolean isEnabled, List filters) { - return new FeatureFlagConfigurationSetting(id, isEnabled) - .setDescription(description) - .setDisplayName(displayName) - .setClientFilters(filters); + return new FeatureFlagConfigurationSetting(id, isEnabled).setDescription(description) + .setDisplayName(displayName) + .setClientFilters(filters); } private FeatureFlagFilter getFlagFilter(String filterName, Map filterParameters) { diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SecretReferenceConfigurationSettingUnitTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SecretReferenceConfigurationSettingUnitTest.java index 295ef865a4cbb..c28c9c1f928b8 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SecretReferenceConfigurationSettingUnitTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SecretReferenceConfigurationSettingUnitTest.java @@ -15,6 +15,7 @@ public class SecretReferenceConfigurationSettingUnitTest { static final String SECRET_ID_VALUE = "https://www.microsoft.com/"; // Updated value static final String UPDATED_SECRET_ID_VALUE = "https://www.microsoft.com/updated"; + @Test public void accessingStronglyTypedPropertiesAfterSettingDifferentSecretReferenceJSON() { // Create a new configuration setting, @@ -51,7 +52,8 @@ public void throwExceptionWhenInvalidNonJsonSecretReferenceValue() { String expectedValue = getSecretReferenceConfigurationSettingValue(SECRET_ID_VALUE); String originalValue = setting.getValue(); assertEquals(expectedValue, originalValue); - assertThrows(IllegalArgumentException.class, () -> setting.setValue("invalidValueForSecretReferenceConfigurationSetting")); + assertThrows(IllegalArgumentException.class, + () -> setting.setValue("invalidValueForSecretReferenceConfigurationSetting")); assertEquals(originalValue, setting.getValue()); assertThrows(IllegalArgumentException.class, () -> setting.getSecretId()); } @@ -59,7 +61,8 @@ public void throwExceptionWhenInvalidNonJsonSecretReferenceValue() { @Test public void reserveUnknownPropertiesTest() { SecretReferenceConfigurationSetting setting = getSecretReferenceConfigurationSetting(NEW_KEY, SECRET_ID_VALUE); - String newSettingValueJSON = getUnknownPropertiesSecretReferenceConfigurationSettingValue(UPDATED_SECRET_ID_VALUE); + String newSettingValueJSON + = getUnknownPropertiesSecretReferenceConfigurationSettingValue(UPDATED_SECRET_ID_VALUE); setting.setValue(newSettingValueJSON); assertEquals(newSettingValueJSON, setting.getValue()); diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SettingSelectorTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SettingSelectorTest.java index 776d75e8ea69c..5e134589b31da 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SettingSelectorTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/SettingSelectorTest.java @@ -14,17 +14,15 @@ public class SettingSelectorTest { @Test public void nullSettingSelectorFields() { final SettingSelector settingSelector = new SettingSelector(); - assertEquals( - "SettingSelector(keyFilter=null, labelFilter=null, acceptDateTime=null, fields=ALL_FIELDS)", + assertEquals("SettingSelector(keyFilter=null, labelFilter=null, acceptDateTime=null, fields=ALL_FIELDS)", settingSelector.toString()); } @Test public void toStringTest() { - final SettingSelector settingSelector = new SettingSelector() - .setFields(SettingFields.ETAG, SettingFields.CONTENT_TYPE); - assertEquals( - "SettingSelector(keyFilter=null, labelFilter=null, acceptDateTime=null, fields=etag,content_type)", + final SettingSelector settingSelector + = new SettingSelector().setFields(SettingFields.ETAG, SettingFields.CONTENT_TYPE); + assertEquals("SettingSelector(keyFilter=null, labelFilter=null, acceptDateTime=null, fields=etag,content_type)", settingSelector.toString()); } } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/TestHelper.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/TestHelper.java index 4f1ad5291d468..8b54381a38490 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/TestHelper.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/TestHelper.java @@ -23,8 +23,8 @@ class TestHelper { static final String DISPLAY_NAME_WITH_ARGUMENTS = "{displayName} with [{arguments}]"; private static final String AZURE_APPCONFIG_TEST_SERVICE_VERSIONS = "AZURE_APPCONFIG_TEST_SERVICE_VERSIONS"; - private static final String SERVICE_VERSION_FROM_ENV = - Configuration.getGlobalConfiguration().get(AZURE_APPCONFIG_TEST_SERVICE_VERSIONS); + private static final String SERVICE_VERSION_FROM_ENV + = Configuration.getGlobalConfiguration().get(AZURE_APPCONFIG_TEST_SERVICE_VERSIONS); /** * Returns a stream of arguments that includes all combinations of eligible {@link HttpClient HttpClients} and @@ -66,8 +66,8 @@ private static boolean shouldServiceVersionBeTested(ConfigurationServiceVersion return true; } String[] configuredServiceVersionList = SERVICE_VERSION_FROM_ENV.split(","); - return Arrays.stream(configuredServiceVersionList).anyMatch(configuredServiceVersion -> - serviceVersion.getVersion().equals(configuredServiceVersion.trim())); + return Arrays.stream(configuredServiceVersionList) + .anyMatch(configuredServiceVersion -> serviceVersion.getVersion().equals(configuredServiceVersion.trim())); } static TokenCredential getTokenCredential(InterceptorManager interceptorManager) { diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialPolicyTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialPolicyTest.java index 68b00e10d2114..b05d8f87b8586 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialPolicyTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationCredentialPolicyTest.java @@ -40,15 +40,11 @@ public void addsRequiredHeadersTest() { return next.process(); }; - final HttpPipeline pipeline = new HttpPipelineBuilder() - .httpClient(new NoOpHttpClient()) + final HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(new NoOpHttpClient()) .policies(configurationCredentialsPolicy, auditorPolicy) .build(); - SyncAsyncExtension.execute( - () -> sendRequestSync(pipeline), - () -> sendRequest(pipeline) - ); + SyncAsyncExtension.execute(() -> sendRequestSync(pipeline), () -> sendRequest(pipeline)); } private Mono sendRequest(HttpPipeline pipeline) { diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializerTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializerTest.java index c046ef6c3dadd..8c13b1e4f7349 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializerTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingDeserializerTest.java @@ -32,19 +32,19 @@ public class ConfigurationSettingDeserializerTest { private static final String FEATURE_FLAG_DISPLAY_NAME = "Feature Flag X"; private static final String SECRET_REFERENCE_URI_VALUE = "https://localhost"; private static final String SETTING_VALUE = "world"; - private static final String FEATURE_FLAG_VALUE_JSON = - "{\"id\":\"hello\",\"display_name\":\"Feature Flag X\",\"enabled\":false," + private static final String FEATURE_FLAG_VALUE_JSON + = "{\"id\":\"hello\",\"display_name\":\"Feature Flag X\",\"enabled\":false," + "\"conditions\":{\"client_filters\":[{\"name\":\"Microsoft.Percentage\",\"parameters\":" + "{\"Value\":30}}]}}"; - private static final String SECRET_REFERENCE_JSON = - "{\"key\":\"hello\",\"value\":\"{\\\"uri\\\":\\\"https://localhost\\\"}\"," + private static final String SECRET_REFERENCE_JSON + = "{\"key\":\"hello\",\"value\":\"{\\\"uri\\\":\\\"https://localhost\\\"}\"," + "\"content_type\":\"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8\"," + "\"etag\":null,\"locked\":false,\"tags\":{}}"; private static final String SECRET_REFERENCE_VALUE_JSON = "{\"uri\":\"https://localhost\"}"; - private static final String CONFIGURATION_SETTING_JSON = - "{\"key\":\"hello\",\"value\":\"world\",\"etag\":null,\"locked\":false,\"tags\":{}}"; + private static final String CONFIGURATION_SETTING_JSON + = "{\"key\":\"hello\",\"value\":\"world\",\"etag\":null,\"locked\":false,\"tags\":{}}"; @Test public void parseFeatureFlagValueTest() { @@ -62,43 +62,34 @@ public void parseSecretReferenceFieldValueTest() { @MethodSource("deserializeSupplier") public void deserialize(String json, T expectedGeo) { if (expectedGeo instanceof FeatureFlagConfigurationSetting) { - final KeyValue mockFeatureFlagSetting = new KeyValue() - .setKey(".appconfig.featureflag/hello") + final KeyValue mockFeatureFlagSetting = new KeyValue().setKey(".appconfig.featureflag/hello") .setValue(FEATURE_FLAG_VALUE_JSON) .setContentType(FEATURE_FLAG_CONTENT_TYPE); - assertFeatureFlagConfigurationSetting( - (FeatureFlagConfigurationSetting) expectedGeo, + assertFeatureFlagConfigurationSetting((FeatureFlagConfigurationSetting) expectedGeo, (FeatureFlagConfigurationSetting) toConfigurationSetting(mockFeatureFlagSetting)); } else if (expectedGeo instanceof SecretReferenceConfigurationSetting) { - final KeyValue mockSecretReferenceSetting = new KeyValue() - .setKey(KEY) + final KeyValue mockSecretReferenceSetting = new KeyValue().setKey(KEY) .setValue(SECRET_REFERENCE_VALUE_JSON) .setContentType(SECRET_REFERENCE_CONTENT_TYPE); - assertSecretReferenceConfigurationSetting( - (SecretReferenceConfigurationSetting) expectedGeo, + assertSecretReferenceConfigurationSetting((SecretReferenceConfigurationSetting) expectedGeo, (SecretReferenceConfigurationSetting) toConfigurationSetting(mockSecretReferenceSetting)); } else { - final KeyValue mockSetting = new KeyValue() - .setKey(KEY) - .setValue(SETTING_VALUE); + final KeyValue mockSetting = new KeyValue().setKey(KEY).setValue(SETTING_VALUE); assertConfigurationSetting(expectedGeo, toConfigurationSetting(mockSetting)); } } public static Stream deserializeSupplier() { - return Stream.of( - Arguments.of(FEATURE_FLAG_VALUE_JSON, getFeatureFlagConfigurationSetting()), + return Stream.of(Arguments.of(FEATURE_FLAG_VALUE_JSON, getFeatureFlagConfigurationSetting()), Arguments.of(SECRET_REFERENCE_JSON, getSecretReferenceConfigurationSetting()), - Arguments.of(CONFIGURATION_SETTING_JSON, getConfigurationSetting()) - ); + Arguments.of(CONFIGURATION_SETTING_JSON, getConfigurationSetting())); } private static FeatureFlagConfigurationSetting getFeatureFlagConfigurationSetting() { - List filters = Collections.singletonList(new FeatureFlagFilter("Microsoft.Percentage") - .setParameters(Collections.singletonMap("Value", 30))); + List filters = Collections.singletonList( + new FeatureFlagFilter("Microsoft.Percentage").setParameters(Collections.singletonMap("Value", 30))); - return new FeatureFlagConfigurationSetting(KEY, false) - .setDisplayName(FEATURE_FLAG_DISPLAY_NAME) + return new FeatureFlagConfigurationSetting(KEY, false).setDisplayName(FEATURE_FLAG_DISPLAY_NAME) .setClientFilters(filters) .setValue(FEATURE_FLAG_VALUE_JSON); } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializerTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializerTest.java index b79254972058f..72b45e67834e8 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializerTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/ConfigurationSettingSerializerTest.java @@ -20,26 +20,26 @@ * Tests for {@link ConfigurationSettingSerializationHelper} */ public class ConfigurationSettingSerializerTest { - private static final String FEATURE_FLAG_VALUE_JSON = - "{\"id\":\"hello\",\"display_name\":\"Feature Flag X\",\"enabled\":false," + private static final String FEATURE_FLAG_VALUE_JSON + = "{\"id\":\"hello\",\"display_name\":\"Feature Flag X\",\"enabled\":false," + "\"conditions\":{\"client_filters\":[{\"name\":\"Microsoft.Percentage\",\"parameters\":" + "{\"Value\":30}}]}}"; private static final String SECRET_REFERENCE_VALUE_JSON = "{\"uri\":\"https://localhost\"}"; @Test public void writeFeatureFlagConfigurationSettingTest() throws IOException { - List filters = Collections.singletonList(new FeatureFlagFilter("Microsoft.Percentage") - .setParameters(Collections.singletonMap("Value", 30))); - final FeatureFlagConfigurationSetting setting = new FeatureFlagConfigurationSetting("hello", false) - .setDisplayName("Feature Flag X") - .setClientFilters(filters); + List filters = Collections.singletonList( + new FeatureFlagFilter("Microsoft.Percentage").setParameters(Collections.singletonMap("Value", 30))); + final FeatureFlagConfigurationSetting setting + = new FeatureFlagConfigurationSetting("hello", false).setDisplayName("Feature Flag X") + .setClientFilters(filters); assertEquals(FEATURE_FLAG_VALUE_JSON, writeFeatureFlagConfigurationSetting(setting)); } @Test public void writeSecretReferenceConfigurationSettingTest() throws IOException { - SecretReferenceConfigurationSetting setting = new SecretReferenceConfigurationSetting("hello", - "https://localhost"); + SecretReferenceConfigurationSetting setting + = new SecretReferenceConfigurationSetting("hello", "https://localhost"); assertEquals(SECRET_REFERENCE_VALUE_JSON, writeSecretReferenceConfigurationSetting(setting)); } } diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicyTest.java b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicyTest.java index cbf93a83c376f..16f18cb627de7 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicyTest.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/implementation/SyncTokenPolicyTest.java @@ -47,8 +47,8 @@ public class SyncTokenPolicyTest { */ @Test public void parseSyncTokenString() { - final SyncToken syncToken = - SyncToken.createSyncToken(constructSyncTokenString(ID, VALUE, SN_NAME, SEQUENCE_NUMBER)); + final SyncToken syncToken + = SyncToken.createSyncToken(constructSyncTokenString(ID, VALUE, SN_NAME, SEQUENCE_NUMBER)); syncTokenEquals(syncToken, ID, VALUE, SEQUENCE_NUMBER); } @@ -141,18 +141,14 @@ public void setSyncTokenPolicyProcessTest() throws MalformedURLException { return next.process(); }; - final HttpPipeline pipeline = - new HttpPipelineBuilder() - .httpClient(new NoOpHttpClient() { + final HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(new NoOpHttpClient() { - @Override - public Mono send(HttpRequest request) { - return Mono.just(new MockHttpResponse(request, 200, - new HttpHeaders().set(SYNC_TOKEN, SYNC_TOKEN_VALUE + ";sn=1"))); - } - }) - .policies(syncTokenPolicy, auditorPolicy) - .build(); + @Override + public Mono send(HttpRequest request) { + return Mono.just( + new MockHttpResponse(request, 200, new HttpHeaders().set(SYNC_TOKEN, SYNC_TOKEN_VALUE + ";sn=1"))); + } + }).policies(syncTokenPolicy, auditorPolicy).build(); HttpRequest request = new HttpRequest(HttpMethod.GET, new URL(LOCAL_HOST)); request.getHeaders().set(REQUEST_ID, FIRST); @@ -200,8 +196,8 @@ public void externalSyncTokensFollowRulesWhenAddedTest() throws MalformedURLExce }; final HttpPipeline pipeline = new HttpPipelineBuilder().httpClient(new NoOpHttpClient()) - .policies(syncTokenPolicy, auditorPolicy) - .build(); + .policies(syncTokenPolicy, auditorPolicy) + .build(); HttpRequest request = new HttpRequest(HttpMethod.GET, new URL(LOCAL_HOST)); SyncAsyncExtension.execute(() -> pipeline.sendSync(request, Context.NONE), () -> pipeline.send(request));