From ab53a7471f0f5217fac9ed369e9013d6bf11ca8a Mon Sep 17 00:00:00 2001 From: Patrick Schlindwein Date: Sun, 31 Dec 2023 15:05:19 +0100 Subject: [PATCH] Set 'id' field when deserializing a PutPipelineRequest Signed-off-by: Patrick Schlindwein Signed-off-by: Patrick Schlindwein --- CHANGELOG.md | 3 ++- .../opensearch/ingest/PutPipelineRequest.java | 1 + .../opensearch/experiments/ParsingTests.java | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3a10a5a53..9132cde8a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ This section is for maintaining a changelog for all breaking changes for the cli - Fix PutTemplateRequest field deserialization ([#723](https://github.com/opensearch-project/opensearch-java/pull/723)) - Fix PutIndexTemplateRequest field deserialization ([#765](https://github.com/opensearch-project/opensearch-java/pull/765)) - Fix InnerHits storedFields deserialization/serialization ([#781](https://github.com/opensearch-project/opensearch-java/pull/781) +- Fix PutPipelineRequest field deserialization ([#789](https://github.com/opensearch-project/opensearch-java/issues/789) ### Security @@ -258,4 +259,4 @@ This section is for maintaining a changelog for all breaking changes for the cli [2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 -[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 \ No newline at end of file +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/ingest/PutPipelineRequest.java b/java-client/src/main/java/org/opensearch/client/opensearch/ingest/PutPipelineRequest.java index 163e03dda2..80e58122ea 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/ingest/PutPipelineRequest.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/ingest/PutPipelineRequest.java @@ -481,6 +481,7 @@ protected static void setupPutPipelineRequestDeserializer(ObjectDeserializer b.id("test-pipeline") + .description("pipeline desc") + .processors(p -> p.convert(c -> c.field("age").targetField("age").type(ConvertType.Integer))) + ); + + var input = "{\"id\":\"test-pipeline\",\"description\":\"pipeline desc\"," + + "\"processors\":[{\"convert\":{\"field\":\"age\",\"target_field\":\"age\",\"type\":\"integer\"}}]}"; + + var deserialized = fromJson(input, PutPipelineRequest._DESERIALIZER); + + assertEquals(putPipelineRequest.id(), deserialized.id()); + assertEquals(putPipelineRequest.description(), deserialized.description()); + assertEquals(putPipelineRequest.processors().size(), deserialized.processors().size()); + + var processor = putPipelineRequest.processors().get(0); + var deserializedProcessor = deserialized.processors().get(0); + assertEquals(processor._kind(), deserializedProcessor._kind()); + assertEquals(processor.convert().field(), deserializedProcessor.convert().field()); + assertEquals(processor.convert().targetField(), deserializedProcessor.convert().targetField()); + assertEquals(processor.convert().type(), deserializedProcessor.convert().type()); + } }