|
32 | 32 | import co.elastic.clients.elasticsearch._types.query_dsl.Query;
|
33 | 33 | import co.elastic.clients.elasticsearch._types.query_dsl.ShapeQuery;
|
34 | 34 | import co.elastic.clients.elasticsearch._types.query_dsl.TermQuery;
|
| 35 | +import co.elastic.clients.elasticsearch.cluster.HealthResponse; |
35 | 36 | import co.elastic.clients.elasticsearch.connector.UpdateIndexNameRequest;
|
36 | 37 | import co.elastic.clients.elasticsearch.core.rank_eval.RankEvalQuery;
|
37 | 38 | import co.elastic.clients.elasticsearch.core.search.SourceFilter;
|
38 | 39 | import co.elastic.clients.json.JsonData;
|
39 | 40 | import co.elastic.clients.json.LazyDeserializer;
|
40 | 41 | import co.elastic.clients.json.ObjectDeserializer;
|
41 | 42 | import co.elastic.clients.testkit.ModelTestCase;
|
| 43 | +import co.elastic.clients.util.ApiTypeHelper; |
42 | 44 | import co.elastic.clients.util.MapBuilder;
|
43 | 45 | import jakarta.json.stream.JsonParsingException;
|
44 | 46 | import org.junit.jupiter.api.Test;
|
45 | 47 |
|
| 48 | +import java.io.StringReader; |
| 49 | + |
46 | 50 | import static co.elastic.clients.elasticsearch._types.query_dsl.Query.Kind.MatchAll;
|
47 | 51 |
|
48 | 52 | public class BehaviorsTest extends ModelTestCase {
|
@@ -345,4 +349,34 @@ public void testWithNull() {
|
345 | 349 | assertEquals(jsonValue,toJson(updateValue));
|
346 | 350 | assertEquals(jsonNull,toJson(updateNull));
|
347 | 351 | }
|
| 352 | + |
| 353 | + @Test |
| 354 | + public void testDangerousDisablePropertyCheckPrimitive(){ |
| 355 | + try (ApiTypeHelper.DisabledChecksHandle h = |
| 356 | + ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true)) { |
| 357 | + HealthResponse healthResponse = HealthResponse.of(hr -> hr.withJson(new StringReader("{\n" + |
| 358 | + " \"cluster_name\" : \"6f47f6476fb04820aeaae5cfabf3c3f7\",\n" + |
| 359 | + " \"status\" : \"green\",\n" + |
| 360 | + " \"timed_out\" : false,\n" + |
| 361 | + " \"number_of_nodes\" : 3,\n" + |
| 362 | + " \"number_of_data_nodes\" : 2,\n" + |
| 363 | + " \"active_primary_shards\" : 88,\n" + |
| 364 | + " \"active_shards\" : 176,\n" + |
| 365 | + " \"relocating_shards\" : 0,\n" + |
| 366 | + " \"initializing_shards\" : 0,\n" + |
| 367 | + " \"unassigned_shards\" : 0,\n" + |
| 368 | + " \"delayed_unassigned_shards\" : 0,\n" + |
| 369 | + " \"number_of_pending_tasks\" : 0,\n" + |
| 370 | + " \"number_of_in_flight_fetch\" : 0,\n" + |
| 371 | + " \"task_max_waiting_in_queue_millis\" : 0,\n" + |
| 372 | + " \"active_shards_percent_as_number\" : 100.0\n" + |
| 373 | + "}"))); |
| 374 | + |
| 375 | + // checking that a required, but missing property has its default value assigned |
| 376 | + assertTrue(healthResponse.unassignedShards()==0); |
| 377 | + |
| 378 | + // checking that roundtrip works |
| 379 | + assertTrue(healthResponse.toString()!=null); |
| 380 | + } |
| 381 | + } |
348 | 382 | }
|
0 commit comments