.put(indexBuilder("foofoo").putAlias(AliasMetaData.builder("barbaz")));
MetaData md = mdBuilder.build();
//ignore unavailable and allow no indices
{
IndicesOptions noExpandLenient = IndicesOptions.fromOptions(true, true, false, false);
String[] results = md.concreteIndices(noExpandLenient, "baz*");
assertThat(results, emptyArray());
results = md.concreteIndices(noExpandLenient, "foo", "baz*");
assertEquals(1, results.length);
assertEquals("foo", results[0]);
results = md.concreteIndices(noExpandLenient, "foofoobar");
assertEquals(2, results.length);
assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
}
//ignore unavailable but don't allow no indices
{
IndicesOptions noExpandDisallowEmpty = IndicesOptions.fromOptions(true, false, false, false);
try {
md.concreteIndices(noExpandDisallowEmpty, "baz*");
fail();
} catch (IndexMissingException e) {
assertThat(e.index().name(), equalTo("baz*"));
}
String[] results = md.concreteIndices(noExpandDisallowEmpty, "foo", "baz*");
assertEquals(1, results.length);
assertEquals("foo", results[0]);
results = md.concreteIndices(noExpandDisallowEmpty, "foofoobar");
assertEquals(2, results.length);
assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
}
//error on unavailable but allow no indices
{
IndicesOptions noExpandErrorUnavailable = IndicesOptions.fromOptions(false, true, false, false);
String[] results = md.concreteIndices(noExpandErrorUnavailable, "baz*");
assertThat(results, emptyArray());
try {
md.concreteIndices(noExpandErrorUnavailable, "foo", "baz*");
fail();
} catch (IndexMissingException e) {
assertThat(e.index().name(), equalTo("baz*"));
}
results = md.concreteIndices(noExpandErrorUnavailable, "foofoobar");
assertEquals(2, results.length);
assertThat(results, arrayContainingInAnyOrder("foo", "foobar"));
}
//error on both unavailable and no indices
{
IndicesOptions noExpandStrict = IndicesOptions.fromOptions(false, false, false, false);
try {
md.concreteIndices(noExpandStrict, "baz*");
fail();
} catch (IndexMissingException e) {