Search in sources :

Example 1 with DefaultRoutingResolver

use of org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver in project spring-data-elasticsearch by spring-projects.

the class EntityOperationsTest method shouldReturnRoutingFromRoutingWhenJoinFieldIsSet.

// #1218
@Test
@DisplayName("should return routing from routing when JoinField is set")
void shouldReturnRoutingFromRoutingWhenJoinFieldIsSet() {
    EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
    entity.setId("42");
    entity.setRouting("theRoute");
    entity.setJoinField(new JoinField<>("foo", "foo-routing"));
    EntityOperations.AdaptibleEntity<EntityWithRoutingAndJoinField> adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext));
    String routing = adaptibleEntity.getRouting();
    assertThat(routing).isEqualTo("theRoute");
}
Also used : DefaultRoutingResolver(org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 2 with DefaultRoutingResolver

use of org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver in project spring-data-elasticsearch by spring-projects.

the class EntityOperationsTest method shouldReturnRoutingFromDefaultRoutingAccessor.

// #1218
@Test
@DisplayName("should return routing from DefaultRoutingAccessor")
void shouldReturnRoutingFromDefaultRoutingAccessor() {
    EntityWithRouting entity = new EntityWithRouting();
    entity.setId("42");
    entity.setRouting("theRoute");
    EntityOperations.AdaptibleEntity<EntityWithRouting> adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext));
    String routing = adaptibleEntity.getRouting();
    assertThat(routing).isEqualTo("theRoute");
}
Also used : DefaultRoutingResolver(org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Example 3 with DefaultRoutingResolver

use of org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver in project spring-data-elasticsearch by spring-projects.

the class EntityOperationsTest method shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull.

// #1218
@Test
@DisplayName("should return routing from JoinField when routing value is null")
void shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull() {
    EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField();
    entity.setId("42");
    entity.setJoinField(new JoinField<>("foo", "foo-routing"));
    EntityOperations.AdaptibleEntity<EntityWithRoutingAndJoinField> adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext));
    String routing = adaptibleEntity.getRouting();
    assertThat(routing).isEqualTo("foo-routing");
}
Also used : DefaultRoutingResolver(org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

DisplayName (org.junit.jupiter.api.DisplayName)3 Test (org.junit.jupiter.api.Test)3 DefaultRoutingResolver (org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver)3