From b6c6d4bb3ad073a1d7302f17156f060070e5d606 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 --- .../opensearch/ingest/PutPipelineRequest.java | 1 + .../opensearch/experiments/ParsingTests.java | 39 ++++++++++++++++--- 2 files changed, 35 insertions(+), 5 deletions(-) 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 s.level("info") .threshold( t -> t.query( - it -> it.debug(Time.of(ti -> ti.time("500ms"))) - .info(Time.of(ti -> ti.time("1000ms"))) - .trace(Time.of(ti -> ti.time("200ms"))) - .warn(Time.of(ti -> ti.time("5000ms"))) - ) + it -> it.debug(Time.of(ti -> ti.time("500ms"))) + .info(Time.of(ti -> ti.time("1000ms"))) + .trace(Time.of(ti -> ti.time("200ms"))) + .warn(Time.of(ti -> ti.time("5000ms"))) + ) .fetch( it -> it.debug(Time.of(ti -> ti.time("5ms"))) .info(Time.of(ti -> ti.time("10ms"))) @@ -357,4 +361,29 @@ public void testIndexSettingsSearch() { assertEquals(search.idle().after().time(), deserialized.idle().after().time()); } + + @Test + public void testPutPipelineRequestDeserialization() { + var putPipelineRequest = PutPipelineRequest.of(b -> + 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()); + } }