@@ -228,14 +228,35 @@ public void testParseFromXContentWithDiscoveredMasterField() throws IOException
228
228
NamedXContentRegistry .EMPTY ,
229
229
DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
230
230
"{\" cluster_name\" :\" 535799904437:7-1-3-node\" ,\" status\" :\" green\" ,"
231
- + "\" timed_out\" :false,\" number_of_nodes\" :6,\" number_of_data_nodes\" :3,\" discovered_master\" :false ,"
231
+ + "\" timed_out\" :false,\" number_of_nodes\" :6,\" number_of_data_nodes\" :3,\" discovered_master\" :true ,"
232
232
+ "\" active_primary_shards\" :4,\" active_shards\" :5,\" relocating_shards\" :0,\" initializing_shards\" :0,"
233
233
+ "\" unassigned_shards\" :0,\" delayed_unassigned_shards\" :0,\" number_of_pending_tasks\" :0,"
234
234
+ "\" number_of_in_flight_fetch\" :0,\" task_max_waiting_in_queue_millis\" :0,"
235
235
+ "\" active_shards_percent_as_number\" :100}"
236
236
)
237
237
) {
238
238
239
+ ClusterHealthResponse clusterHealth = ClusterHealthResponse .fromXContent (parser );
240
+ assertNotNull (clusterHealth );
241
+ assertThat (clusterHealth .getClusterName (), Matchers .equalTo ("535799904437:7-1-3-node" ));
242
+ assertThat (clusterHealth .getNumberOfNodes (), Matchers .equalTo (6 ));
243
+ assertThat (clusterHealth .hasDiscoveredMaster (), Matchers .equalTo (true ));
244
+ }
245
+ }
246
+
247
+ public void testParseFromXContentWithoutDiscoveredMasterField () throws IOException {
248
+ try (
249
+ XContentParser parser = JsonXContent .jsonXContent .createParser (
250
+ NamedXContentRegistry .EMPTY ,
251
+ DeprecationHandler .THROW_UNSUPPORTED_OPERATION ,
252
+ "{\" cluster_name\" :\" 535799904437:7-1-3-node\" ,\" status\" :\" green\" ,"
253
+ + "\" timed_out\" :false,\" number_of_nodes\" :6,\" number_of_data_nodes\" :3,"
254
+ + "\" active_primary_shards\" :4,\" active_shards\" :5,\" relocating_shards\" :0,\" initializing_shards\" :0,"
255
+ + "\" unassigned_shards\" :0,\" delayed_unassigned_shards\" :0,\" number_of_pending_tasks\" :0,"
256
+ + "\" number_of_in_flight_fetch\" :0,\" task_max_waiting_in_queue_millis\" :0,"
257
+ + "\" active_shards_percent_as_number\" :100}"
258
+ )
259
+ ) {
239
260
ClusterHealthResponse clusterHealth = ClusterHealthResponse .fromXContent (parser );
240
261
assertNotNull (clusterHealth );
241
262
assertThat (clusterHealth .getClusterName (), Matchers .equalTo ("535799904437:7-1-3-node" ));
0 commit comments