mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-01 09:42:11 +00:00
parent
6eb038a344
commit
4344a65dc2
@ -18,11 +18,16 @@ package org.springframework.data.elasticsearch.config;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.commons.lang.ClassUtils;
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.main.MainResponse;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@ -110,7 +115,10 @@ public class ElasticsearchConfigurationSupportUnitTests {
|
||||
|
||||
@Override
|
||||
public ReactiveElasticsearchClient reactiveElasticsearchClient() {
|
||||
return mock(ReactiveElasticsearchClient.class);
|
||||
ReactiveElasticsearchClient client = mock(ReactiveElasticsearchClient.class);
|
||||
when(client.info()).thenReturn(Mono
|
||||
.just(new MainResponse("mockNodename", Version.CURRENT, new ClusterName("mockCluster"), "mockUuid", null)));
|
||||
return client;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.action.DocWriteResponse;
|
||||
import org.elasticsearch.action.bulk.BulkItemResponse;
|
||||
import org.elasticsearch.action.bulk.BulkRequest;
|
||||
@ -39,7 +40,9 @@ import org.elasticsearch.action.get.GetRequest;
|
||||
import org.elasticsearch.action.get.MultiGetRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.main.MainResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.index.get.GetResult;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -66,6 +69,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* @author Roman Puchkovskiy
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||
@ -90,6 +94,9 @@ public class ReactiveElasticsearchTemplateCallbackTests {
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
when(client.info()).thenReturn(
|
||||
Mono.just(new MainResponse("mockNodename", Version.CURRENT, new ClusterName("mockCluster"), "mockUuid", null)));
|
||||
|
||||
template = new ReactiveElasticsearchTemplate(client);
|
||||
|
||||
when(client.index(any(IndexRequest.class))).thenReturn(Mono.just(indexResponse));
|
||||
|
@ -35,9 +35,11 @@ import java.util.Collections;
|
||||
|
||||
import org.elasticsearch.action.delete.DeleteRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.main.MainResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.support.IndicesOptions;
|
||||
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
||||
import org.elasticsearch.cluster.ClusterName;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -76,6 +78,9 @@ public class ReactiveElasticsearchTemplateUnitTests {
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
|
||||
when(client.info()).thenReturn(Mono.just(new MainResponse("mockNodename", org.elasticsearch.Version.CURRENT,
|
||||
new ClusterName("mockCluster"), "mockUuid", null)));
|
||||
|
||||
template = new ReactiveElasticsearchTemplate(client);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user