|
34 | 34 |
|
35 | 35 | import java.util.Arrays;
|
36 | 36 | import java.util.Map;
|
| 37 | + |
37 | 38 | import org.junit.Test;
|
| 39 | +import org.opensearch.client.json.JsonData; |
38 | 40 | import org.opensearch.client.opensearch._types.Time;
|
39 | 41 | import org.opensearch.client.opensearch._types.analysis.Analyzer;
|
40 | 42 | import org.opensearch.client.opensearch._types.analysis.TokenFilterDefinition;
|
|
53 | 55 | import org.opensearch.client.opensearch.indices.IndexSettingsSearch;
|
54 | 56 | import org.opensearch.client.opensearch.indices.Translog;
|
55 | 57 | import org.opensearch.client.opensearch.indices.get_field_mapping.TypeFieldMappings;
|
| 58 | +import org.opensearch.client.opensearch.ingest.ConvertType; |
| 59 | +import org.opensearch.client.opensearch.ingest.PutPipelineRequest; |
56 | 60 | import org.opensearch.client.opensearch.model.ModelTestCase;
|
57 | 61 |
|
58 | 62 | public class ParsingTests extends ModelTestCase {
|
@@ -320,11 +324,11 @@ public void testIndexSettingsSearch() {
|
320 | 324 | s -> s.level("info")
|
321 | 325 | .threshold(
|
322 | 326 | t -> t.query(
|
323 |
| - it -> it.debug(Time.of(ti -> ti.time("500ms"))) |
324 |
| - .info(Time.of(ti -> ti.time("1000ms"))) |
325 |
| - .trace(Time.of(ti -> ti.time("200ms"))) |
326 |
| - .warn(Time.of(ti -> ti.time("5000ms"))) |
327 |
| - ) |
| 327 | + it -> it.debug(Time.of(ti -> ti.time("500ms"))) |
| 328 | + .info(Time.of(ti -> ti.time("1000ms"))) |
| 329 | + .trace(Time.of(ti -> ti.time("200ms"))) |
| 330 | + .warn(Time.of(ti -> ti.time("5000ms"))) |
| 331 | + ) |
328 | 332 | .fetch(
|
329 | 333 | it -> it.debug(Time.of(ti -> ti.time("5ms")))
|
330 | 334 | .info(Time.of(ti -> ti.time("10ms")))
|
@@ -357,4 +361,29 @@ public void testIndexSettingsSearch() {
|
357 | 361 | assertEquals(search.idle().after().time(), deserialized.idle().after().time());
|
358 | 362 |
|
359 | 363 | }
|
| 364 | + |
| 365 | + @Test |
| 366 | + public void testPutPipelineRequestDeserialization() { |
| 367 | + var putPipelineRequest = PutPipelineRequest.of(b -> |
| 368 | + b.id("test-pipeline") |
| 369 | + .description("pipeline desc") |
| 370 | + .processors(p -> p.convert(c -> c.field("age").targetField("age").type(ConvertType.Integer))) |
| 371 | + ); |
| 372 | + |
| 373 | + var input = "{\"id\":\"test-pipeline\",\"description\":\"pipeline desc\"," + |
| 374 | + "\"processors\":[{\"convert\":{\"field\":\"age\",\"target_field\":\"age\",\"type\":\"integer\"}}]}"; |
| 375 | + |
| 376 | + var deserialized = fromJson(input, PutPipelineRequest._DESERIALIZER); |
| 377 | + |
| 378 | + assertEquals(putPipelineRequest.id(), deserialized.id()); |
| 379 | + assertEquals(putPipelineRequest.description(), deserialized.description()); |
| 380 | + assertEquals(putPipelineRequest.processors().size(), deserialized.processors().size()); |
| 381 | + |
| 382 | + var processor = putPipelineRequest.processors().get(0); |
| 383 | + var deserializedProcessor = deserialized.processors().get(0); |
| 384 | + assertEquals(processor._kind(), deserializedProcessor._kind()); |
| 385 | + assertEquals(processor.convert().field(), deserializedProcessor.convert().field()); |
| 386 | + assertEquals(processor.convert().targetField(), deserializedProcessor.convert().targetField()); |
| 387 | + assertEquals(processor.convert().type(), deserializedProcessor.convert().type()); |
| 388 | + } |
360 | 389 | }
|
0 commit comments