@@ -217,22 +217,21 @@ public void testGroupClusterIndices() throws IOException {
217
217
assertTrue (service .isRemoteClusterRegistered ("cluster_2" ));
218
218
assertFalse (service .isRemoteClusterRegistered ("foo" ));
219
219
Map <String , List <String >> perClusterIndices = service .groupClusterIndices (service .getRemoteClusterNames (),
220
- new String []{"foo:bar" , "cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" ,
221
- "cluster*:baz" , "*:boo" , "no*match:boo" },
222
- i -> false );
220
+ new String []{"cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" , "cluster*:baz" ,
221
+ "*:boo" });
223
222
List <String > localIndices = perClusterIndices .remove (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY );
224
223
assertNotNull (localIndices );
225
- assertEquals (Arrays . asList ( "foo:bar " , "foo" , "no*match:boo" ), localIndices );
224
+ assertEquals ("foo" , localIndices . get ( 0 ) );
226
225
assertEquals (2 , perClusterIndices .size ());
227
226
assertEquals (Arrays .asList ("bar" , "test" , "baz" , "boo" ), perClusterIndices .get ("cluster_1" ));
228
227
assertEquals (Arrays .asList ("foo:bar" , "foo*" , "baz" , "boo" ), perClusterIndices .get ("cluster_2" ));
229
228
230
- IllegalArgumentException iae = expectThrows (IllegalArgumentException .class , () ->
231
- service .groupClusterIndices (service .getRemoteClusterNames (), new String []{"foo:bar" , "cluster_1:bar" ,
232
- "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" }, "cluster_1:bar" ::equals ));
229
+ expectThrows (NoSuchRemoteClusterException .class , () -> service .groupClusterIndices (service .getRemoteClusterNames (),
230
+ new String []{"foo:bar" , "cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" }));
233
231
234
- assertEquals ("Can not filter indices; index cluster_1:bar exists but there is also a remote cluster named:" +
235
- " cluster_1" , iae .getMessage ());
232
+ expectThrows (NoSuchRemoteClusterException .class , () ->
233
+ service .groupClusterIndices (service .getRemoteClusterNames (), new String []{"cluster_1:bar" ,
234
+ "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "does_not_exist:*" }));
236
235
}
237
236
}
238
237
}
@@ -264,34 +263,28 @@ public void testGroupIndices() throws IOException {
264
263
assertFalse (service .isRemoteClusterRegistered ("foo" ));
265
264
{
266
265
Map <String , OriginalIndices > perClusterIndices = service .groupIndices (IndicesOptions .LENIENT_EXPAND_OPEN ,
267
- new String []{"foo:bar" , "cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" ,
268
- "cluster*:baz" , "*:boo" , "no*match:boo" },
269
- i -> false );
266
+ new String []{"cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" , "cluster*:baz" ,
267
+ "*:boo" });
270
268
assertEquals (3 , perClusterIndices .size ());
271
- assertArrayEquals (new String []{"foo:bar" , "foo" , "no*match:boo " },
269
+ assertArrayEquals (new String []{"foo" },
272
270
perClusterIndices .get (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY ).indices ());
273
271
assertArrayEquals (new String []{"bar" , "test" , "baz" , "boo" }, perClusterIndices .get ("cluster_1" ).indices ());
274
272
assertArrayEquals (new String []{"foo:bar" , "foo*" , "baz" , "boo" }, perClusterIndices .get ("cluster_2" ).indices ());
275
273
}
276
274
{
277
- IllegalArgumentException iae = expectThrows (IllegalArgumentException .class , () ->
278
- service .groupClusterIndices (service .getRemoteClusterNames (), new String []{"foo:bar" , "cluster_1:bar" ,
279
- "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" }, "cluster_1:bar" ::equals ));
280
- assertEquals ("Can not filter indices; index cluster_1:bar exists but there is also a remote cluster named:" +
281
- " cluster_1" , iae .getMessage ());
275
+ expectThrows (NoSuchRemoteClusterException .class , () -> service .groupClusterIndices (service .getRemoteClusterNames (),
276
+ new String []{"foo:bar" , "cluster_1:bar" , "cluster_2:foo:bar" , "cluster_1:test" , "cluster_2:foo*" , "foo" }));
282
277
}
283
278
{
284
279
Map <String , OriginalIndices > perClusterIndices = service .groupIndices (IndicesOptions .LENIENT_EXPAND_OPEN ,
285
- new String []{"cluster_1:bar" , "cluster_2:foo*" },
286
- i -> false );
280
+ new String []{"cluster_1:bar" , "cluster_2:foo*" });
287
281
assertEquals (2 , perClusterIndices .size ());
288
282
assertArrayEquals (new String []{"bar" }, perClusterIndices .get ("cluster_1" ).indices ());
289
283
assertArrayEquals (new String []{"foo*" }, perClusterIndices .get ("cluster_2" ).indices ());
290
284
}
291
285
{
292
286
Map <String , OriginalIndices > perClusterIndices = service .groupIndices (IndicesOptions .LENIENT_EXPAND_OPEN ,
293
- Strings .EMPTY_ARRAY ,
294
- i -> false );
287
+ Strings .EMPTY_ARRAY );
295
288
assertEquals (1 , perClusterIndices .size ());
296
289
assertArrayEquals (Strings .EMPTY_ARRAY , perClusterIndices .get (RemoteClusterAware .LOCAL_CLUSTER_GROUP_KEY ).indices ());
297
290
}
0 commit comments