From 1ea2d78c416ae556ab16c1d1540b1469216d22cd Mon Sep 17 00:00:00 2001 From: Connie Yau Date: Wed, 13 Apr 2022 23:29:55 -0700 Subject: [PATCH] Renames MessageWithMetadata to MessageContent (#28096) * Updating CHANGELOG. * Rename class to MessageContent. * Move MessageContent to com.azure. * Remove unused package-info.java. * Remove unused module-info.java * Update CHANGELOG. * Update to use unreleased_azure.core dependency and rename MessageContent. --- eng/versioning/version_client.txt | 1 + sdk/core/azure-core-experimental/CHANGELOG.md | 2 + .../experimental/models/package-info.java | 7 ---- .../src/main/java/module-info.java | 2 - sdk/core/azure-core/CHANGELOG.md | 2 + .../azure/core/models/MessageContent.java} | 12 +++--- .../core/models/MessageContentTest.java} | 12 +++--- .../CHANGELOG.md | 2 +- .../README.md | 6 +-- .../pom.xml | 7 +--- .../SchemaRegistryApacheAvroSerializer.java | 40 +++++++++---------- .../src/main/java/module-info.java | 2 +- .../apacheavro/ComplexMessage.java | 4 +- .../apacheavro/ReadmeSamples.java | 12 +++--- ...pacheAvroSerializerJavaDocCodeSamples.java | 8 ++-- ...emaRegistryApacheAvroSerializerSample.java | 6 +-- ...hemaRegistryAvroDeserializationSample.java | 8 ++-- ...ryApacheAvroSerializerIntegrationTest.java | 6 +-- ...chemaRegistryApacheAvroSerializerTest.java | 18 ++++----- 19 files changed, 74 insertions(+), 83 deletions(-) delete mode 100644 sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/package-info.java rename sdk/core/{azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java => azure-core/src/main/java/com/azure/core/models/MessageContent.java} (74%) rename sdk/core/{azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java => azure-core/src/test/java/com/azure/core/models/MessageContentTest.java} (75%) diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 8571c90ebffe2..1de70d642e7ec 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -345,6 +345,7 @@ com.azure.tools:azure-sdk-build-tool;1.0.0-beta.1;1.0.0-beta.2 # In the pom, the version update tag after the version should name the unreleased package and the dependency version: # unreleased_com.azure:azure-aot-graalvm-perf;1.0.0-beta.1 +unreleased_com.azure:azure-core;1.28.0-beta.1 # Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current # version and set the version to the released beta. Released beta dependencies are only valid diff --git a/sdk/core/azure-core-experimental/CHANGELOG.md b/sdk/core/azure-core-experimental/CHANGELOG.md index 044c3b1a02c28..30dfac4dd5926 100644 --- a/sdk/core/azure-core-experimental/CHANGELOG.md +++ b/sdk/core/azure-core-experimental/CHANGELOG.md @@ -6,6 +6,8 @@ ### Breaking Changes +- Move `MessageWithMetadata` to `com.azure` package as `com.azure.core.models.MessageContent`. + ### Bugs Fixed ### Other Changes diff --git a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/package-info.java b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/package-info.java deleted file mode 100644 index da6e2700c0b0e..0000000000000 --- a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -/** - * Package containing experimental model classes. - */ -package com.azure.core.experimental.models; diff --git a/sdk/core/azure-core-experimental/src/main/java/module-info.java b/sdk/core/azure-core-experimental/src/main/java/module-info.java index 6addb1a8ece0a..dbc0343a02f74 100644 --- a/sdk/core/azure-core-experimental/src/main/java/module-info.java +++ b/sdk/core/azure-core-experimental/src/main/java/module-info.java @@ -9,7 +9,5 @@ exports com.azure.core.experimental.http; exports com.azure.core.experimental.http.policy; - exports com.azure.core.experimental.models; - uses com.azure.core.experimental.serializer.AvroSerializerProvider; } diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 767fdb6ac87b2..4ccb04d3cf5d7 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -4,6 +4,8 @@ ### Features Added +- Add `com.azure.core.models.MessageContent`. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java b/sdk/core/azure-core/src/main/java/com/azure/core/models/MessageContent.java similarity index 74% rename from sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java rename to sdk/core/azure-core/src/main/java/com/azure/core/models/MessageContent.java index 7b0a9ccdbd4d5..5f0093dd225d4 100644 --- a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/models/MessageContent.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.core.experimental.models; +package com.azure.core.models; import com.azure.core.annotation.Fluent; import com.azure.core.util.BinaryData; @@ -10,7 +10,7 @@ * An abstraction for a message containing a content type along with its data. */ @Fluent -public class MessageWithMetadata { +public class MessageContent { private BinaryData binaryData; private String contentType; @@ -28,9 +28,9 @@ public BinaryData getBodyAsBinaryData() { * * @param binaryData The message body. * - * @return The updated {@link MessageWithMetadata} object. + * @return The updated {@link MessageContent} object. */ - public MessageWithMetadata setBodyAsBinaryData(BinaryData binaryData) { + public MessageContent setBodyAsBinaryData(BinaryData binaryData) { this.binaryData = binaryData; return this; } @@ -49,9 +49,9 @@ public String getContentType() { * * @param contentType The content type. * - * @return The updated {@link MessageWithMetadata} object. + * @return The updated {@link MessageContent} object. */ - public MessageWithMetadata setContentType(String contentType) { + public MessageContent setContentType(String contentType) { this.contentType = contentType; return this; } diff --git a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java b/sdk/core/azure-core/src/test/java/com/azure/core/models/MessageContentTest.java similarity index 75% rename from sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java rename to sdk/core/azure-core/src/test/java/com/azure/core/models/MessageContentTest.java index ebe19fa1a9fc6..d606592c0ec12 100644 --- a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/models/MessageContentTest.java @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -package com.azure.core.experimental.models; +package com.azure.core.models; import com.azure.core.util.BinaryData; import org.junit.jupiter.api.Test; @@ -9,16 +9,16 @@ import static org.junit.jupiter.api.Assertions.assertNull; /** - * Tests for {@link MessageWithMetadata} + * Tests for {@link MessageContent} */ -public class MessageWithMetadataTest { +public class MessageContentTest { /** * Verify default parameters. */ @Test public void initialize() { // Act - final MessageWithMetadata message = new MessageWithMetadata(); + final MessageContent message = new MessageContent(); // Assert assertNull(message.getBodyAsBinaryData(), "'body' should initially be null."); @@ -33,10 +33,10 @@ public void settingProperties() { // Arrange final BinaryData binaryData = BinaryData.fromString("foo.bar.baz"); final String contentType = "some-content"; - final MessageWithMetadata message = new MessageWithMetadata(); + final MessageContent message = new MessageContent(); // Act - final MessageWithMetadata actual = message.setContentType(contentType) + final MessageContent actual = message.setContentType(contentType) .setBodyAsBinaryData(binaryData); // Assert diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md index 02b9d8067282c..c4214c35b9e16 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md @@ -42,7 +42,7 @@ ### Features Added -- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageWithMetadata` rather than tied to a binary format +- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageContent` rather than tied to a binary format with preamble. Backwards compatibility with preamble format supported for this release. See issue #26449. ### Breaking Changes diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md index 79632e20dfd84..cf8b42707945e 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md @@ -101,8 +101,8 @@ playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); -MessageWithMetadata message = serializer.serializeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); +MessageContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(MessageContent.class)); ``` The avro type `PlayingCard` is available in samples package @@ -113,7 +113,7 @@ Deserialize a Schema Registry-compatible avro payload into a strongly-type objec ```java readme-sample-deserializeSample SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); -MessageWithMetadata message = getSchemaRegistryAvroMessage(); +MessageContent message = getSchemaRegistryAvroMessage(); PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); ``` diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index c0e57ceda6d78..b437038131881 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -47,12 +47,7 @@ com.azure azure-core - 1.27.0 - - - com.azure - azure-core-experimental - 1.0.0-beta.26 + 1.28.0-beta.1 com.azure diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java index 684e0ce66d2a7..96aeecd6b8f8f 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java @@ -5,7 +5,7 @@ import com.azure.core.exception.HttpResponseException; import com.azure.core.exception.ResourceNotFoundException; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import com.azure.core.util.BinaryData; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; @@ -50,9 +50,9 @@ * * *

Serialize an object

- * Serializes an Avro generated object into {@link MessageWithMetadata}. + * Serializes an Avro generated object into {@link MessageContent}. * {@link #serializeMessageData(Object, TypeReference)} assumes that there is a no argument constructor used to - * instantiate the {@link MessageWithMetadata} type. If there is a different way to instantiate the concrete type, use + * instantiate the {@link MessageContent} type. If there is a different way to instantiate the concrete type, use * the overload which takes a message factory function, {@link #serializeMessageData(Object, TypeReference, Function)}. * * @@ -73,8 +73,8 @@ * .setFavouriteColour("Turquoise") * .build(); * - * MessageWithMetadata message = serializer.serializeMessageData(person, - * TypeReference.createInstance(MessageWithMetadata.class)); + * MessageContent message = serializer.serializeMessageData(person, + * TypeReference.createInstance(MessageContent.class)); * * * @@ -82,7 +82,7 @@ * *
  * // Message to deserialize. Assume that the body contains data which has been serialized using an Avro encoder.
- * MessageWithMetadata message = new MessageWithMetadata()
+ * MessageContent message = new MessageContent()
  *     .setBodyAsBinaryData(BinaryData.fromBytes(new byte[0]))
  *     .setContentType("avro/binary+{schema-id}");
  *
@@ -92,7 +92,7 @@
  * 
  *
  * 

Serialize an object using a message factory

- * Serializes an Avro generated object into {@link MessageWithMetadata}. It uses the {@link Function messageFactory} to + * Serializes an Avro generated object into {@link MessageContent}. It uses the {@link Function messageFactory} to * instantiate and populate the type. * * @@ -154,7 +154,7 @@ public final class SchemaRegistryApacheAvroSerializer { * * @param object Object to serialize. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return The message encoded or {@code null} if the message could not be serialized. * @@ -168,7 +168,7 @@ public final class SchemaRegistryApacheAvroSerializer { * SchemaRegistryApacheAvroSerializerBuilder#autoRegisterSchema(boolean)} is false. * @throws HttpResponseException if an error occurred while trying to fetch the schema from the service. */ - public T serializeMessageData(Object object, TypeReference typeReference) { + public T serializeMessageData(Object object, TypeReference typeReference) { return serializeMessageDataAsync(object, typeReference).block(); } @@ -178,7 +178,7 @@ public T serializeMessageData(Object object, Typ * @param object Object to serialize. * @param typeReference Type of message to create. * @param messageFactory Factory to create an instance given the serialized Avro. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return The message encoded or {@code null} if the message could not be serialized. * @@ -191,7 +191,7 @@ public T serializeMessageData(Object object, Typ * SchemaRegistryApacheAvroSerializerBuilder#autoRegisterSchema(boolean)} is false. * @throws HttpResponseException if an error occurred while trying to fetch the schema from the service. */ - public T serializeMessageData(Object object, TypeReference typeReference, + public T serializeMessageData(Object object, TypeReference typeReference, Function messageFactory) { return serializeMessageDataAsync(object, typeReference, messageFactory).block(); } @@ -201,7 +201,7 @@ public T serializeMessageData(Object object, Typ * * @param object Object to serialize. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return A Mono that completes with the serialized message. * @@ -214,7 +214,7 @@ public T serializeMessageData(Object object, Typ * SchemaRegistryApacheAvroSerializerBuilder#autoRegisterSchema(boolean)} is false. * @throws HttpResponseException if an error occurred while trying to fetch the schema from the service. */ - public Mono serializeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference) { return serializeMessageDataAsync(object, typeReference, null); @@ -227,7 +227,7 @@ public Mono serializeMessageDataAsync(Object * @param typeReference Type of message to create. * @param messageFactory Factory to create an instance given the serialized Avro. If null is passed in, then the * no argument constructor will be used. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return A Mono that completes with the serialized message. * @@ -240,7 +240,7 @@ public Mono serializeMessageDataAsync(Object * SchemaRegistryApacheAvroSerializerBuilder#autoRegisterSchema(boolean)} is false. * @throws HttpResponseException if an error occurred while trying to fetch the schema from the service. */ - public Mono serializeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference, Function messageFactory) { if (object == null) { @@ -304,7 +304,7 @@ public Mono serializeMessageDataAsync(Object * * @param message Object to deserialize. * @param typeReference Message type to deserialize to. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return The message deserialized. * @@ -318,7 +318,7 @@ public Mono serializeMessageDataAsync(Object * SchemaRegistryApacheAvroSerializerBuilder#autoRegisterSchema(boolean)} is false. * @throws HttpResponseException if an error occurred while trying to fetch the schema from the service. */ - public T deserializeMessageData(MessageWithMetadata message, TypeReference typeReference) { + public T deserializeMessageData(MessageContent message, TypeReference typeReference) { return deserializeMessageDataAsync(message, typeReference).block(); } @@ -327,7 +327,7 @@ public T deserializeMessageData(MessageWithMetadata message, TypeReference Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link MessageContent}. * * @return A Mono that completes when the message encoded. If {@code message.getBodyAsBinaryData()} is null or * empty, then an empty Mono is returned. @@ -342,7 +342,7 @@ public T deserializeMessageData(MessageWithMetadata message, TypeReference Mono deserializeMessageDataAsync(MessageWithMetadata message, TypeReference typeReference) { + public Mono deserializeMessageDataAsync(MessageContent message, TypeReference typeReference) { if (message == null) { return monoError(logger, new NullPointerException("'message' cannot be null.")); } else if (typeReference == null) { @@ -433,7 +433,7 @@ public Mono deserializeMessageDataAsync(MessageWithMetadata message, Type * @throws RuntimeException if an instance of {@code T} could not be instantiated. */ @SuppressWarnings("unchecked") - private static T createNoArgumentInstance(TypeReference typeReference) { + private static T createNoArgumentInstance(TypeReference typeReference) { final Optional> constructor = Arrays.stream(typeReference.getJavaClass().getDeclaredConstructors()) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/module-info.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/module-info.java index 9d1510c4b99e5..9384876707438 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/module-info.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/module-info.java @@ -2,8 +2,8 @@ // Licensed under the MIT License. module com.azure.data.schemaregistry.apacheavro { + requires transitive com.azure.core; requires transitive com.azure.data.schemaregistry; - requires transitive com.azure.core.experimental; requires org.apache.avro; diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ComplexMessage.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ComplexMessage.java index 27bf2c94c4fbd..ab8300377752c 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ComplexMessage.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ComplexMessage.java @@ -2,14 +2,14 @@ // Licensed under the MIT License. package com.azure.data.schemaregistry.apacheavro; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import java.time.OffsetDateTime; /** * Sample type used in {@link SchemaRegistryApacheAvroSerializerJavaDocCodeSamples#serializeMessageFactory()}. */ -public class ComplexMessage extends MessageWithMetadata { +public class ComplexMessage extends MessageContent { private final String id; private final OffsetDateTime creationTime; diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java index 2944d58c1f855..b6b70c0d93975 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/ReadmeSamples.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; @@ -56,8 +56,8 @@ public void serializeSample() { playingCard.setIsFaceCard(false); playingCard.setCardValue(5); - MessageWithMetadata message = serializer.serializeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); + MessageContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(MessageContent.class)); // END: readme-sample-serializeSample } @@ -67,7 +67,7 @@ public void serializeSample() { public void deserializeSample() { // BEGIN: readme-sample-deserializeSample SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); - MessageWithMetadata message = getSchemaRegistryAvroMessage(); + MessageContent message = getSchemaRegistryAvroMessage(); PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // END: readme-sample-deserializeSample } @@ -76,8 +76,8 @@ public void deserializeSample() { * Non-functional method not visible on README sample * @return a new message. */ - private MessageWithMetadata getSchemaRegistryAvroMessage() { - return new MessageWithMetadata() + private MessageContent getSchemaRegistryAvroMessage() { + return new MessageContent() .setBodyAsBinaryData(BinaryData.fromBytes(new byte[1])) .setContentType("avro/binary+schema_id"); } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerJavaDocCodeSamples.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerJavaDocCodeSamples.java index 5fa4000f3693c..1037b79021f0d 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerJavaDocCodeSamples.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerJavaDocCodeSamples.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; @@ -69,8 +69,8 @@ public void serialize() { .setFavouriteColour("Turquoise") .build(); - MessageWithMetadata message = serializer.serializeMessageData(person, - TypeReference.createInstance(MessageWithMetadata.class)); + MessageContent message = serializer.serializeMessageData(person, + TypeReference.createInstance(MessageContent.class)); // END: com.azure.data.schemaregistry.apacheavro.schemaregistryapacheavroserializer.serialize } @@ -110,7 +110,7 @@ public void serializeMessageFactory() { public void deserialize() { // BEGIN: com.azure.data.schemaregistry.apacheavro.schemaregistryapacheavroserializer.deserialize // Message to deserialize. Assume that the body contains data which has been serialized using an Avro encoder. - MessageWithMetadata message = new MessageWithMetadata() + MessageContent message = new MessageContent() .setBodyAsBinaryData(BinaryData.fromBytes(new byte[0])) .setContentType("avro/binary+{schema-id}"); diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java index f687f19dcc5a0..98b85f3de2b24 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; import com.azure.data.schemaregistry.SchemaRegistryClientBuilder; @@ -45,7 +45,7 @@ public static void main(String[] args) { playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); // Serialize the playing card object and write to the output stream. - MessageWithMetadata message = serializer.serializeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); + MessageContent message = serializer.serializeMessageData(playingCard, + TypeReference.createInstance(MessageContent.class)); } } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java index a60c9d8417e57..49171471e9402 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java @@ -4,7 +4,7 @@ package com.azure.data.schemaregistry.apacheavro; import com.azure.core.credential.TokenCredential; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.models.MessageContent; import com.azure.core.util.BinaryData; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryAsyncClient; @@ -45,19 +45,19 @@ public static void main(String[] args) { .buildSerializer(); // Get serialized avro data to deserialize into strongly-typed object. - MessageWithMetadata inputStream = getMessageToDeserialize(); + MessageContent inputStream = getMessageToDeserialize(); PlayingCard deserializedObject = encoder.deserializeMessageData(inputStream, TypeReference.createInstance(PlayingCard.class)); } - private static MessageWithMetadata getMessageToDeserialize() { + private static MessageContent getMessageToDeserialize() { PlayingCard playingCard = new PlayingCard(); playingCard.setCardValue(5); playingCard.setIsFaceCard(false); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); try { - return new MessageWithMetadata() + return new MessageContent() .setBodyAsBinaryData(BinaryData.fromBytes(playingCard.toByteBuffer().array())) .setContentType("avro/binary+schema_id"); } catch (IOException e) { diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java index 9dfc43773642b..440001d81c2a5 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java @@ -6,10 +6,10 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; -import com.azure.core.experimental.models.MessageWithMetadata; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.models.MessageContent; import com.azure.core.test.TestBase; import com.azure.core.util.serializer.TypeReference; import com.azure.data.schemaregistry.SchemaRegistryClient; @@ -131,8 +131,8 @@ public void registerAndGetSchema() { assertNotNull(schemaProperties); // Act & Assert - final MessageWithMetadata encodedMessage = encoder.serializeMessageData(cards, - TypeReference.createInstance(MessageWithMetadata.class)); + final MessageContent encodedMessage = encoder.serializeMessageData(cards, + TypeReference.createInstance(MessageContent.class)); assertNotNull(encodedMessage); final byte[] outputArray = encodedMessage.getBodyAsBinaryData().toBytes(); diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java index 77c7ff867b564..c6066aa5612a6 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java @@ -6,10 +6,10 @@ import com.azure.core.credential.AccessToken; import com.azure.core.credential.TokenCredential; import com.azure.core.credential.TokenRequestContext; -import com.azure.core.experimental.models.MessageWithMetadata; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; +import com.azure.core.models.MessageContent; import com.azure.core.test.InterceptorManager; import com.azure.core.test.TestContextManager; import com.azure.core.test.TestMode; @@ -138,7 +138,7 @@ public void testRegistryGuidPrefixedToPayload() { avroSerializer, serializerOptions); StepVerifier.create(serializer.serializeMessageDataAsync(playingCard, - TypeReference.createInstance(MessageWithMetadata.class))) + TypeReference.createInstance(MessageContent.class))) .assertNext(message -> { // guid should match preloaded SchemaRegistryObject guid assertEquals(expectedContentType, message.getContentType()); @@ -156,7 +156,7 @@ public void testNullPayloadThrowsSerializationException() { final SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); - final MessageWithMetadata message = new MessageWithMetadata(); + final MessageContent message = new MessageContent(); // Act & Assert StepVerifier.create(serializer.serializeMessageDataAsync(message, null)) @@ -226,7 +226,7 @@ public static Stream testEmptyPayload() { return Stream.of( Arguments.of( new MockMessage(), - new MessageWithMetadata().setContentType("avro/binary")) + new MessageContent().setContentType("avro/binary")) ); } @@ -235,7 +235,7 @@ public static Stream testEmptyPayload() { */ @MethodSource @ParameterizedTest - public void testEmptyPayload(MessageWithMetadata message) { + public void testEmptyPayload(MessageContent message) { // Arrange final AvroSerializer avroSerializer = new AvroSerializer(false, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); @@ -369,7 +369,7 @@ public void serializeForwardCompatibility() { .setFavouriteColour(colour) .setFavouritePet(pet) .build(); - final AtomicReference outputData = new AtomicReference<>(); + final AtomicReference outputData = new AtomicReference<>(); // Act: Serialize the new Person2. StepVerifier.create(serializer.serializeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) @@ -532,15 +532,15 @@ private SchemaRegistryAsyncClient getSchemaRegistryClient(TestInfo testInfo, Tes } /** - * Test class that extends from MessageWithMetadata + * Test class that extends from MessageContent */ - static class MockMessage extends MessageWithMetadata { + static class MockMessage extends MessageContent { } /** * This class does not expose the no-args constructor that we look for. */ - static class InvalidMessage extends MessageWithMetadata { + static class InvalidMessage extends MessageContent { InvalidMessage(String contents) { super();