Skip to content

Commit

Permalink
Enable Spotless for azure-data-appconfiguration and azure-data-appcon…
Browse files Browse the repository at this point in the history
…figuration-perf (#41950)
  • Loading branch information
alzimmermsft authored Sep 19, 2024
1 parent 74cc6ab commit 93c25d8
Show file tree
Hide file tree
Showing 34 changed files with 1,275 additions and 1,193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<properties>
<perf.test.mainClass>com.azure.data.appconfiguration.perf.App</perf.test.mainClass>
<perf.test.imageName>azure-data-appconfiguration-perf</perf.test.imageName>
<spotless.skip>false</spotless.skip>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public ListConfigurationSettingsTest(PerfStressOptions options) {
public Mono<Void> globalSetupAsync() {
List<Mono<ConfigurationSetting>> 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();
Expand All @@ -48,8 +48,8 @@ public Mono<Void> globalSetupAsync() {
public Mono<Void> globalCleanupAsync() {
List<Mono<ConfigurationSetting>> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* Base class for Azure App Configuration performance tests.
*/
public abstract class ServiceTest<TOptions extends PerfStressOptions> extends PerfStressTest<TOptions> {
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;
Expand All @@ -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();
}
}
1 change: 1 addition & 0 deletions sdk/appconfiguration/azure-data-appconfiguration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</javaModulesSurefireArgLine>
<graalvm.disable>false</graalvm.disable>
<nativeImage.buildArgs>--initialize-at-build-time=com.azure.data.appconfiguration.TestHelper</nativeImage.buildArgs>
<spotless.skip>false</spotless.skip>
</properties>

<dependencies>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -432,9 +433,8 @@ public Response<ConfigurationSetting> 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<PutKeyValueHeaders, KeyValue> response =
serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), null, ETAG_ANY,
toKeyValue(setting), context);
final ResponseBase<PutKeyValueHeaders, KeyValue> response = serviceClient.putKeyValueWithResponse(
setting.getKey(), setting.getLabel(), null, ETAG_ANY, toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}

Expand Down Expand Up @@ -578,9 +578,8 @@ public ConfigurationSetting setConfigurationSetting(ConfigurationSetting setting
public Response<ConfigurationSetting> setConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged, Context context) {
validateSetting(setting);
final ResponseBase<PutKeyValueHeaders, KeyValue> response =
serviceClient.putKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting),
null, toKeyValue(setting), context);
final ResponseBase<PutKeyValueHeaders, KeyValue> response = serviceClient.putKeyValueWithResponse(
setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), null, toKeyValue(setting), context);
return toConfigurationSettingWithResponse(response);
}

Expand Down Expand Up @@ -723,10 +722,9 @@ public Response<ConfigurationSetting> getConfigurationSettingWithResponse(Config
OffsetDateTime acceptDateTime, boolean ifChanged, Context context) {
validateSetting(setting);
try {
final ResponseBase<GetKeyValueHeaders, KeyValue> response =
serviceClient.getKeyValueWithResponse(setting.getKey(), setting.getLabel(),
acceptDateTime == null ? null : acceptDateTime.toString(), null, getETag(ifChanged, setting), null,
context);
final ResponseBase<GetKeyValueHeaders, KeyValue> 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();
Expand Down Expand Up @@ -762,8 +760,8 @@ public Response<ConfigurationSetting> 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();
}

/**
Expand Down Expand Up @@ -850,9 +848,8 @@ public ConfigurationSetting deleteConfigurationSetting(ConfigurationSetting sett
public Response<ConfigurationSetting> deleteConfigurationSettingWithResponse(ConfigurationSetting setting,
boolean ifUnchanged, Context context) {
validateSetting(setting);
final ResponseBase<DeleteKeyValueHeaders, KeyValue> response =
serviceClient.deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(),
getETag(ifUnchanged, setting), context);
final ResponseBase<DeleteKeyValueHeaders, KeyValue> response = serviceClient
.deleteKeyValueWithResponse(setting.getKey(), setting.getLabel(), getETag(ifUnchanged, setting), context);
return toConfigurationSettingWithResponse(response);
}

Expand Down Expand Up @@ -1062,29 +1059,25 @@ public PagedIterable<ConfigurationSetting> listConfigurationSettings(SettingSele
final List<String> tagsFilter = selector == null ? null : selector.getTagsFilter();

AtomicInteger pageETagIndex = new AtomicInteger(0);
return new PagedIterable<>(
() -> {
PagedResponse<KeyValue> 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<KeyValue> 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<KeyValue> 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<KeyValue> pagedResponse;
try {
pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, acceptDateTime, null,
getPageETag(matchConditionsList, pageETagIndex), context);
} catch (HttpResponseException ex) {
return handleNotModifiedErrorToValidResponse(ex, LOGGER);
}
return toConfigurationSettingWithPagedResponse(pagedResponse);
});
}

/**
Expand Down Expand Up @@ -1148,8 +1141,8 @@ public PagedIterable<ConfigurationSetting> listConfigurationSettingsForSnapshot(
fields, snapshotName, null, null, null, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
}, nextLink -> {
final PagedResponse<KeyValue> pagedResponse = serviceClient.getKeyValuesNextSinglePage(nextLink, null, null,
null, context);
final PagedResponse<KeyValue> pagedResponse
= serviceClient.getKeyValuesNextSinglePage(nextLink, null, null, null, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
});
}
Expand Down Expand Up @@ -1224,11 +1217,11 @@ public PagedIterable<ConfigurationSetting> listRevisions(SettingSelector selecto
final PagedResponse<KeyValue> 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<KeyValue> pagedResponse = serviceClient.getRevisionsNextSinglePage(nextLink,
acceptDateTime, context);
final PagedResponse<KeyValue> pagedResponse
= serviceClient.getRevisionsNextSinglePage(nextLink, acceptDateTime, context);
return toConfigurationSettingWithPagedResponse(pagedResponse);
});
}
Expand Down Expand Up @@ -1265,8 +1258,8 @@ public PagedIterable<ConfigurationSetting> listRevisions(SettingSelector selecto
* has failed. The completed operation returns a {@link ConfigurationSnapshot}.
*/
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<PollOperationDetails, ConfigurationSnapshot> beginCreateSnapshot(
String snapshotName, ConfigurationSnapshot snapshot, Context context) {
public SyncPoller<PollOperationDetails, ConfigurationSnapshot> beginCreateSnapshot(String snapshotName,
ConfigurationSnapshot snapshot, Context context) {
return createSnapshotUtilClient.beginCreateSnapshot(snapshotName, snapshot, context);
}

Expand Down Expand Up @@ -1324,9 +1317,9 @@ public ConfigurationSnapshot getSnapshot(String snapshotName) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<ConfigurationSnapshot> getSnapshotWithResponse(String snapshotName, List<SnapshotFields> fields,
Context context) {
final ResponseBase<GetSnapshotHeaders, ConfigurationSnapshot> response =
serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context);
Context context) {
final ResponseBase<GetSnapshotHeaders, ConfigurationSnapshot> response
= serviceClient.getSnapshotWithResponse(snapshotName, null, null, fields, context);
return new SimpleResponse<>(response, response.getValue());
}

Expand All @@ -1349,8 +1342,8 @@ public Response<ConfigurationSnapshot> 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();
}

/**
Expand Down Expand Up @@ -1408,8 +1401,8 @@ public Response<ConfigurationSnapshot> 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();
}

/**
Expand Down Expand Up @@ -1496,9 +1489,10 @@ public PagedIterable<ConfigurationSnapshot> listSnapshots(SnapshotSelector selec
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<ConfigurationSnapshot> 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));
}

Expand Down Expand Up @@ -1580,7 +1574,8 @@ public PagedIterable<SettingLabel> listLabels(SettingLabelSelector selector) {
public PagedIterable<SettingLabel> 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<SettingLabelFields> labelFields = selector == null ? null : selector.getFields();
return serviceClient.getLabels(labelNameFilter, null, acceptDatetime, labelFields, context);
}
Expand Down
Loading

0 comments on commit 93c25d8

Please sign in to comment.