Search in sources :

Example 6 with AliasData

use of org.springframework.data.elasticsearch.core.index.AliasData in project spring-data-elasticsearch by spring-projects.

the class ReactiveIndexOperationsTest method shouldGetAliasData.

// DATAES-864
@Test
void shouldGetAliasData() {
    ReactiveIndexOperations indexOps = operations.indexOps(Entity.class);
    AliasActions aliasActions = new AliasActions();
    aliasActions.add(new AliasAction.Add(AliasActionParameters.builder().withIndices(indexOps.getIndexCoordinates().getIndexNames()).withAliases("aliasA", "aliasB").build()));
    assertThat(indexOps.create().block()).isTrue();
    assertThat(indexOps.alias(aliasActions).block()).isTrue();
    // 
    indexOps.getAliases("aliasA").as(// 
    StepVerifier::create).assertNext(aliasDatas -> {
        // 
        Set<AliasData> aliasData = aliasDatas.get(indexOps.getIndexCoordinates().getIndexName());
        assertThat(aliasData.stream().map(AliasData::getAlias)).containsExactly("aliasA");
    }).verifyComplete();
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) StepVerifier(reactor.test.StepVerifier) AliasAction(org.springframework.data.elasticsearch.core.index.AliasAction) AliasActions(org.springframework.data.elasticsearch.core.index.AliasActions) Settings(org.springframework.data.elasticsearch.core.index.Settings) Field(org.springframework.data.elasticsearch.annotations.Field) Autowired(org.springframework.beans.factory.annotation.Autowired) JSONAssert(org.skyscreamer.jsonassert.JSONAssert) ReactiveElasticsearchRestTemplateConfiguration(org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration) Mapping(org.springframework.data.elasticsearch.annotations.Mapping) JSONException(org.json.JSONException) Map(java.util.Map) Document(org.springframework.data.elasticsearch.annotations.Document) Assertions(org.assertj.core.api.Assertions) Nullable(org.springframework.lang.Nullable) AliasData(org.springframework.data.elasticsearch.core.index.AliasData) TemplateData(org.springframework.data.elasticsearch.core.index.TemplateData) DeleteTemplateRequest(org.springframework.data.elasticsearch.core.index.DeleteTemplateRequest) ExistsTemplateRequest(org.springframework.data.elasticsearch.core.index.ExistsTemplateRequest) Setting(org.springframework.data.elasticsearch.annotations.Setting) IndexCoordinates(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates) AliasActionParameters(org.springframework.data.elasticsearch.core.index.AliasActionParameters) Set(java.util.Set) Import(org.springframework.context.annotation.Import) Mono(reactor.core.publisher.Mono) UUID(java.util.UUID) DateFormat(org.springframework.data.elasticsearch.annotations.DateFormat) PutTemplateRequest(org.springframework.data.elasticsearch.core.index.PutTemplateRequest) Test(org.junit.jupiter.api.Test) Configuration(org.springframework.context.annotation.Configuration) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest) AfterEach(org.junit.jupiter.api.AfterEach) FieldType(org.springframework.data.elasticsearch.annotations.FieldType) GetTemplateRequest(org.springframework.data.elasticsearch.core.index.GetTemplateRequest) LocalDate(java.time.LocalDate) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Id(org.springframework.data.annotation.Id) Set(java.util.Set) AliasAction(org.springframework.data.elasticsearch.core.index.AliasAction) StepVerifier(reactor.test.StepVerifier) AliasActions(org.springframework.data.elasticsearch.core.index.AliasActions) Test(org.junit.jupiter.api.Test) SpringIntegrationTest(org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)

Aggregations

AliasData (org.springframework.data.elasticsearch.core.index.AliasData)6 Settings (org.springframework.data.elasticsearch.core.index.Settings)5 ArrayList (java.util.ArrayList)3 Test (org.junit.jupiter.api.Test)3 AliasAction (org.springframework.data.elasticsearch.core.index.AliasAction)3 AliasActions (org.springframework.data.elasticsearch.core.index.AliasActions)3 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)3 Nullable (org.springframework.lang.Nullable)3 LocalDate (java.time.LocalDate)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 UUID (java.util.UUID)2 Assertions (org.assertj.core.api.Assertions)2 JSONException (org.json.JSONException)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 JSONAssert (org.skyscreamer.jsonassert.JSONAssert)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Boolean (java.lang.Boolean)1 Long (java.lang.Long)1 Object (java.lang.Object)1