Skip to content

Commit 661c2ed

Browse files
committed
update test
1 parent f997002 commit 661c2ed

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

java-client/src/test/java/co/elastic/clients/elasticsearch/model/VariantsTest.java

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,64 @@ public void testContainerWithOptionalVariants() {
288288
@Test
289289
public void testBooleanVariantTag() {
290290

291-
String jsonT = "{\"indices\":{\"test\":{\"index\":\"test\",\"managed\":true,\"policy\":\"my_policy\"," +
292-
"\"index_creation_date_millis\":1736785235558,\"time_since_index_creation\":\"27.75d\"," +
293-
"\"lifecycle_date_millis\":1736785235558,\"age\":\"27.75d\",\"phase\":\"warm\"," +
294-
"\"phase_time_millis\":1739183166898,\"action\":\"migrate\",\"action_time_millis\":1739183166898," +
295-
"\"step\":\"check-migration\",\"step_time_millis\":1739183166898," +
296-
"\"step_info\":{\"message\":\"Waiting for all shard copies to be active\"," +
297-
"\"shards_left_to_allocate\":-1,\"all_shards_active\":false,\"number_of_replicas\":1}," +
298-
"\"phase_execution\":{\"policy\":\"my_policy\",\"phase_definition\":{\"min_age\":\"10d\"," +
299-
"\"actions\":{\"forcemerge\":{\"max_num_segments\":1}}},\"version\":1," +
300-
"\"modified_date_in_millis\":1739183005443}}}}";
291+
String jsonT = "{\n" +
292+
" \"indices\": {\n" +
293+
" \"test\": {\n" +
294+
" \"index\": \"test\",\n" +
295+
" \"managed\": true,\n" +
296+
" \"policy\": \"my_policy\",\n" +
297+
" \"index_creation_date_millis\": 1736785235558,\n" +
298+
" \"time_since_index_creation\": \"27.75d\",\n" +
299+
" \"lifecycle_date_millis\": 1736785235558,\n" +
300+
" \"age\": \"27.75d\",\n" +
301+
" \"phase\": \"warm\",\n" +
302+
" \"phase_time_millis\": 1739183166898,\n" +
303+
" \"action\": \"migrate\",\n" +
304+
" \"action_time_millis\": 1739183166898,\n" +
305+
" \"step\": \"check-migration\",\n" +
306+
" \"step_time_millis\": 1739183166898,\n" +
307+
" \"step_info\": {\n" +
308+
" \"message\": \"Waiting for all shard copies to be active\",\n" +
309+
" \"shards_left_to_allocate\": -1,\n" +
310+
" \"all_shards_active\": false,\n" +
311+
" \"number_of_replicas\": 1\n" +
312+
" },\n" +
313+
" \"phase_execution\": {\n" +
314+
" \"policy\": \"my_policy\",\n" +
315+
" \"phase_definition\": {\n" +
316+
" \"min_age\": \"10d\",\n" +
317+
" \"actions\": {\n" +
318+
" \"forcemerge\": {\n" +
319+
" \"max_num_segments\": 1\n" +
320+
" }\n" +
321+
" }\n" +
322+
" },\n" +
323+
" \"version\": 1,\n" +
324+
" \"modified_date_in_millis\": 1739183005443\n" +
325+
" }\n" +
326+
" }\n" +
327+
" }\n" +
328+
"}";
301329

302330
ExplainLifecycleResponse respT = fromJson(jsonT,ExplainLifecycleResponse.class);
303331

304332
// if managed is "true" then the variant class must be Managed
305333
assertTrue(respT.indices().get("test").isTrue());
306334
assertTrue(respT.indices().get("test")._get().getClass().equals(LifecycleExplainManaged.class));
307335

308-
String jsonF = "{\"indices\":{\"test\":{\"index\":\"test\",\"managed\":false}}}";
336+
String jsonF = "{\n" +
337+
" \"indices\": {\n" +
338+
" \"test\": {\n" +
339+
" \"index\": \"test\",\n" +
340+
" \"managed\": false\n" +
341+
" }\n" +
342+
" }\n" +
343+
"}";
309344

310345
ExplainLifecycleResponse respF = fromJson(jsonF,ExplainLifecycleResponse.class);
311346

312347
// if managed is "false" then the variant class must be Unmanaged
313348
assertTrue(respF.indices().get("test").isFalse());
314349
assertTrue(respF.indices().get("test")._get().getClass().equals(LifecycleExplainUnmanaged.class));
315-
316-
// roundtrip isn't the same
317-
// ExplainLifecycleResponse respT2 = checkJsonRoundtrip(respT, jsonT);
318-
// ExplainLifecycleResponse respF2 = checkJsonRoundtrip(respF, jsonF);
319350
}
320351
}

0 commit comments

Comments
 (0)