Skip to content

Commit

Permalink
rerun maven in schemaregistry sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mssfang committed Dec 3, 2024
1 parent 88ec9d7 commit 2532641
Show file tree
Hide file tree
Showing 12 changed files with 155 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,7 @@ public String getFullyQualifiedNamespace() {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<SchemaProperties> registerSchema(String groupName, String name, String schemaDefinition,
SchemaFormat format) {
return registerSchemaWithResponse(groupName, name, schemaDefinition, format)
.map(Response::getValue);
return registerSchemaWithResponse(groupName, name, schemaDefinition, format).map(Response::getValue);
}

/**
Expand Down Expand Up @@ -246,8 +245,8 @@ public Mono<SchemaProperties> registerSchema(String groupName, String name, Stri
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<SchemaProperties>> registerSchemaWithResponse(String groupName, String name,
String schemaDefinition, SchemaFormat format) {
return FluxUtil.withContext(context -> registerSchemaWithResponse(groupName, name, schemaDefinition,
format, context));
return FluxUtil
.withContext(context -> registerSchemaWithResponse(groupName, name, schemaDefinition, format, context));
}

Mono<Response<SchemaProperties>> registerSchemaWithResponse(String groupName, String name, String schemaDefinition,
Expand All @@ -269,11 +268,12 @@ Mono<Response<SchemaProperties>> registerSchemaWithResponse(String groupName, St
final com.azure.data.schemaregistry.implementation.models.SchemaFormat contentType
= SchemaRegistryHelper.getContentType(format);

return restService.getSchemas().registerWithResponseAsync(groupName, name, contentType.toString(), binaryData,
binaryData.getLength(), context)
return restService.getSchemas()
.registerWithResponseAsync(groupName, name, contentType.toString(), binaryData, binaryData.getLength(),
context)
.map(response -> {
final SchemaProperties registered = SchemaRegistryHelper.getSchemaProperties(
response.getDeserializedHeaders(), response.getHeaders(), format);
final SchemaProperties registered = SchemaRegistryHelper
.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders(), format);
return new SimpleResponse<>(response, registered);
});
}
Expand Down Expand Up @@ -359,11 +359,12 @@ Mono<Response<SchemaRegistrySchema>> getSchemaWithResponse(String schemaId, Cont
return monoError(logger, new NullPointerException("'schemaId' should not be null."));
}

return this.restService.getSchemas().getByIdWithResponseAsync(schemaId, context)
return this.restService.getSchemas()
.getByIdWithResponseAsync(schemaId, context)
.onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError)
.flatMap(response -> {
SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(
response.getDeserializedHeaders(), response.getHeaders());
SchemaProperties schemaObject = SchemaRegistryHelper
.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders());
return convertToString(response.getValue(), response.getHeaders())
.map(schema -> new SimpleResponse<>(response, new SchemaRegistrySchema(schemaObject, schema)));
});
Expand All @@ -376,22 +377,21 @@ Mono<Response<SchemaRegistrySchema>> getSchemaWithResponse(String groupName, Str
return monoError(logger, new NullPointerException("'groupName' should not be null."));
}

return this.restService.getSchemas().getSchemaVersionWithResponseAsync(groupName, schemaName, schemaVersion,
context)
return this.restService.getSchemas()
.getSchemaVersionWithResponseAsync(groupName, schemaName, schemaVersion, context)
.onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError)
.flatMap(response -> {
final Flux<ByteBuffer> schemaFlux = response.getValue();
SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(
response.getDeserializedHeaders(), response.getHeaders());
SchemaProperties schemaObject = SchemaRegistryHelper
.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders());

if (schemaFlux == null) {
return Mono.error(new IllegalArgumentException(String.format(
"Schema definition should not be null. Group Name: %s. Schema Name: %s. Version: %d",
groupName, schemaName, schemaVersion)));
"Schema definition should not be null. Group Name: %s. Schema Name: %s. Version: %d", groupName,
schemaName, schemaVersion)));
}
return convertToString(schemaFlux, response.getHeaders())
.map(schema -> new SimpleResponse<>(
response.getRequest(), response.getStatusCode(),
.map(schema -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
response.getHeaders(), new SchemaRegistrySchema(schemaObject, schema)));
});
}
Expand Down Expand Up @@ -439,8 +439,8 @@ public Mono<SchemaProperties> getSchemaProperties(String groupName, String name,
public Mono<Response<SchemaProperties>> getSchemaPropertiesWithResponse(String groupName, String name,
String schemaDefinition, SchemaFormat format) {

return FluxUtil.withContext(context ->
getSchemaPropertiesWithResponse(groupName, name, schemaDefinition, format, context));
return FluxUtil.withContext(
context -> getSchemaPropertiesWithResponse(groupName, name, schemaDefinition, format, context));
}

/**
Expand Down Expand Up @@ -485,8 +485,8 @@ Mono<Response<SchemaProperties>> getSchemaPropertiesWithResponse(String groupNam
context)
.onErrorMap(ErrorException.class, SchemaRegistryAsyncClient::remapError)
.map(response -> {
final SchemaProperties properties = SchemaRegistryHelper.getSchemaProperties(
response.getDeserializedHeaders(), response.getHeaders(), format);
final SchemaProperties properties = SchemaRegistryHelper
.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders(), format);

return new SimpleResponse<>(response, properties);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ public Response<SchemaProperties> registerSchemaWithResponse(String groupName, S
final com.azure.data.schemaregistry.implementation.models.SchemaFormat contentType
= SchemaRegistryHelper.getContentType(format);

ResponseBase<SchemasRegisterHeaders, Void> response = restService.getSchemas().registerWithResponse(groupName,
name, contentType.toString(), binaryData, binaryData.getLength(), context);
ResponseBase<SchemasRegisterHeaders, Void> response = restService.getSchemas()
.registerWithResponse(groupName, name, contentType.toString(), binaryData, binaryData.getLength(), context);
final SchemaProperties registered = SchemaRegistryHelper.getSchemaProperties(response.getDeserializedHeaders(),
response.getHeaders(), format);

Expand Down Expand Up @@ -314,13 +314,13 @@ public Response<SchemaRegistrySchema> getSchemaWithResponse(String schemaId, Con
}

try {
ResponseBase<SchemasGetByIdHeaders, BinaryData> response = this.restService.getSchemas()
.getByIdWithResponse(schemaId, context);
SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(response.getDeserializedHeaders(),
response.getHeaders());
ResponseBase<SchemasGetByIdHeaders, BinaryData> response
= this.restService.getSchemas().getByIdWithResponse(schemaId, context);
SchemaProperties schemaObject
= SchemaRegistryHelper.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders());

return new SimpleResponse<>(response, new SchemaRegistrySchema(schemaObject,
convertToString(response.getValue().toStream())));
return new SimpleResponse<>(response,
new SchemaRegistrySchema(schemaObject, convertToString(response.getValue().toStream())));
} catch (ErrorException ex) {
throw logger.logExceptionAsError(SchemaRegistryAsyncClient.remapError(ex));
}
Expand All @@ -343,22 +343,22 @@ public Response<SchemaRegistrySchema> getSchemaWithResponse(String schemaId, Con
* @throws UncheckedIOException if an error occurred while deserializing response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<SchemaRegistrySchema> getSchemaWithResponse(String groupName, String schemaName,
int schemaVersion, Context context) {
public Response<SchemaRegistrySchema> getSchemaWithResponse(String groupName, String schemaName, int schemaVersion,
Context context) {
if (Objects.isNull(groupName)) {
throw logger.logExceptionAsError(new NullPointerException("'groupName' should not be null."));
}

ResponseBase<SchemasGetSchemaVersionHeaders, BinaryData> response = this.restService.getSchemas()
.getSchemaVersionWithResponse(groupName, schemaName, schemaVersion, context);
ResponseBase<SchemasGetSchemaVersionHeaders, BinaryData> response
= this.restService.getSchemas().getSchemaVersionWithResponse(groupName, schemaName, schemaVersion, context);
InputStream schemaInputStream = response.getValue().toStream();
SchemaProperties schemaObject = SchemaRegistryHelper.getSchemaProperties(response.getDeserializedHeaders(),
response.getHeaders());
SchemaProperties schemaObject
= SchemaRegistryHelper.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders());

if (schemaInputStream == null) {
throw logger.logExceptionAsError(new IllegalArgumentException(String.format(
"Schema definition should not be null. Group Name: %s. Schema Name: %s. Version: %d",
groupName, schemaName, schemaVersion)));
throw logger.logExceptionAsError(new IllegalArgumentException(
String.format("Schema definition should not be null. Group Name: %s. Schema Name: %s. Version: %d",
groupName, schemaName, schemaVersion)));
}

return new SimpleResponse<>(response,
Expand Down Expand Up @@ -426,11 +426,11 @@ public Response<SchemaProperties> getSchemaPropertiesWithResponse(String groupNa
= SchemaRegistryHelper.getContentType(format);

try {
ResponseBase<SchemasQueryIdByContentHeaders, Void> response = restService.getSchemas()
ResponseBase<SchemasQueryIdByContentHeaders, Void> response = restService.getSchemas()
.queryIdByContentWithResponse(groupName, name, contentType, binaryData, binaryData.getLength(),
context);
final SchemaProperties properties = SchemaRegistryHelper.getSchemaProperties(
response.getDeserializedHeaders(), response.getHeaders(), format);
final SchemaProperties properties = SchemaRegistryHelper
.getSchemaProperties(response.getDeserializedHeaders(), response.getHeaders(), format);
return new SimpleResponse<>(response, properties);
} catch (ErrorException ex) {
throw logger.logExceptionAsError(SchemaRegistryAsyncClient.remapError(ex));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@
* </pre>
* <!-- end com.azure.data.schemaregistry.schemaregistryasyncclient.retrypolicy.construct -->
*/
@ServiceClientBuilder(serviceClients = {SchemaRegistryAsyncClient.class, SchemaRegistryClient.class})
public class SchemaRegistryClientBuilder implements
ConfigurationTrait<SchemaRegistryClientBuilder>,
HttpTrait<SchemaRegistryClientBuilder>,
TokenCredentialTrait<SchemaRegistryClientBuilder> {
@ServiceClientBuilder(serviceClients = { SchemaRegistryAsyncClient.class, SchemaRegistryClient.class })
public class SchemaRegistryClientBuilder implements ConfigurationTrait<SchemaRegistryClientBuilder>,
HttpTrait<SchemaRegistryClientBuilder>, TokenCredentialTrait<SchemaRegistryClientBuilder> {
private final ClientLogger logger = new ClientLogger(SchemaRegistryClientBuilder.class);

private static final String DEFAULT_SCOPE = "https://eventhubs.azure.net/.default";
Expand Down Expand Up @@ -392,13 +390,12 @@ private AzureSchemaRegistryImpl getAzureSchemaRegistryImplService() {
"'fullyQualifiedNamespace' cannot be null and must be set via builder.fullyQualifiedNamespace(String)");

if (CoreUtils.isNullOrEmpty(fullyQualifiedNamespace)) {
throw logger.logExceptionAsError(new IllegalArgumentException(
"'fullyQualifiedNamespace' cannot be an empty string."));
throw logger.logExceptionAsError(
new IllegalArgumentException("'fullyQualifiedNamespace' cannot be an empty string."));
}

Configuration buildConfiguration = (configuration == null)
? Configuration.getGlobalConfiguration()
: configuration;
Configuration buildConfiguration
= (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;

HttpPipeline buildPipeline = this.httpPipeline;
// Create a default Pipeline if it is not given
Expand Down Expand Up @@ -435,8 +432,7 @@ private AzureSchemaRegistryImpl getAzureSchemaRegistryImplService() {

policies.add(new HttpLoggingPolicy(httpLogOptions));

buildPipeline = new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
buildPipeline = new HttpPipelineBuilder().policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.clientOptions(clientOptions)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
* Helper to access private-package methods of models.
*/
public final class SchemaRegistryHelper {
private static final HashMap<String, com.azure.data.schemaregistry.implementation.models.SchemaFormat>
SCHEMA_FORMAT_HASH_MAP = new HashMap<>();
private static final HashMap<String, com.azure.data.schemaregistry.implementation.models.SchemaFormat> SCHEMA_FORMAT_HASH_MAP
= new HashMap<>();
private static final Pattern SCHEMA_FORMAT_PATTERN = Pattern.compile("\\s");

private static SchemaRegistryModelsAccessor accessor;

static {
com.azure.data.schemaregistry.implementation.models.SchemaFormat.values().forEach(value -> {
final String mimeTypeLower = SCHEMA_FORMAT_PATTERN.matcher(value.toString()).replaceAll("")
.toLowerCase(Locale.ROOT);
final String mimeTypeLower
= SCHEMA_FORMAT_PATTERN.matcher(value.toString()).replaceAll("").toLowerCase(Locale.ROOT);

SCHEMA_FORMAT_HASH_MAP.put(mimeTypeLower, value);
});
Expand Down Expand Up @@ -88,8 +88,8 @@ public static SchemaProperties getSchemaProperties(SchemasGetSchemaVersionHeader
deserializedHeaders.getSchemaVersion());
}

public static com.azure.data.schemaregistry.implementation.models.SchemaFormat getContentType(
SchemaFormat schemaFormat) {
public static com.azure.data.schemaregistry.implementation.models.SchemaFormat
getContentType(SchemaFormat schemaFormat) {
Objects.requireNonNull(schemaFormat, "'schemaFormat' cannot be null.'");

if (schemaFormat == SchemaFormat.AVRO) {
Expand All @@ -114,12 +114,11 @@ public static SchemaFormat getSchemaFormat(HttpHeaders headers) {
return null;
}

final String replaced = SCHEMA_FORMAT_PATTERN.matcher(contentType).replaceAll("")
.toLowerCase(Locale.ROOT);
final String replaced = SCHEMA_FORMAT_PATTERN.matcher(contentType).replaceAll("").toLowerCase(Locale.ROOT);

// Default value if nothing matches is CUSTOM.
final com.azure.data.schemaregistry.implementation.models.SchemaFormat implementationFormat =
SCHEMA_FORMAT_HASH_MAP.getOrDefault(replaced,
final com.azure.data.schemaregistry.implementation.models.SchemaFormat implementationFormat
= SCHEMA_FORMAT_HASH_MAP.getOrDefault(replaced,
com.azure.data.schemaregistry.implementation.models.SchemaFormat.TEXT_PLAIN_CHARSET_UTF8);

if (com.azure.data.schemaregistry.implementation.models.SchemaFormat.APPLICATION_JSON_SERIALIZATION_AVRO
Expand All @@ -133,4 +132,3 @@ public static SchemaFormat getSchemaFormat(HttpHeaders headers) {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ class Constants {

static final String PLAYBACK_ENDPOINT = "https://foo.servicebus.windows.net";

static final String SCHEMA_REGISTRY_AVRO_FULLY_QUALIFIED_NAMESPACE = "SCHEMA_REGISTRY_AVRO_FULLY_QUALIFIED_NAMESPACE";
static final String SCHEMA_REGISTRY_AVRO_FULLY_QUALIFIED_NAMESPACE
= "SCHEMA_REGISTRY_AVRO_FULLY_QUALIFIED_NAMESPACE";

static final String SCHEMA_REGISTRY_CUSTOM_FULLY_QUALIFIED_NAMESPACE = "SCHEMA_REGISTRY_CUSTOM_FULLY_QUALIFIED_NAMESPACE";
static final String SCHEMA_REGISTRY_CUSTOM_FULLY_QUALIFIED_NAMESPACE
= "SCHEMA_REGISTRY_CUSTOM_FULLY_QUALIFIED_NAMESPACE";

static final String SCHEMA_REGISTRY_JSON_FULLY_QUALIFIED_NAMESPACE = "SCHEMA_REGISTRY_JSON_FULLY_QUALIFIED_NAMESPACE";
static final String SCHEMA_REGISTRY_JSON_FULLY_QUALIFIED_NAMESPACE
= "SCHEMA_REGISTRY_JSON_FULLY_QUALIFIED_NAMESPACE";

static final String SCHEMA_REGISTRY_GROUP = "SCHEMA_REGISTRY_GROUP";
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected void beforeTest() {
String endpoint;
String schemaGroup;
if (interceptorManager.isPlaybackMode()) {
tokenCredential = tokenRequestContext ->
Mono.fromCallable(() -> new AccessToken("foo", OffsetDateTime.now().plusMinutes(20)));
tokenCredential = tokenRequestContext -> Mono
.fromCallable(() -> new AccessToken("foo", OffsetDateTime.now().plusMinutes(20)));
schemaGroup = PLAYBACK_TEST_GROUP;
endpoint = PLAYBACK_ENDPOINT;
} else {
Expand All @@ -47,9 +47,7 @@ protected void beforeTest() {
assertNotNull(schemaGroup, "'schemaGroup' cannot be null in LIVE/RECORD mode.");
}

builder = new SchemaRegistryClientBuilder()
.credential(tokenCredential)
.fullyQualifiedNamespace(endpoint);
builder = new SchemaRegistryClientBuilder().credential(tokenCredential).fullyQualifiedNamespace(endpoint);

if (interceptorManager.isPlaybackMode()) {
builder.httpClient(buildAsyncAssertingClient(interceptorManager.getPlaybackClient()));
Expand All @@ -61,8 +59,7 @@ protected void beforeTest() {
}

private HttpClient buildAsyncAssertingClient(HttpClient httpClient) {
return new AssertingHttpClientBuilder(httpClient)
.assertAsync()
return new AssertingHttpClientBuilder(httpClient).assertAsync()
.skipRequest((httpRequest, context) -> false)
.build();
}
Expand Down
Loading

0 comments on commit 2532641

Please sign in to comment.