3737import static org .elasticsearch .xpack .core .watcher .support .WatcherDateTimeUtils .formatDate ;
3838import static org .elasticsearch .xpack .core .watcher .support .WatcherUtils .flattenModel ;
3939import static org .elasticsearch .xpack .watcher .input .search .ExecutableSearchInput .DEFAULT_SEARCH_TYPE ;
40+ import static org .elasticsearch .xpack .watcher .support .search .WatcherSearchTemplateRequest .DEFAULT_INDICES_OPTIONS ;
4041import static org .elasticsearch .xpack .watcher .test .WatcherTestUtils .getRandomSupportedSearchType ;
4142import static org .hamcrest .Matchers .arrayContainingInAnyOrder ;
4243import static org .hamcrest .Matchers .equalTo ;
@@ -92,7 +93,9 @@ public void testSerializeSearchRequest() throws Exception {
9293 String [] expectedIndices = generateRandomStringArray (5 , 5 , true );
9394 String [] expectedTypes = generateRandomStringArray (2 , 5 , true , false );
9495 IndicesOptions expectedIndicesOptions = IndicesOptions .fromOptions (randomBoolean (), randomBoolean (), randomBoolean (),
95- randomBoolean (), WatcherSearchTemplateRequest .DEFAULT_INDICES_OPTIONS );
96+ randomBoolean (), randomBoolean (), DEFAULT_INDICES_OPTIONS .allowAliasesToMultipleIndices (),
97+ DEFAULT_INDICES_OPTIONS .forbidClosedIndices (), DEFAULT_INDICES_OPTIONS .ignoreAliases (),
98+ DEFAULT_INDICES_OPTIONS .ignoreThrottled ());
9699 SearchType expectedSearchType = getRandomSupportedSearchType ();
97100
98101 BytesReference expectedSource = null ;
@@ -150,7 +153,6 @@ public void testSerializeSearchRequest() throws Exception {
150153 }
151154 }
152155
153- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/65397" )
154156 public void testDeserializeSearchRequest () throws Exception {
155157
156158 XContentBuilder builder = jsonBuilder ().startObject ();
@@ -175,18 +177,14 @@ public void testDeserializeSearchRequest() throws Exception {
175177 }
176178 }
177179
178- IndicesOptions indicesOptions = WatcherSearchTemplateRequest . DEFAULT_INDICES_OPTIONS ;
180+ IndicesOptions indicesOptions = DEFAULT_INDICES_OPTIONS ;
179181 if (randomBoolean ()) {
180182 indicesOptions = IndicesOptions .fromOptions (randomBoolean (), randomBoolean (), randomBoolean (),
181- randomBoolean (), WatcherSearchTemplateRequest .DEFAULT_INDICES_OPTIONS );
182- builder .startObject ("indices_options" )
183- .field ("allow_no_indices" , indicesOptions .allowNoIndices ())
184- .field ("expand_wildcards" , indicesOptions .expandWildcardsClosed () && indicesOptions .expandWildcardsOpen () ? "all" :
185- indicesOptions .expandWildcardsClosed () ? "closed" :
186- indicesOptions .expandWildcardsOpen () ? "open" :
187- "none" )
188- .field ("ignore_unavailable" , indicesOptions .ignoreUnavailable ())
189- .endObject ();
183+ randomBoolean (), randomBoolean (), indicesOptions .allowAliasesToMultipleIndices (),
184+ indicesOptions .forbidClosedIndices (), indicesOptions .ignoreAliases (), indicesOptions .ignoreThrottled ());
185+ builder .startObject ("indices_options" );
186+ indicesOptions .toXContent (builder , ToXContent .EMPTY_PARAMS );
187+ builder .endObject ();
190188 }
191189
192190 SearchType searchType = SearchType .DEFAULT ;
@@ -248,5 +246,4 @@ public void testDeserializeSearchRequest() throws Exception {
248246 assertWarnings (WatcherSearchTemplateRequest .TYPES_DEPRECATION_MESSAGE );
249247 }
250248 }
251-
252249}
0 commit comments