From a18c81ef2ec9d53367cf91a134d531f518187e6a Mon Sep 17 00:00:00 2001 From: Connie Date: Tue, 8 Mar 2022 12:35:28 -0800 Subject: [PATCH 01/16] Rename MessageWithMetadata -> BinaryContent --- .../{MessageWithMetadata.java => BinaryContent.java} | 10 +++++----- .../experimental/models/MessageWithMetadataTest.java | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) rename sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/{MessageWithMetadata.java => BinaryContent.java} (77%) diff --git a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java similarity index 77% rename from sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java rename to sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java index 7b0a9ccdbd4d5..5805f030eb49b 100644 --- a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/MessageWithMetadata.java +++ b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/models/BinaryContent.java @@ -10,7 +10,7 @@ * An abstraction for a message containing a content type along with its data. */ @Fluent -public class MessageWithMetadata { +public class BinaryContent { 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 BinaryContent} object. */ - public MessageWithMetadata setBodyAsBinaryData(BinaryData binaryData) { + public BinaryContent 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 BinaryContent} object. */ - public MessageWithMetadata setContentType(String contentType) { + public BinaryContent 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-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java index ebe19fa1a9fc6..bb98e92a9fa8b 100644 --- a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java +++ b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java @@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertNull; /** - * Tests for {@link MessageWithMetadata} + * Tests for {@link BinaryContent} */ public class MessageWithMetadataTest { /** @@ -18,7 +18,7 @@ public class MessageWithMetadataTest { @Test public void initialize() { // Act - final MessageWithMetadata message = new MessageWithMetadata(); + final BinaryContent message = new BinaryContent(); // 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 BinaryContent message = new BinaryContent(); // Act - final MessageWithMetadata actual = message.setContentType(contentType) + final BinaryContent actual = message.setContentType(contentType) .setBodyAsBinaryData(binaryData); // Assert From 3aa403d4458c3c4aefbeb10e0f420593ab62050c Mon Sep 17 00:00:00 2001 From: Connie Date: Tue, 8 Mar 2022 13:01:34 -0800 Subject: [PATCH 02/16] Rename to BinaryContentTest --- .../{MessageWithMetadataTest.java => BinaryContentTest.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/{MessageWithMetadataTest.java => BinaryContentTest.java} (97%) diff --git a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java similarity index 97% rename from sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java rename to sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java index bb98e92a9fa8b..5419a1d5cb1c6 100644 --- a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/MessageWithMetadataTest.java +++ b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/models/BinaryContentTest.java @@ -11,7 +11,7 @@ /** * Tests for {@link BinaryContent} */ -public class MessageWithMetadataTest { +public class BinaryContentTest { /** * Verify default parameters. */ From 774ede8e5283f2a82abab154c6c4fe5363d1e134 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 14:53:25 -0800 Subject: [PATCH 03/16] Add unreleased_ entry --- eng/versioning/version_client.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 23a8ba155af07..0e05e2466436c 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -354,8 +354,8 @@ unreleased_com.azure:azure-aot-graalvm-support;1.0.0-beta.1 unreleased_com.azure:azure-aot-graalvm-support-netty;1.0.0-beta.1 unreleased_com.azure:azure-aot-graalvm-perf;1.0.0-beta.1 - unreleased_com.azure:azure-core-amqp;2.5.0-beta.1 +unreleased_com.azure:azure-core-experimental;1.0.0-beta.26 # 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 From 36245731e665780bdba7434c56b1eca2ddbc4054 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 14:54:01 -0800 Subject: [PATCH 04/16] Update CHANGELOG. --- .../azure-data-schemaregistry-apacheavro/CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md index 583d2f24d077f..79dfc89de3e86 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md @@ -6,6 +6,10 @@ ### Breaking Changes +- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `BinaryContent`. +- Changed `SchemaRegistryApacheAvroEncoder` to `SchemaRegistryApacheAvroSerializer`. +- Changed `` + ### Bugs Fixed ### Other Changes @@ -14,7 +18,7 @@ ### Features Added -- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageWithMetadata` rather than tied to a binary format +- Changed `SchemaRegistryApacheAvroEncoder` to deserialize `MessageWithMetadata` rather than tied to a binary format with preamble. Backwards compatibility with preamble format supported for this release. See issue #26449. ### Breaking Changes From 76816bb7fa14b2be1b4bbc98d1f8e77a1369b580 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 14:54:23 -0800 Subject: [PATCH 05/16] Add reference to unreleased in pom.xml --- sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index 4a8d72e34bc09..bec2f1b7bbc26 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -47,7 +47,7 @@ com.azure azure-core-experimental - 1.0.0-beta.25 + 1.0.0-beta.26 com.azure From a3c7d4373cc36b7d501d217827cf99fba0cc3330 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 14:54:34 -0800 Subject: [PATCH 06/16] Fix build breaks from rename. --- .../README.md | 6 ++-- .../SchemaRegistryApacheAvroEncoder.java | 28 +++++++++---------- .../apacheavro/ReadmeSamples.java | 12 ++++---- ...SchemaRegistryApacheAvroEncoderSample.java | 6 ++-- ...hemaRegistryAvroDeserializationSample.java | 8 +++--- ...istryApacheAvroEncoderIntegrationTest.java | 6 ++-- .../SchemaRegistryApacheAvroEncoderTest.java | 18 ++++++------ 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md index 15e55cb3f7804..229578a50c414 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md @@ -111,8 +111,8 @@ playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); -MessageWithMetadata message = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); +BinaryContent message = encoder.encodeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.class)); ``` The avro type `PlayingCard` is available in samples package @@ -123,7 +123,7 @@ Deserialize a Schema Registry-compatible avro payload into a strongly-type objec ```java readme-sample-decodeSample SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); -MessageWithMetadata message = getSchemaRegistryAvroMessage(); +BinaryContent message = getSchemaRegistryAvroMessage(); PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); ``` diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java index d5bb9f1f4049e..a5d3a4d4070c3 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java @@ -3,7 +3,7 @@ package com.azure.data.schemaregistry.apacheavro; -import com.azure.core.experimental.models.MessageWithMetadata; +import com.azure.core.experimental.models.BinaryContent; import com.azure.core.util.BinaryData; import com.azure.core.util.CoreUtils; import com.azure.core.util.logging.ClientLogger; @@ -60,7 +60,7 @@ public final class SchemaRegistryApacheAvroEncoder { * * @param object Object to encode. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return The message encoded or {@code null} if the message could not be encoded. * @@ -70,7 +70,7 @@ public final class SchemaRegistryApacheAvroEncoder { * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference) { + public T encodeMessageData(Object object, TypeReference typeReference) { return encodeMessageDataAsync(object, typeReference).block(); } @@ -80,7 +80,7 @@ public T encodeMessageData(Object object, TypeRe * @param object Object to encode. * @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 BinaryContent}. * * @return The message encoded or {@code null} if the message could not be encoded. * @@ -90,7 +90,7 @@ public T encodeMessageData(Object object, TypeRe * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference, + public T encodeMessageData(Object object, TypeReference typeReference, Function messageFactory) { return encodeMessageDataAsync(object, typeReference, messageFactory).block(); } @@ -100,7 +100,7 @@ public T encodeMessageData(Object object, TypeRe * * @param object Object to encode. * @param typeReference Type of message to create. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return A Mono that completes with the encoded message. * @@ -110,7 +110,7 @@ public T encodeMessageData(Object object, TypeRe * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono encodeMessageDataAsync(Object object, TypeReference typeReference) { return encodeMessageDataAsync(object, typeReference, null); @@ -123,7 +123,7 @@ public Mono encodeMessageDataAsync(Object obj * @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 BinaryContent}. * * @return A Mono that completes with the encoded message. * @@ -133,7 +133,7 @@ public Mono encodeMessageDataAsync(Object obj * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono encodeMessageDataAsync(Object object, TypeReference typeReference, Function messageFactory) { if (object == null) { @@ -193,13 +193,13 @@ public Mono encodeMessageDataAsync(Object obj * * @param message Object to encode. * @param typeReference Message to encode to. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return The message encoded. * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public T decodeMessageData(MessageWithMetadata message, TypeReference typeReference) { + public T decodeMessageData(BinaryContent message, TypeReference typeReference) { return decodeMessageDataAsync(message, typeReference).block(); } @@ -208,14 +208,14 @@ public T decodeMessageData(MessageWithMetadata message, TypeReference typ * * @param message Object to encode. * @param typeReference Message to encode to. - * @param Concrete type of {@link MessageWithMetadata}. + * @param Concrete type of {@link BinaryContent}. * * @return A Mono that completes when the message encoded. If {@code message.getBodyAsBinaryData()} is null or * empty, then an empty Mono is returned. * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public Mono decodeMessageDataAsync(MessageWithMetadata message, TypeReference typeReference) { + public Mono decodeMessageDataAsync(BinaryContent message, TypeReference typeReference) { if (message == null) { return monoError(logger, new NullPointerException("'message' cannot be null.")); } else if (typeReference == null) { @@ -305,7 +305,7 @@ private Mono decodeMessageDataAsync(String schemaId, ByteBuffer buffer, T * @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/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 eb685bb70f700..4da2642a4654d 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.experimental.models.BinaryContent; 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 encodeSample() { playingCard.setIsFaceCard(false); playingCard.setCardValue(5); - MessageWithMetadata message = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); + BinaryContent message = encoder.encodeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.class)); // END: readme-sample-encodeSample } @@ -67,7 +67,7 @@ public void encodeSample() { public void decodeSample() { // BEGIN: readme-sample-decodeSample SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); - MessageWithMetadata message = getSchemaRegistryAvroMessage(); + BinaryContent message = getSchemaRegistryAvroMessage(); PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // END: readme-sample-decodeSample } @@ -76,8 +76,8 @@ public void decodeSample() { * Non-functional method not visible on README sample * @return a new message. */ - private MessageWithMetadata getSchemaRegistryAvroMessage() { - return new MessageWithMetadata() + private BinaryContent getSchemaRegistryAvroMessage() { + return new BinaryContent() .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/SchemaRegistryApacheAvroEncoderSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java index bb168300362e1..9d8fb74d1bd4a 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.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.experimental.models.BinaryContent; 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 = encoder.encodeMessageData(playingCard, - TypeReference.createInstance(MessageWithMetadata.class)); + BinaryContent message = encoder.encodeMessageData(playingCard, + TypeReference.createInstance(BinaryContent.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 04b1b0fbe9597..b9bb66807f90d 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.experimental.models.BinaryContent; 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) { .buildEncoder(); // Get serialized avro data to deserialize into strongly-typed object. - MessageWithMetadata inputStream = getMessageToDeserialize(); + BinaryContent inputStream = getMessageToDeserialize(); PlayingCard deserializedObject = encoder.decodeMessageData(inputStream, TypeReference.createInstance(PlayingCard.class)); } - private static MessageWithMetadata getMessageToDeserialize() { + private static BinaryContent getMessageToDeserialize() { PlayingCard playingCard = new PlayingCard(); playingCard.setCardValue(5); playingCard.setIsFaceCard(false); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); try { - return new MessageWithMetadata() + return new BinaryContent() .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/SchemaRegistryApacheAvroEncoderIntegrationTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java index 186f1b36a6476..59e9b34cdf0e6 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java @@ -6,7 +6,7 @@ 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.experimental.models.BinaryContent; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; @@ -131,8 +131,8 @@ public void registerAndGetSchema() { assertNotNull(schemaProperties); // Act & Assert - final MessageWithMetadata encodedMessage = encoder.encodeMessageData(cards, - TypeReference.createInstance(MessageWithMetadata.class)); + final BinaryContent encodedMessage = encoder.encodeMessageData(cards, + TypeReference.createInstance(BinaryContent.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/SchemaRegistryApacheAvroEncoderTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java index cbbcd55414de2..d7e85010cd34b 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java @@ -6,7 +6,7 @@ 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.experimental.models.BinaryContent; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; @@ -140,7 +140,7 @@ public void testRegistryGuidPrefixedToPayload() { avroSerializer, serializerOptions); StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, - TypeReference.createInstance(MessageWithMetadata.class))) + TypeReference.createInstance(BinaryContent.class))) .assertNext(message -> { // guid should match preloaded SchemaRegistryObject guid assertEquals(expectedContentType, message.getContentType()); @@ -158,7 +158,7 @@ public void testNullPayloadThrowsSerializationException() { final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, avroSerializer, serializerOptions); - final MessageWithMetadata message = new MessageWithMetadata(); + final BinaryContent message = new BinaryContent(); // Act & Assert StepVerifier.create(encoder.encodeMessageDataAsync(message, null)) @@ -219,7 +219,7 @@ public static Stream testEmptyPayload() { return Stream.of( Arguments.of( new MockMessage(), - new MessageWithMetadata().setContentType("avro/binary")) + new BinaryContent().setContentType("avro/binary")) ); } @@ -228,7 +228,7 @@ public static Stream testEmptyPayload() { */ @MethodSource @ParameterizedTest - public void testEmptyPayload(MessageWithMetadata message) { + public void testEmptyPayload(BinaryContent message) { // Arrange final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); @@ -362,7 +362,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(encoder.encodeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) @@ -527,15 +527,15 @@ private SchemaRegistryAsyncClient getSchemaRegistryClient(TestInfo testInfo, Tes } /** - * Test class that extends from MessageWithMetadata + * Test class that extends from BinaryContent */ - static class MockMessage extends MessageWithMetadata { + static class MockMessage extends BinaryContent { } /** * This class does not expose the no-args constructor that we look for. */ - static class InvalidMessage extends MessageWithMetadata { + static class InvalidMessage extends BinaryContent { InvalidMessage(String contents) { super(); From bbe394e31397473c970aa057ebf9fbfcee35f575 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 13:21:17 -0800 Subject: [PATCH 07/16] Adding explicit dependency on azure-core. --- .../azure-data-schemaregistry-apacheavro/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index bec2f1b7bbc26..853ef4fbfa5e9 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -44,6 +44,11 @@ + + com.azure + azure-core + 1.26.0 + com.azure azure-core-experimental From 0a23693562e72ad5cf308bc7b001c59d9d4533df Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 13:38:42 -0800 Subject: [PATCH 08/16] Updating class name from Encoder -> Serializer. --- ...> SchemaRegistryApacheAvroSerializer.java} | 6 +-- ...aRegistryApacheAvroSerializerBuilder.java} | 32 +++++++------- .../apacheavro/ReadmeSamples.java | 12 +++--- ...SchemaRegistryApacheAvroEncoderSample.java | 4 +- ...hemaRegistryAvroDeserializationSample.java | 2 +- ...yApacheAvroSerializerIntegrationTest.java} | 4 +- ...hemaRegistryApacheAvroSerializerTest.java} | 42 +++++++++---------- 7 files changed, 51 insertions(+), 51 deletions(-) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/{SchemaRegistryApacheAvroEncoder.java => SchemaRegistryApacheAvroSerializer.java} (98%) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/{SchemaRegistryApacheAvroEncoderBuilder.java => SchemaRegistryApacheAvroSerializerBuilder.java} (80%) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/{SchemaRegistryApacheAvroEncoderIntegrationTest.java => SchemaRegistryApacheAvroSerializerIntegrationTest.java} (96%) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/{SchemaRegistryApacheAvroEncoderTest.java => SchemaRegistryApacheAvroSerializerTest.java} (92%) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java similarity index 98% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java index a5d3a4d4070c3..d1c34afe48e47 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializer.java @@ -28,13 +28,13 @@ /** * Schema Registry-based serializer implementation for Avro data format using Apache Avro. */ -public final class SchemaRegistryApacheAvroEncoder { +public final class SchemaRegistryApacheAvroSerializer { static final String AVRO_MIME_TYPE = "avro/binary"; static final byte[] RECORD_FORMAT_INDICATOR = new byte[]{0x00, 0x00, 0x00, 0x00}; static final int RECORD_FORMAT_INDICATOR_SIZE = RECORD_FORMAT_INDICATOR.length; static final int SCHEMA_ID_SIZE = 32; - private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroEncoder.class); + private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroSerializer.class); private final SchemaRegistryAsyncClient schemaRegistryClient; private final AvroSerializer avroSerializer; private final SerializerOptions serializerOptions; @@ -46,7 +46,7 @@ public final class SchemaRegistryApacheAvroEncoder { * @param avroSerializer Serializer implemented using Apache Avro. * @param serializerOptions Options to configure the serializer with. */ - SchemaRegistryApacheAvroEncoder(SchemaRegistryAsyncClient schemaRegistryClient, + SchemaRegistryApacheAvroSerializer(SchemaRegistryAsyncClient schemaRegistryClient, AvroSerializer avroSerializer, SerializerOptions serializerOptions) { this.schemaRegistryClient = Objects.requireNonNull(schemaRegistryClient, "'schemaRegistryClient' cannot be null."); diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java similarity index 80% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java index 8886719469981..6f55d024c1507 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderBuilder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java @@ -15,15 +15,15 @@ import java.util.Objects; /** - * The builder implementation for building {@link SchemaRegistryApacheAvroEncoder}. + * The builder implementation for building {@link SchemaRegistryApacheAvroSerializer}. * - * @see SchemaRegistryApacheAvroEncoder + * @see SchemaRegistryApacheAvroSerializer */ -public final class SchemaRegistryApacheAvroEncoderBuilder { +public final class SchemaRegistryApacheAvroSerializerBuilder { private static final boolean AVRO_SPECIFIC_READER_DEFAULT = false; private static final int MAX_CACHE_SIZE = 128; - private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroEncoderBuilder.class); + private final ClientLogger logger = new ClientLogger(SchemaRegistryApacheAvroSerializerBuilder.class); private Boolean autoRegisterSchemas; private Boolean avroSpecificReader; private SchemaRegistryAsyncClient schemaRegistryAsyncClient; @@ -32,7 +32,7 @@ public final class SchemaRegistryApacheAvroEncoderBuilder { /** * Instantiates instance of Builder class. Supplies client defaults. */ - public SchemaRegistryApacheAvroEncoderBuilder() { + public SchemaRegistryApacheAvroSerializerBuilder() { this.autoRegisterSchemas = false; this.avroSpecificReader = false; } @@ -46,9 +46,9 @@ public SchemaRegistryApacheAvroEncoderBuilder() { * * @param schemaGroup Azure Schema Registry schema group * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance */ - public SchemaRegistryApacheAvroEncoderBuilder schemaGroup(String schemaGroup) { + public SchemaRegistryApacheAvroSerializerBuilder schemaGroup(String schemaGroup) { this.schemaGroup = schemaGroup; return this; } @@ -64,9 +64,9 @@ public SchemaRegistryApacheAvroEncoderBuilder schemaGroup(String schemaGroup) { * * @param autoRegisterSchemas flag for schema auto-registration * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance */ - public SchemaRegistryApacheAvroEncoderBuilder autoRegisterSchema(boolean autoRegisterSchemas) { + public SchemaRegistryApacheAvroSerializerBuilder autoRegisterSchema(boolean autoRegisterSchemas) { this.autoRegisterSchemas = autoRegisterSchemas; return this; } @@ -78,9 +78,9 @@ public SchemaRegistryApacheAvroEncoderBuilder autoRegisterSchema(boolean autoReg * @param avroSpecificReader {@code true} to deserialize into {@link SpecificRecord} via {@link * SpecificDatumReader}; {@code false} otherwise. * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance. + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance. */ - public SchemaRegistryApacheAvroEncoderBuilder avroSpecificReader(boolean avroSpecificReader) { + public SchemaRegistryApacheAvroSerializerBuilder avroSpecificReader(boolean avroSpecificReader) { this.avroSpecificReader = avroSpecificReader; return this; } @@ -90,9 +90,9 @@ public SchemaRegistryApacheAvroEncoderBuilder avroSpecificReader(boolean avroSpe * * @param schemaRegistryAsyncClient The {@link SchemaRegistryAsyncClient}. * - * @return updated {@link SchemaRegistryApacheAvroEncoderBuilder} instance. + * @return updated {@link SchemaRegistryApacheAvroSerializerBuilder} instance. */ - public SchemaRegistryApacheAvroEncoderBuilder schemaRegistryAsyncClient( + public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryAsyncClient( SchemaRegistryAsyncClient schemaRegistryAsyncClient) { this.schemaRegistryAsyncClient = schemaRegistryAsyncClient; return this; @@ -101,13 +101,13 @@ public SchemaRegistryApacheAvroEncoderBuilder schemaRegistryAsyncClient( /** * Creates a new instance of Schema Registry serializer. * - * @return A new instance of {@link SchemaRegistryApacheAvroEncoder}. + * @return A new instance of {@link SchemaRegistryApacheAvroSerializer}. * * @throws NullPointerException if {@link #schemaRegistryAsyncClient(SchemaRegistryAsyncClient)} is {@code null} * @throws IllegalStateException if {@link #autoRegisterSchema(boolean)} is {@code true} but {@link * #schemaGroup(String) schemaGroup} is {@code null}. */ - public SchemaRegistryApacheAvroEncoder buildEncoder() { + public SchemaRegistryApacheAvroSerializer buildEncoder() { final boolean isAutoRegister = autoRegisterSchemas != null && autoRegisterSchemas; if (Objects.isNull(schemaRegistryAsyncClient)) { @@ -126,6 +126,6 @@ public SchemaRegistryApacheAvroEncoder buildEncoder() { EncoderFactory.get(), DecoderFactory.get()); final SerializerOptions options = new SerializerOptions(schemaGroup, isAutoRegister, MAX_CACHE_SIZE); - return new SchemaRegistryApacheAvroEncoder(schemaRegistryAsyncClient, codec, options); + return new SchemaRegistryApacheAvroSerializer(schemaRegistryAsyncClient, codec, options); } } 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 4da2642a4654d..704bbf143f607 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 @@ -19,10 +19,10 @@ public class ReadmeSamples { /** - * Sample to demonstrate creation of {@link SchemaRegistryApacheAvroEncoder}. - * @return The {@link SchemaRegistryApacheAvroEncoder}. + * Sample to demonstrate creation of {@link SchemaRegistryApacheAvroSerializer}. + * @return The {@link SchemaRegistryApacheAvroSerializer}. */ - public SchemaRegistryApacheAvroEncoder createAvroSchemaRegistryEncoder() { + public SchemaRegistryApacheAvroSerializer createAvroSchemaRegistryEncoder() { // BEGIN: readme-sample-createSchemaRegistryAsyncClient TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); @@ -35,7 +35,7 @@ public SchemaRegistryApacheAvroEncoder createAvroSchemaRegistryEncoder() { // END: readme-sample-createSchemaRegistryAsyncClient // BEGIN: readme-sample-createSchemaRegistryAvroEncoder - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .buildEncoder(); @@ -48,7 +48,7 @@ public SchemaRegistryApacheAvroEncoder createAvroSchemaRegistryEncoder() { * Encode a strongly-typed object into avro payload compatible with schema registry. */ public void encodeSample() { - SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); + SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); // BEGIN: readme-sample-encodeSample PlayingCard playingCard = new PlayingCard(); @@ -66,7 +66,7 @@ public void encodeSample() { */ public void decodeSample() { // BEGIN: readme-sample-decodeSample - SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); + SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); BinaryContent message = getSchemaRegistryAvroMessage(); PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // END: readme-sample-decodeSample diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java index 9d8fb74d1bd4a..846049f5fdfdf 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java @@ -13,7 +13,7 @@ import com.azure.identity.DefaultAzureCredentialBuilder; /** - * Sample to demonstrate using {@link SchemaRegistryApacheAvroEncoder} for serialization and deserialization of data. + * Sample to demonstrate using {@link SchemaRegistryApacheAvroSerializer} for serialization and deserialization of data. */ public class SchemaRegistryApacheAvroEncoderSample { /** @@ -33,7 +33,7 @@ public static void main(String[] args) { // Create the encoder instance by configuring it with the schema registry client and // enabling auto registering of new schemas - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .avroSpecificReader(true) 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 b9bb66807f90d..8e2b1d3c2f419 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 @@ -37,7 +37,7 @@ public static void main(String[] args) { // Create the encoder instance by configuring it with the schema registry client and // enabling auto registering of new schemas - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .avroSpecificReader(true) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java similarity index 96% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java index 59e9b34cdf0e6..c512962224330 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderIntegrationTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerIntegrationTest.java @@ -38,7 +38,7 @@ /** * Tests end to end experience of the schema registry class. */ -public class SchemaRegistryApacheAvroEncoderIntegrationTest extends TestBase { +public class SchemaRegistryApacheAvroSerializerIntegrationTest extends TestBase { static final String SCHEMA_REGISTRY_ENDPOINT = "SCHEMA_REGISTRY_ENDPOINT"; static final String SCHEMA_REGISTRY_GROUP = "SCHEMA_REGISTRY_GROUP"; @@ -99,7 +99,7 @@ protected void afterTest() { public void registerAndGetSchema() { // Arrange final SchemaRegistryClient registryClient = builder.buildClient(); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(schemaGroup) .schemaRegistryAsyncClient(builder.buildAsyncClient()) .avroSpecificReader(true) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java similarity index 92% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java index d7e85010cd34b..29a9557b8e948 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderTest.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerTest.java @@ -56,12 +56,12 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Stream; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.AVRO_MIME_TYPE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.RECORD_FORMAT_INDICATOR; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.RECORD_FORMAT_INDICATOR_SIZE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoder.SCHEMA_ID_SIZE; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoderIntegrationTest.PLAYBACK_ENDPOINT; -import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroEncoderIntegrationTest.PLAYBACK_TEST_GROUP; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.AVRO_MIME_TYPE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.RECORD_FORMAT_INDICATOR; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.RECORD_FORMAT_INDICATOR_SIZE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializer.SCHEMA_ID_SIZE; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerIntegrationTest.PLAYBACK_ENDPOINT; +import static com.azure.data.schemaregistry.apacheavro.SchemaRegistryApacheAvroSerializerIntegrationTest.PLAYBACK_TEST_GROUP; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -72,9 +72,9 @@ import static org.mockito.Mockito.when; /** - * Unit tests for {@link SchemaRegistryApacheAvroEncoder}. + * Unit tests for {@link SchemaRegistryApacheAvroSerializer}. */ -public class SchemaRegistryApacheAvroEncoderTest { +public class SchemaRegistryApacheAvroSerializerTest { private static final String MOCK_GUID = new String(new char[SCHEMA_ID_SIZE]).replace("\0", "a"); private static final String MOCK_SCHEMA_GROUP = "mock-group"; private static final int MOCK_CACHE_SIZE = 128; @@ -136,7 +136,7 @@ public void testRegistryGuidPrefixedToPayload() { playingClassSchema.toString(), SchemaFormat.AVRO)).thenReturn(Mono.just(registered)); final String expectedContentType = AVRO_MIME_TYPE + "+" + MOCK_GUID; - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, @@ -155,7 +155,7 @@ public void testNullPayloadThrowsSerializationException() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, false, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, avroSerializer, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); final BinaryContent message = new BinaryContent(); @@ -174,7 +174,7 @@ public void testIfRegistryNullThenThrow() { // Act & Assert assertThrows(NullPointerException.class, - () -> new SchemaRegistryApacheAvroEncoder(null, encoder, serializerOptions)); + () -> new SchemaRegistryApacheAvroSerializer(null, encoder, serializerOptions)); } @Test @@ -188,7 +188,7 @@ void testGetSchemaAndDeserialize() throws IOException { final SchemaRegistrySchema registrySchema = new SchemaRegistrySchema(registered, playingClassSchema); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, decoder, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, decoder, serializerOptions); assertNotNull(registrySchema.getProperties()); @@ -233,7 +233,7 @@ public void testEmptyPayload(BinaryContent message) { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Act & Assert @@ -252,7 +252,7 @@ public void testEmptyPayloadSync() { final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); final MockMessage message = new MockMessage(); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Act @@ -270,7 +270,7 @@ public void testNullPayload() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); // Null payload should throw NullPointerException. @@ -287,7 +287,7 @@ public void testNullPayloadSync() { final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder( + SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer( client, avroSerializer, serializerOptions); // Null payload should throw NullPointerException. @@ -317,7 +317,7 @@ public void serializeFromPortal() { .build(); final SchemaRegistryAsyncClient client = getSchemaRegistryClient(testInfo, TestMode.PLAYBACK); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) @@ -343,7 +343,7 @@ public void serializeFromPortal() { public void serializeForwardCompatibility() { // Arrange final SchemaRegistryAsyncClient client = getSchemaRegistryClient(testInfo, TestMode.PLAYBACK); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) @@ -396,7 +396,7 @@ public void throwsWhenConstructorNotAvailable() { // Arrange final AvroSerializer avroSerializer = new AvroSerializer(false, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder( + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer( client, avroSerializer, serializerOptions); final PlayingCard playingCard = new PlayingCard(true, 10, PlayingCardSuit.DIAMONDS); @@ -424,7 +424,7 @@ public void backwardsCompatiblePreamble() throws IOException { final AvroSerializer avroSerializer = new AvroSerializer(true, parser, ENCODER_FACTORY, DECODER_FACTORY); final SerializerOptions serializerOptions = new SerializerOptions(MOCK_SCHEMA_GROUP, true, MOCK_CACHE_SIZE); - final SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoder(client, avroSerializer, + final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); when(client.getSchema(MOCK_GUID)).thenReturn(Mono.just(schemaResponse)); @@ -506,7 +506,7 @@ private SchemaRegistryAsyncClient getSchemaRegistryClient(TestInfo testInfo, Tes endpoint = PLAYBACK_ENDPOINT; } else { tokenCredential = new DefaultAzureCredentialBuilder().build(); - endpoint = System.getenv(SchemaRegistryApacheAvroEncoderIntegrationTest.SCHEMA_REGISTRY_ENDPOINT); + endpoint = System.getenv(SchemaRegistryApacheAvroSerializerIntegrationTest.SCHEMA_REGISTRY_ENDPOINT); assertNotNull(endpoint, "'endpoint' cannot be null in LIVE/RECORD mode."); } From 74d5e10701295d7cf3241edd81e79086ea00270c Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 13:57:46 -0800 Subject: [PATCH 09/16] Rename encode/decode to deserialize/serialize. --- .../SchemaRegistryApacheAvroSerializer.java | 24 +++++++++---------- .../apacheavro/ReadmeSamples.java | 4 ++-- ...SchemaRegistryApacheAvroEncoderSample.java | 2 +- ...hemaRegistryAvroDeserializationSample.java | 2 +- ...ryApacheAvroSerializerIntegrationTest.java | 4 ++-- ...chemaRegistryApacheAvroSerializerTest.java | 24 +++++++++---------- 6 files changed, 30 insertions(+), 30 deletions(-) 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 d1c34afe48e47..2a8d3f2c3f071 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 @@ -70,8 +70,8 @@ public final class SchemaRegistryApacheAvroSerializer { * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference) { - return encodeMessageDataAsync(object, typeReference).block(); + public T serializeMessageData(Object object, TypeReference typeReference) { + return serializeMessageDataAsync(object, typeReference).block(); } /** @@ -90,9 +90,9 @@ public T encodeMessageData(Object object, TypeReferenc * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public T encodeMessageData(Object object, TypeReference typeReference, + public T serializeMessageData(Object object, TypeReference typeReference, Function messageFactory) { - return encodeMessageDataAsync(object, typeReference, messageFactory).block(); + return serializeMessageDataAsync(object, typeReference, messageFactory).block(); } /** @@ -110,10 +110,10 @@ public T encodeMessageData(Object object, TypeReferenc * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference) { - return encodeMessageDataAsync(object, typeReference, null); + return serializeMessageDataAsync(object, typeReference, null); } /** @@ -133,7 +133,7 @@ public Mono encodeMessageDataAsync(Object object, * encoding the object. * @throws NullPointerException if the {@code object} is null or {@code typeReference} is null. */ - public Mono encodeMessageDataAsync(Object object, + public Mono serializeMessageDataAsync(Object object, TypeReference typeReference, Function messageFactory) { if (object == null) { @@ -199,8 +199,8 @@ public Mono encodeMessageDataAsync(Object object, * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public T decodeMessageData(BinaryContent message, TypeReference typeReference) { - return decodeMessageDataAsync(message, typeReference).block(); + public T deserializeMessageData(BinaryContent message, TypeReference typeReference) { + return deserializeMessageDataAsync(message, typeReference).block(); } /** @@ -215,7 +215,7 @@ public T decodeMessageData(BinaryContent message, TypeReference typeRefer * * @throws NullPointerException if {@code message} or {@code typeReference} is null. */ - public Mono decodeMessageDataAsync(BinaryContent message, TypeReference typeReference) { + public Mono deserializeMessageDataAsync(BinaryContent message, TypeReference typeReference) { if (message == null) { return monoError(logger, new NullPointerException("'message' cannot be null.")); } else if (typeReference == null) { @@ -282,10 +282,10 @@ public Mono decodeMessageDataAsync(BinaryContent message, TypeReference Mono decodeMessageDataAsync(String schemaId, ByteBuffer buffer, TypeReference typeReference) { + private Mono deserializeMessageDataAsync(String schemaId, ByteBuffer buffer, TypeReference typeReference) { return this.schemaRegistryClient.getSchema(schemaId) .handle((registryObject, sink) -> { final byte[] payloadSchema = registryObject.getDefinition().getBytes(StandardCharsets.UTF_8); 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 704bbf143f607..490eb7dee2d2a 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 @@ -56,7 +56,7 @@ public void encodeSample() { playingCard.setIsFaceCard(false); playingCard.setCardValue(5); - BinaryContent message = encoder.encodeMessageData(playingCard, + BinaryContent message = encoder.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.class)); // END: readme-sample-encodeSample } @@ -68,7 +68,7 @@ public void decodeSample() { // BEGIN: readme-sample-decodeSample SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); BinaryContent message = getSchemaRegistryAvroMessage(); - PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); + PlayingCard playingCard = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // END: readme-sample-decodeSample } diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java index 846049f5fdfdf..f63a3f7d97b8c 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java @@ -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. - BinaryContent message = encoder.encodeMessageData(playingCard, + BinaryContent message = encoder.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.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 8e2b1d3c2f419..80fbae55983a3 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 @@ -46,7 +46,7 @@ public static void main(String[] args) { // Get serialized avro data to deserialize into strongly-typed object. BinaryContent inputStream = getMessageToDeserialize(); - PlayingCard deserializedObject = encoder.decodeMessageData(inputStream, + PlayingCard deserializedObject = encoder.deserializeMessageData(inputStream, TypeReference.createInstance(PlayingCard.class)); } 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 c512962224330..e05634ebda80e 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 @@ -131,14 +131,14 @@ public void registerAndGetSchema() { assertNotNull(schemaProperties); // Act & Assert - final BinaryContent encodedMessage = encoder.encodeMessageData(cards, + final BinaryContent encodedMessage = encoder.serializeMessageData(cards, TypeReference.createInstance(BinaryContent.class)); assertNotNull(encodedMessage); final byte[] outputArray = encodedMessage.getBodyAsBinaryData().toBytes(); assertTrue(outputArray.length > 0, "There should have been contents in array."); - final HandOfCards actual = encoder.decodeMessageData(encodedMessage, + final HandOfCards actual = encoder.deserializeMessageData(encodedMessage, TypeReference.createInstance(HandOfCards.class)); assertNotNull(actual); 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 29a9557b8e948..1cf0ccc86755f 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 @@ -139,7 +139,7 @@ public void testRegistryGuidPrefixedToPayload() { final SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializer(client, avroSerializer, serializerOptions); - StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, + StepVerifier.create(encoder.serializeMessageDataAsync(playingCard, TypeReference.createInstance(BinaryContent.class))) .assertNext(message -> { // guid should match preloaded SchemaRegistryObject guid @@ -161,7 +161,7 @@ public void testNullPayloadThrowsSerializationException() { final BinaryContent message = new BinaryContent(); // Act & Assert - StepVerifier.create(encoder.encodeMessageDataAsync(message, null)) + StepVerifier.create(encoder.serializeMessageDataAsync(message, null)) .verifyError(NullPointerException.class); } @@ -206,7 +206,7 @@ void testGetSchemaAndDeserialize() throws IOException { final MockMessage message = getPayload(playingCard); - StepVerifier.create(encoder.decodeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) + StepVerifier.create(encoder.deserializeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) .assertNext(actual -> { assertEquals(playingCard.getPlayingCardSuit(), actual.getPlayingCardSuit()); assertEquals(playingCard.getCardValue(), actual.getCardValue()); @@ -237,7 +237,7 @@ public void testEmptyPayload(BinaryContent message) { avroSerializer, serializerOptions); // Act & Assert - StepVerifier.create(encoder.decodeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) + StepVerifier.create(encoder.deserializeMessageDataAsync(message, TypeReference.createInstance(PlayingCard.class))) .expectComplete() .verify(); } @@ -256,7 +256,7 @@ public void testEmptyPayloadSync() { avroSerializer, serializerOptions); // Act - final Person actual = encoder.decodeMessageData(message, TypeReference.createInstance(Person.class)); + final Person actual = encoder.deserializeMessageData(message, TypeReference.createInstance(Person.class)); // Assert assertNull(actual); @@ -274,7 +274,7 @@ public void testNullPayload() { avroSerializer, serializerOptions); // Null payload should throw NullPointerException. - StepVerifier.create(encoder.encodeMessageDataAsync(null, null)) + StepVerifier.create(encoder.serializeMessageDataAsync(null, null)) .expectError(NullPointerException.class) .verify(); } @@ -291,7 +291,7 @@ public void testNullPayloadSync() { client, avroSerializer, serializerOptions); // Null payload should throw NullPointerException. - assertThrows(NullPointerException.class, () -> encoder.decodeMessageData(null, null)); + assertThrows(NullPointerException.class, () -> encoder.deserializeMessageData(null, null)); } /** @@ -325,7 +325,7 @@ public void serializeFromPortal() { final String expectedContentType = AVRO_MIME_TYPE + "+64fc737160ff41bdb8a0b8af028e6827"; // Act - StepVerifier.create(encoder.encodeMessageDataAsync(record, TypeReference.createInstance(MockMessage.class))) + StepVerifier.create(encoder.serializeMessageDataAsync(record, TypeReference.createInstance(MockMessage.class))) .assertNext(message -> { assertEquals(expectedContentType, message.getContentType()); assertNotNull(message.getBodyAsBinaryData()); @@ -365,7 +365,7 @@ public void serializeForwardCompatibility() { final AtomicReference outputData = new AtomicReference<>(); // Act: Serialize the new Person2. - StepVerifier.create(encoder.encodeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) + StepVerifier.create(encoder.serializeMessageDataAsync(writerPerson, TypeReference.createInstance(MockMessage.class))) .assertNext(message -> { assertEquals(expectedContentType, message.getContentType()); @@ -379,7 +379,7 @@ public void serializeForwardCompatibility() { // Act: Deserialize Person (the older schema) assertNotNull(outputData.get(), "Value should have been set from the test."); - final Person readerPerson = encoder.decodeMessageData(outputData.get(), TypeReference.createInstance(Person.class)); + final Person readerPerson = encoder.deserializeMessageData(outputData.get(), TypeReference.createInstance(Person.class)); assertNotNull(readerPerson); assertEquals(name, readerPerson.getName()); @@ -403,7 +403,7 @@ public void throwsWhenConstructorNotAvailable() { final TypeReference typeReference = TypeReference.createInstance(InvalidMessage.class); // Act & Assert - StepVerifier.create(encoder.encodeMessageDataAsync(playingCard, typeReference)) + StepVerifier.create(encoder.serializeMessageDataAsync(playingCard, typeReference)) .expectError(IllegalArgumentException.class) .verify(); } @@ -448,7 +448,7 @@ public void backwardsCompatiblePreamble() throws IOException { message.setBodyAsBinaryData(binaryData); // Act - final PlayingCard actual = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); + final PlayingCard actual = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); // Assert assertNotNull(actual); From 394cee3c4e3fab58eba49d2cfff427ee755dfb43 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 14:17:53 -0800 Subject: [PATCH 10/16] Update CHANgELOG --- sdk/core/azure-core-experimental/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/core/azure-core-experimental/CHANGELOG.md b/sdk/core/azure-core-experimental/CHANGELOG.md index 0dfb1b6448cae..55f6d064c75c0 100644 --- a/sdk/core/azure-core-experimental/CHANGELOG.md +++ b/sdk/core/azure-core-experimental/CHANGELOG.md @@ -6,6 +6,8 @@ ### Breaking Changes +- Changed `com.azure.core.experimental.models.MessageWithMetadata` to `BinaryContent`. + ### Bugs Fixed ### Other Changes From f94f32923fa4610c217a383eb929d1b37ce8cc82 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 15:01:08 -0800 Subject: [PATCH 11/16] Rename playback files. --- ...ApacheAvroSerializerIntegrationTest.registerAndGetSchema.json} | 0 ...ryApacheAvroSerializerTest.serializeForwardCompatibility.json} | 0 ...hemaRegistryApacheAvroSerializerTest.serializeFromPortal.json} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/{SchemaRegistryApacheAvroEncoderIntegrationTest.registerAndGetSchema.json => SchemaRegistryApacheAvroSerializerIntegrationTest.registerAndGetSchema.json} (100%) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/{SchemaRegistryApacheAvroEncoderTest.serializeForwardCompatibility.json => SchemaRegistryApacheAvroSerializerTest.serializeForwardCompatibility.json} (100%) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/{SchemaRegistryApacheAvroEncoderTest.serializeFromPortal.json => SchemaRegistryApacheAvroSerializerTest.serializeFromPortal.json} (100%) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderIntegrationTest.registerAndGetSchema.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerIntegrationTest.registerAndGetSchema.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderIntegrationTest.registerAndGetSchema.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerIntegrationTest.registerAndGetSchema.json diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeForwardCompatibility.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeForwardCompatibility.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeForwardCompatibility.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeForwardCompatibility.json diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeFromPortal.json b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeFromPortal.json similarity index 100% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroEncoderTest.serializeFromPortal.json rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/test/resources/session-records/SchemaRegistryApacheAvroSerializerTest.serializeFromPortal.json From 6091b103bd470c6c795f3cf38986314ecc8dd065 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 15:01:21 -0800 Subject: [PATCH 12/16] Fix README file snippets. --- .../azure-data-schemaregistry-apacheavro/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md index 229578a50c414..4cda34b4a2b45 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md @@ -73,7 +73,7 @@ SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBu #### Create `SchemaRegistryAvroSerializer` through the builder ```java readme-sample-createSchemaRegistryAvroEncoder -SchemaRegistryApacheAvroEncoder encoder = new SchemaRegistryApacheAvroEncoderBuilder() +SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .buildEncoder(); @@ -111,7 +111,7 @@ playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); -BinaryContent message = encoder.encodeMessageData(playingCard, +BinaryContent message = encoder.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.class)); ``` @@ -122,9 +122,9 @@ The avro type `PlayingCard` is available in samples package Deserialize a Schema Registry-compatible avro payload into a strongly-type object. ```java readme-sample-decodeSample -SchemaRegistryApacheAvroEncoder encoder = createAvroSchemaRegistryEncoder(); +SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); BinaryContent message = getSchemaRegistryAvroMessage(); -PlayingCard playingCard = encoder.decodeMessageData(message, TypeReference.createInstance(PlayingCard.class)); +PlayingCard playingCard = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); ``` ## Troubleshooting From 60cd1148b5c95cc0aabd855b56affbcbe7172897 Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 15:07:56 -0800 Subject: [PATCH 13/16] Fix CHANGELOG entries. --- .../azure-data-schemaregistry-apacheavro/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md index 79dfc89de3e86..a5a0e8df2f8a1 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/CHANGELOG.md @@ -8,7 +8,8 @@ - Changed `SchemaRegistryApacheAvroEncoder` to deserialize `BinaryContent`. - Changed `SchemaRegistryApacheAvroEncoder` to `SchemaRegistryApacheAvroSerializer`. -- Changed `` +- Changed `decodeMessageData` and `decodeMessageDataAsync` to `deserializeMessageData` and `deserializeMessageDataAsync`. +- Changed `encodeMessageData` and `encodeMessageDataAsync` to `serializeMessageData` and `serializeMessageDataAsync`. ### Bugs Fixed From 1771dc3f5fa7bbd99f83da280fc35381733e1f3d Mon Sep 17 00:00:00 2001 From: Connie Date: Thu, 10 Mar 2022 15:18:52 -0800 Subject: [PATCH 14/16] Fix version update tag. --- .../azure-data-schemaregistry-apacheavro/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml index 853ef4fbfa5e9..278cd1a50f191 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/pom.xml @@ -46,8 +46,8 @@ com.azure - azure-core - 1.26.0 + azure-core + 1.26.0 com.azure From d89f6d33982a4ddcef10247228b1e5d27edffa3f Mon Sep 17 00:00:00 2001 From: Connie Date: Fri, 11 Mar 2022 10:33:53 -0800 Subject: [PATCH 15/16] Fixing README entries. --- .../README.md | 16 +++++----- ...maRegistryApacheAvroSerializerBuilder.java | 2 +- .../apacheavro/ReadmeSamples.java | 32 +++++++++---------- ...maRegistryApacheAvroSerializerSample.java} | 8 ++--- ...hemaRegistryAvroDeserializationSample.java | 2 +- ...ryApacheAvroSerializerIntegrationTest.java | 2 +- ...chemaRegistryApacheAvroSerializerTest.java | 4 +-- 7 files changed, 33 insertions(+), 33 deletions(-) rename sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/{SchemaRegistryApacheAvroEncoderSample.java => SchemaRegistryApacheAvroSerializerSample.java} (88%) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md index 4cda34b4a2b45..e5a685b1678b8 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md @@ -72,11 +72,11 @@ SchemaRegistryAsyncClient schemaRegistryAsyncClient = new SchemaRegistryClientBu #### Create `SchemaRegistryAvroSerializer` through the builder -```java readme-sample-createSchemaRegistryAvroEncoder -SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() +```java readme-sample-createSchemaRegistryAvroSerializer +SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") - .buildEncoder(); + .buildSerializer(); ``` ## Key concepts @@ -105,13 +105,13 @@ The serializer in this library creates messages in a wire format. The format is ### Serialize Serialize a strongly-typed object into Schema Registry-compatible avro payload. -```java readme-sample-encodeSample +```java readme-sample-serializeSample PlayingCard playingCard = new PlayingCard(); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); -BinaryContent message = encoder.serializeMessageData(playingCard, +BinaryContent message = serializer.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.class)); ``` @@ -121,10 +121,10 @@ The avro type `PlayingCard` is available in samples package ### Deserialize Deserialize a Schema Registry-compatible avro payload into a strongly-type object. -```java readme-sample-decodeSample -SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); +```java readme-sample-deserializeSample +SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); BinaryContent message = getSchemaRegistryAvroMessage(); -PlayingCard playingCard = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); +PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); ``` ## Troubleshooting diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java index 6f55d024c1507..1b3114adf3d84 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/main/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerBuilder.java @@ -107,7 +107,7 @@ public SchemaRegistryApacheAvroSerializerBuilder schemaRegistryAsyncClient( * @throws IllegalStateException if {@link #autoRegisterSchema(boolean)} is {@code true} but {@link * #schemaGroup(String) schemaGroup} is {@code null}. */ - public SchemaRegistryApacheAvroSerializer buildEncoder() { + public SchemaRegistryApacheAvroSerializer buildSerializer() { final boolean isAutoRegister = autoRegisterSchemas != null && autoRegisterSchemas; if (Objects.isNull(schemaRegistryAsyncClient)) { 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 490eb7dee2d2a..de1af19d97c67 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 @@ -22,7 +22,7 @@ public class ReadmeSamples { * Sample to demonstrate creation of {@link SchemaRegistryApacheAvroSerializer}. * @return The {@link SchemaRegistryApacheAvroSerializer}. */ - public SchemaRegistryApacheAvroSerializer createAvroSchemaRegistryEncoder() { + public SchemaRegistryApacheAvroSerializer createAvroSchemaRegistrySerializer() { // BEGIN: readme-sample-createSchemaRegistryAsyncClient TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); @@ -34,42 +34,42 @@ public SchemaRegistryApacheAvroSerializer createAvroSchemaRegistryEncoder() { .buildAsyncClient(); // END: readme-sample-createSchemaRegistryAsyncClient - // BEGIN: readme-sample-createSchemaRegistryAvroEncoder - SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() + // BEGIN: readme-sample-createSchemaRegistryAvroSerializer + SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") - .buildEncoder(); - // END: readme-sample-createSchemaRegistryAvroEncoder + .buildSerializer(); + // END: readme-sample-createSchemaRegistryAvroSerializer - return encoder; + return serializer; } /** * Encode a strongly-typed object into avro payload compatible with schema registry. */ - public void encodeSample() { - SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); + public void serializeSample() { + SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); - // BEGIN: readme-sample-encodeSample + // BEGIN: readme-sample-serializeSample PlayingCard playingCard = new PlayingCard(); playingCard.setPlayingCardSuit(PlayingCardSuit.SPADES); playingCard.setIsFaceCard(false); playingCard.setCardValue(5); - BinaryContent message = encoder.serializeMessageData(playingCard, + BinaryContent message = serializer.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.class)); - // END: readme-sample-encodeSample + // END: readme-sample-serializeSample } /** * Decode avro payload compatible with schema registry into a strongly-type object. */ - public void decodeSample() { - // BEGIN: readme-sample-decodeSample - SchemaRegistryApacheAvroSerializer encoder = createAvroSchemaRegistryEncoder(); + public void deserializeSample() { + // BEGIN: readme-sample-deserializeSample + SchemaRegistryApacheAvroSerializer serializer = createAvroSchemaRegistrySerializer(); BinaryContent message = getSchemaRegistryAvroMessage(); - PlayingCard playingCard = encoder.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); - // END: readme-sample-decodeSample + PlayingCard playingCard = serializer.deserializeMessageData(message, TypeReference.createInstance(PlayingCard.class)); + // END: readme-sample-deserializeSample } /** diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java similarity index 88% rename from sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java rename to sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java index f63a3f7d97b8c..38e7f39e3a959 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java @@ -15,7 +15,7 @@ /** * Sample to demonstrate using {@link SchemaRegistryApacheAvroSerializer} for serialization and deserialization of data. */ -public class SchemaRegistryApacheAvroEncoderSample { +public class SchemaRegistryApacheAvroSerializerSample { /** * Main method to run this sample. * @@ -33,11 +33,11 @@ public static void main(String[] args) { // Create the encoder instance by configuring it with the schema registry client and // enabling auto registering of new schemas - SchemaRegistryApacheAvroSerializer encoder = new SchemaRegistryApacheAvroSerializerBuilder() + SchemaRegistryApacheAvroSerializer serializer = new SchemaRegistryApacheAvroSerializerBuilder() .schemaRegistryAsyncClient(schemaRegistryAsyncClient) .schemaGroup("{schema-group}") .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); PlayingCard playingCard = new PlayingCard(); playingCard.setCardValue(5); @@ -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. - BinaryContent message = encoder.serializeMessageData(playingCard, + BinaryContent message = serializer.serializeMessageData(playingCard, TypeReference.createInstance(BinaryContent.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 80fbae55983a3..fb836f1f819e5 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 @@ -42,7 +42,7 @@ public static void main(String[] args) { .schemaGroup("{schema-group}") .avroSpecificReader(true) .autoRegisterSchema(true) - .buildEncoder(); + .buildSerializer(); // Get serialized avro data to deserialize into strongly-typed object. BinaryContent inputStream = getMessageToDeserialize(); 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 e05634ebda80e..b2323fe7d0323 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 @@ -103,7 +103,7 @@ public void registerAndGetSchema() { .schemaGroup(schemaGroup) .schemaRegistryAsyncClient(builder.buildAsyncClient()) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final PlayingCard playingCard = PlayingCard.newBuilder() .setCardValue(1) 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 1cf0ccc86755f..fc8bda6f4b7c2 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 @@ -321,7 +321,7 @@ public void serializeFromPortal() { .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final String expectedContentType = AVRO_MIME_TYPE + "+64fc737160ff41bdb8a0b8af028e6827"; // Act @@ -347,7 +347,7 @@ public void serializeForwardCompatibility() { .schemaGroup(PLAYBACK_TEST_GROUP) .schemaRegistryAsyncClient(client) .avroSpecificReader(true) - .buildEncoder(); + .buildSerializer(); final String expectedContentType = AVRO_MIME_TYPE + "+f047cfa64b374167b3a1d101370c1483"; final String name = "Jackson"; From 6b43d9451e5cd56ef5e4d8961b81c2b3283ff717 Mon Sep 17 00:00:00 2001 From: Connie Date: Fri, 11 Mar 2022 10:52:52 -0800 Subject: [PATCH 16/16] Fix broken link --- .../azure-data-schemaregistry-apacheavro/src/samples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md index fe8c37a9f7998..cf8e66173e4b9 100644 --- a/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md +++ b/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/README.md @@ -40,7 +40,7 @@ This project welcomes contributions and suggestions. See [Contributing][sdk_read [sdk_readme_troubleshooting]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#troubleshooting [sdk_readme_next_steps]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#next-steps [sdk_readme_contributing]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/README.md#contributing -[sample_avro_serialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroEncoderSample.java +[sample_avro_serialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryApacheAvroSerializerSample.java [sample_avro_deserialization]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/schemaregistry/azure-data-schemaregistry-apacheavro/src/samples/java/com/azure/data/schemaregistry/apacheavro/SchemaRegistryAvroDeserializationSample.java ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-java%2Fsdk%schemaregistry%2Fazure-data-schemaregistry-apacheavro%2Fsrc%2Fsamples%2README.png)