use of org.opensearch.cluster.metadata.AliasMetadata in project OpenSearch by opensearch-project.
the class RestGetAliasesActionTests method testAliasWildcardsIncludeAndExcludeSomeAndExplicitMissing.
public void testAliasWildcardsIncludeAndExcludeSomeAndExplicitMissing() throws Exception {
final XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON);
final ImmutableOpenMap.Builder<String, List<AliasMetadata>> openMapBuilder = ImmutableOpenMap.builder();
final AliasMetadata aliasMetadata = AliasMetadata.builder("foo").build();
openMapBuilder.put("index", Arrays.asList(aliasMetadata));
final String[] aliasPattern;
if (randomBoolean()) {
aliasPattern = new String[] { "missing", "foo*", "-foob*" };
} else {
aliasPattern = new String[] { "foo*", "-foob*", "missing" };
}
final RestResponse restResponse = RestGetAliasesAction.buildRestResponse(true, aliasPattern, openMapBuilder.build(), xContentBuilder);
assertThat(restResponse.status(), equalTo(NOT_FOUND));
assertThat(restResponse.contentType(), equalTo("application/json; charset=UTF-8"));
assertThat(restResponse.content().utf8ToString(), equalTo("{\"error\":\"alias [missing] missing\",\"status\":404,\"index\":{\"aliases\":{\"foo\":{}}}}"));
}
Aggregations