Search in sources :

Example 1 with RegexMatcher

use of org.opensearch.test.hamcrest.RegexMatcher in project OpenSearch by opensearch-project.

the class IndicesServiceTests method testConflictingEngineFactories.

public void testConflictingEngineFactories() {
    final String indexName = "foobar";
    final Index index = new Index(indexName, UUIDs.randomBase64UUID());
    final Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT).put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID()).put(FooEnginePlugin.FOO_INDEX_SETTING.getKey(), true).put(BarEnginePlugin.BAR_INDEX_SETTING.getKey(), true).build();
    final IndexMetadata indexMetadata = new IndexMetadata.Builder(index.getName()).settings(settings).numberOfShards(1).numberOfReplicas(0).build();
    final IndicesService indicesService = getIndicesService();
    final IllegalStateException e = expectThrows(IllegalStateException.class, () -> indicesService.createIndex(indexMetadata, Collections.emptyList(), false));
    final String pattern = ".*multiple engine factories provided for \\[foobar/.*\\]: \\[.*FooEngineFactory\\],\\[.*BarEngineFactory\\].*";
    assertThat(e, hasToString(new RegexMatcher(pattern)));
}
Also used : Index(org.opensearch.index.Index) RegexMatcher(org.opensearch.test.hamcrest.RegexMatcher) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Matchers.containsString(org.hamcrest.Matchers.containsString) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) Settings(org.opensearch.common.settings.Settings) IndexSettings(org.opensearch.index.IndexSettings)

Aggregations

Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.hasToString (org.hamcrest.Matchers.hasToString)1 IndexMetadata (org.opensearch.cluster.metadata.IndexMetadata)1 Settings (org.opensearch.common.settings.Settings)1 Index (org.opensearch.index.Index)1 IndexSettings (org.opensearch.index.IndexSettings)1 RegexMatcher (org.opensearch.test.hamcrest.RegexMatcher)1