Search in sources :

Example 51 with AliasMetadata

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\":{}}}}"));
}
Also used : AliasMetadata(org.opensearch.cluster.metadata.AliasMetadata) RestResponse(org.opensearch.rest.RestResponse) List(java.util.List) ImmutableOpenMap(org.opensearch.common.collect.ImmutableOpenMap) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder)

Aggregations

AliasMetadata (org.opensearch.cluster.metadata.AliasMetadata)51 List (java.util.List)21 Settings (org.opensearch.common.settings.Settings)16 ArrayList (java.util.ArrayList)13 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)13 ImmutableOpenMap (org.opensearch.common.collect.ImmutableOpenMap)12 Template (org.opensearch.cluster.metadata.Template)10 HashMap (java.util.HashMap)8 Matchers.containsString (org.hamcrest.Matchers.containsString)8 MappingMetadata (org.opensearch.cluster.metadata.MappingMetadata)8 Metadata (org.opensearch.cluster.metadata.Metadata)8 IOException (java.io.IOException)7 ComponentTemplate (org.opensearch.cluster.metadata.ComponentTemplate)7 ComposableIndexTemplate (org.opensearch.cluster.metadata.ComposableIndexTemplate)7 IndexTemplateMetadata (org.opensearch.cluster.metadata.IndexTemplateMetadata)7 CompressedXContent (org.opensearch.common.compress.CompressedXContent)7 HashSet (java.util.HashSet)6 Map (java.util.Map)6 ActionListener (org.opensearch.action.ActionListener)6 GetAliasesRequest (org.opensearch.action.admin.indices.alias.get.GetAliasesRequest)6