mirror of
				https://github.com/spring-projects/spring-data-elasticsearch.git
				synced 2025-10-30 22:28:47 +00:00 
			
		
		
		
	Added RefreshPolicy setter to the AbstractElasticsearchTemplate copy method.
Original Pull Request #1976 Closes #1978
This commit is contained in:
		
							parent
							
								
									f1b4a54bc2
								
							
						
					
					
						commit
						8894dd3d21
					
				| @ -70,6 +70,7 @@ import org.springframework.util.Assert; | ||||
|  * @author Roman Puchkovskiy | ||||
|  * @author Subhobrata Dey | ||||
|  * @author Steven Pearce | ||||
|  * @author Anton Naydenov | ||||
|  */ | ||||
| public abstract class AbstractElasticsearchTemplate implements ElasticsearchOperations, ApplicationContextAware { | ||||
| 
 | ||||
| @ -110,6 +111,7 @@ public abstract class AbstractElasticsearchTemplate implements ElasticsearchOper | ||||
| 		} | ||||
| 
 | ||||
| 		copy.setRoutingResolver(routingResolver); | ||||
| 		copy.setRefreshPolicy(refreshPolicy); | ||||
| 
 | ||||
| 		return copy; | ||||
| 	} | ||||
|  | ||||
| @ -33,11 +33,9 @@ import org.springframework.data.annotation.Id; | ||||
| import org.springframework.data.elasticsearch.annotations.Document; | ||||
| import org.springframework.data.elasticsearch.annotations.Routing; | ||||
| import org.springframework.data.elasticsearch.annotations.Setting; | ||||
| import org.springframework.data.elasticsearch.core.ElasticsearchOperations; | ||||
| import org.springframework.data.elasticsearch.core.IndexOperations; | ||||
| import org.springframework.data.elasticsearch.core.MultiGetItem; | ||||
| import org.springframework.data.elasticsearch.core.SearchHits; | ||||
| import org.springframework.data.elasticsearch.core.*; | ||||
| import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; | ||||
| import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext; | ||||
| import org.springframework.data.elasticsearch.core.query.BaseQuery; | ||||
| import org.springframework.data.elasticsearch.core.query.Query; | ||||
| import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; | ||||
| @ -47,6 +45,7 @@ import org.springframework.test.context.ContextConfiguration; | ||||
| 
 | ||||
| /** | ||||
|  * @author Peter-Josef Meisch | ||||
|  * @author Anton Naydenov | ||||
|  */ | ||||
| @SuppressWarnings("ConstantConditions") | ||||
| @SpringIntegrationTest | ||||
| @ -159,6 +158,21 @@ public class ElasticsearchOperationsRoutingTests { | ||||
| 		softly.assertAll(); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	void shouldCreateACopyOfTheClientWithRefreshPolicy() { | ||||
| 		//given | ||||
| 		AbstractElasticsearchTemplate sourceTemplate = (AbstractElasticsearchTemplate) operations; | ||||
| 		SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext(); | ||||
| 		DefaultRoutingResolver defaultRoutingResolver = new DefaultRoutingResolver(mappingContext); | ||||
| 
 | ||||
| 		//when | ||||
| 		ElasticsearchOperations operationsCopy = this.operations.withRouting(defaultRoutingResolver); | ||||
| 		AbstractElasticsearchTemplate copyTemplate = (AbstractElasticsearchTemplate) operationsCopy; | ||||
| 
 | ||||
| 		//then | ||||
| 		assertThat(sourceTemplate.getRefreshPolicy()).isEqualTo(copyTemplate.getRefreshPolicy()); | ||||
| 	} | ||||
| 
 | ||||
| 	@Document(indexName = INDEX) | ||||
| 	@Setting(shards = 7) | ||||
| 	@Routing("routing") | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user