mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-13 07:32:11 +00:00
parent
c50af32fc3
commit
c46a6f4c64
8
pom.xml
8
pom.xml
@ -264,6 +264,14 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-junit-jupiter</artifactId>
|
||||||
|
<version>${mockito}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -18,8 +18,6 @@ package org.springframework.data.elasticsearch.client.reactive;
|
|||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.junit.ClassRule;
|
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.TestNodeResource;
|
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -50,33 +48,27 @@ import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
|||||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||||
import org.elasticsearch.rest.RestStatus;
|
import org.elasticsearch.rest.RestStatus;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersion;
|
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersionRule;
|
|
||||||
import org.springframework.data.elasticsearch.TestUtils;
|
import org.springframework.data.elasticsearch.TestUtils;
|
||||||
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
import org.springframework.data.elasticsearch.client.ClientConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersion;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
|
@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class })
|
||||||
public class ReactiveElasticsearchClientTests {
|
public class ReactiveElasticsearchClientTests {
|
||||||
|
|
||||||
@ClassRule
|
|
||||||
public static TestNodeResource testNodeResource = new TestNodeResource();
|
|
||||||
|
|
||||||
public @Rule ElasticsearchVersionRule elasticsearchVersion = ElasticsearchVersionRule.any();
|
|
||||||
|
|
||||||
static final String INDEX_I = "idx-1-reactive-client-tests";
|
static final String INDEX_I = "idx-1-reactive-client-tests";
|
||||||
static final String INDEX_II = "idx-2-reactive-client-tests";
|
static final String INDEX_II = "idx-2-reactive-client-tests";
|
||||||
|
|
||||||
@ -99,7 +91,7 @@ public class ReactiveElasticsearchClientTests {
|
|||||||
DOC_SOURCE = Collections.unmodifiableMap(source);
|
DOC_SOURCE = Collections.unmodifiableMap(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
syncClient = TestUtils.restHighLevelClient();
|
syncClient = TestUtils.restHighLevelClient();
|
||||||
@ -108,7 +100,7 @@ public class ReactiveElasticsearchClientTests {
|
|||||||
TestUtils.deleteIndex(INDEX_I, INDEX_II);
|
TestUtils.deleteIndex(INDEX_I, INDEX_II);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void after() throws IOException {
|
public void after() throws IOException {
|
||||||
|
|
||||||
TestUtils.deleteIndex(INDEX_I, INDEX_II);
|
TestUtils.deleteIndex(INDEX_I, INDEX_II);
|
||||||
|
@ -23,7 +23,7 @@ import java.util.Collections;
|
|||||||
|
|
||||||
import org.apache.commons.lang.ClassUtils;
|
import org.apache.commons.lang.ClassUtils;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
|
@ -19,8 +19,8 @@ import static org.assertj.core.api.Assertions.*;
|
|||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
@ -29,14 +29,14 @@ import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfig
|
|||||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link AbstractElasticsearchConfiguration}.
|
* Tests for {@link AbstractElasticsearchConfiguration}.
|
||||||
*
|
*
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@ExtendWith(SpringExtension.class)
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class ElasticsearchConfigurationTests {
|
public class ElasticsearchConfigurationTests {
|
||||||
|
|
||||||
|
@ -24,47 +24,36 @@ import lombok.Data;
|
|||||||
import java.lang.Double;
|
import java.lang.Double;
|
||||||
import java.lang.Long;
|
import java.lang.Long;
|
||||||
|
|
||||||
import org.elasticsearch.node.NodeValidationException;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
import org.springframework.data.elasticsearch.Utils;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.Score;
|
import org.springframework.data.elasticsearch.annotations.Score;
|
||||||
import org.springframework.data.elasticsearch.annotations.ScriptedField;
|
import org.springframework.data.elasticsearch.annotations.ScriptedField;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Kevin Leturc
|
* @author Kevin Leturc
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration
|
@ContextConfiguration(classes = { EnableNestedElasticsearchRepositoriesTests.Config.class })
|
||||||
public class EnableNestedElasticsearchRepositoriesTests {
|
public class EnableNestedElasticsearchRepositoriesTests {
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Import({ ElasticsearchTemplateConfiguration.class })
|
||||||
@EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.config.nested" },
|
@EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.config.nested" },
|
||||||
considerNestedRepositories = true)
|
considerNestedRepositories = true)
|
||||||
static class Config {
|
static class Config {}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ElasticsearchOperations elasticsearchTemplate() throws NodeValidationException {
|
|
||||||
return new ElasticsearchTemplate(Utils.getNodeClient());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired(required = false) private SampleRepository nestedRepository;
|
@Autowired(required = false) private SampleRepository nestedRepository;
|
||||||
|
|
||||||
|
@ -24,34 +24,30 @@ import java.lang.Double;
|
|||||||
import java.lang.Long;
|
import java.lang.Long;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.elasticsearch.node.NodeValidationException;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationContextAware;
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
import org.springframework.data.elasticsearch.Utils;
|
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.FieldType;
|
import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||||
import org.springframework.data.elasticsearch.annotations.Score;
|
import org.springframework.data.elasticsearch.annotations.Score;
|
||||||
import org.springframework.data.elasticsearch.annotations.ScriptedField;
|
import org.springframework.data.elasticsearch.annotations.ScriptedField;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||||
import org.springframework.data.repository.Repository;
|
import org.springframework.data.repository.Repository;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -60,8 +56,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
* @author Gad Akuka
|
* @author Gad Akuka
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration
|
@ContextConfiguration(classes = { EnableElasticsearchRepositoriesTests.Config.class })
|
||||||
public class EnableElasticsearchRepositoriesTests implements ApplicationContextAware {
|
public class EnableElasticsearchRepositoriesTests implements ApplicationContextAware {
|
||||||
|
|
||||||
ApplicationContext context;
|
ApplicationContext context;
|
||||||
@ -73,15 +69,9 @@ public class EnableElasticsearchRepositoriesTests implements ApplicationContextA
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Import({ ElasticsearchTemplateConfiguration.class })
|
||||||
@EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.config.notnested" })
|
@EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.config.notnested" })
|
||||||
static class Config {
|
static class Config {}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ElasticsearchOperations elasticsearchTemplate() throws NodeValidationException {
|
|
||||||
|
|
||||||
return new ElasticsearchTemplate(Utils.getNodeClient());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Autowired ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
|
||||||
@ -91,7 +81,7 @@ public class EnableElasticsearchRepositoriesTests implements ApplicationContextA
|
|||||||
|
|
||||||
interface SampleRepository extends Repository<EnableElasticsearchRepositoriesTests.SampleEntity, Long> {}
|
interface SampleRepository extends Repository<EnableElasticsearchRepositoriesTests.SampleEntity, Long> {}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
IndexInitializer.init(elasticsearchTemplate, SampleEntity.class);
|
IndexInitializer.init(elasticsearchTemplate, SampleEntity.class);
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,9 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchStatusException;
|
import org.elasticsearch.ElasticsearchStatusException;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.dao.DataAccessResourceFailureException;
|
import org.springframework.dao.DataAccessResourceFailureException;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
@ -63,9 +61,9 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilde
|
|||||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||||
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersion;
|
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersion;
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersionRule;
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,21 +74,18 @@ import org.springframework.util.StringUtils;
|
|||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
* @author Farid Azaza
|
* @author Farid Azaza
|
||||||
* @author Martin Choraine
|
* @author Martin Choraine
|
||||||
* @currentRead Golden Fool - Robin Hobb
|
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:infrastructure.xml")
|
@ContextConfiguration(classes = { ElasticsearchRestTemplateConfiguration.class })
|
||||||
public class ReactiveElasticsearchTemplateTests {
|
public class ReactiveElasticsearchTemplateTests {
|
||||||
|
|
||||||
public @Rule ElasticsearchVersionRule elasticsearchVersion = ElasticsearchVersionRule.any();
|
|
||||||
|
|
||||||
static final String DEFAULT_INDEX = "reactive-template-test-index";
|
static final String DEFAULT_INDEX = "reactive-template-test-index";
|
||||||
static final String ALTERNATE_INDEX = "reactive-template-tests-alternate-index";
|
static final String ALTERNATE_INDEX = "reactive-template-tests-alternate-index";
|
||||||
|
|
||||||
private ElasticsearchRestTemplate restTemplate;
|
private ElasticsearchRestTemplate restTemplate;
|
||||||
private ReactiveElasticsearchTemplate template;
|
private ReactiveElasticsearchTemplate template;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
deleteIndices();
|
deleteIndices();
|
||||||
@ -103,7 +98,7 @@ public class ReactiveElasticsearchTemplateTests {
|
|||||||
template = new ReactiveElasticsearchTemplate(TestUtils.reactiveClient(), restTemplate.getElasticsearchConverter());
|
template = new ReactiveElasticsearchTemplate(TestUtils.reactiveClient(), restTemplate.getElasticsearchConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
deleteIndices();
|
deleteIndices();
|
||||||
}
|
}
|
||||||
@ -195,9 +190,10 @@ public class ReactiveElasticsearchTemplateTests {
|
|||||||
}).verifyComplete();
|
}).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class) // DATAES-504
|
@Test // DATAES-504
|
||||||
public void insertShouldErrorOnNullEntity() {
|
public void insertShouldErrorOnNullEntity() {
|
||||||
template.save(null);
|
assertThatThrownBy(() -> template.save(null)).isInstanceOf(IllegalArgumentException.class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-519
|
@Test // DATAES-519
|
||||||
@ -247,9 +243,9 @@ public class ReactiveElasticsearchTemplateTests {
|
|||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class) // DATAES-504
|
@Test // DATAES-504
|
||||||
public void findByIdShouldErrorForNullId() {
|
public void findByIdShouldErrorForNullId() {
|
||||||
template.findById(null, SampleEntity.class);
|
assertThatThrownBy(() -> template.findById(null, SampleEntity.class)).isInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-504
|
@Test // DATAES-504
|
||||||
|
@ -40,14 +40,12 @@ import org.elasticsearch.action.support.IndicesOptions;
|
|||||||
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnit;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.mockito.junit.MockitoRule;
|
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
@ -63,18 +61,15 @@ import org.springframework.data.elasticsearch.core.query.StringQuery;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @currentRead Fool's Fate - Robin Hobb
|
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class ReactiveElasticsearchTemplateUnitTests {
|
public class ReactiveElasticsearchTemplateUnitTests {
|
||||||
|
|
||||||
@Rule //
|
|
||||||
public MockitoRule rule = MockitoJUnit.rule();
|
|
||||||
|
|
||||||
@Mock ReactiveElasticsearchClient client;
|
@Mock ReactiveElasticsearchClient client;
|
||||||
ReactiveElasticsearchTemplate template;
|
ReactiveElasticsearchTemplate template;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
|
||||||
template = new ReactiveElasticsearchTemplate(client);
|
template = new ReactiveElasticsearchTemplate(client);
|
||||||
|
@ -19,8 +19,7 @@ import static org.assertj.core.api.Assertions.*;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl;
|
import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl;
|
||||||
|
@ -30,11 +30,9 @@ import java.util.List;
|
|||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.search.aggregations.Aggregations;
|
import org.elasticsearch.search.aggregations.Aggregations;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
@ -46,9 +44,10 @@ import org.springframework.data.elasticsearch.core.ResultsExtractor;
|
|||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -57,8 +56,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
@ContextConfiguration(classes = { ElasticsearchTemplateConfiguration.class })
|
||||||
public class ElasticsearchTemplateAggregationTests {
|
public class ElasticsearchTemplateAggregationTests {
|
||||||
|
|
||||||
static final String RIZWAN_IDREES = "Rizwan Idrees";
|
static final String RIZWAN_IDREES = "Rizwan Idrees";
|
||||||
@ -72,7 +71,7 @@ public class ElasticsearchTemplateAggregationTests {
|
|||||||
|
|
||||||
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
|
|
||||||
IndexInitializer.init(elasticsearchTemplate, ArticleEntity.class);
|
IndexInitializer.init(elasticsearchTemplate, ArticleEntity.class);
|
||||||
@ -97,7 +96,7 @@ public class ElasticsearchTemplateAggregationTests {
|
|||||||
elasticsearchTemplate.refresh(ArticleEntity.class);
|
elasticsearchTemplate.refresh(ArticleEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void after() {
|
public void after() {
|
||||||
|
|
||||||
elasticsearchTemplate.deleteIndex(ArticleEntity.class);
|
elasticsearchTemplate.deleteIndex(ArticleEntity.class);
|
||||||
|
@ -26,17 +26,17 @@ import org.elasticsearch.search.suggest.SuggestBuilder;
|
|||||||
import org.elasticsearch.search.suggest.SuggestBuilders;
|
import org.elasticsearch.search.suggest.SuggestBuilders;
|
||||||
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
import org.elasticsearch.search.suggest.SuggestionBuilder;
|
||||||
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
|
import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.CompletionField;
|
import org.springframework.data.elasticsearch.annotations.CompletionField;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -46,8 +46,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
* @author Mewes Kochheim
|
* @author Mewes Kochheim
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
@ContextConfiguration(classes = { ElasticsearchTemplateConfiguration.class })
|
||||||
public class ElasticsearchTemplateCompletionTests {
|
public class ElasticsearchTemplateCompletionTests {
|
||||||
|
|
||||||
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
@ -33,8 +33,7 @@ import org.elasticsearch.search.suggest.completion.CompletionSuggestion;
|
|||||||
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
|
import org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder;
|
||||||
import org.elasticsearch.search.suggest.completion.context.CategoryQueryContext;
|
import org.elasticsearch.search.suggest.completion.context.CategoryQueryContext;
|
||||||
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.CompletionContext;
|
import org.springframework.data.elasticsearch.annotations.CompletionContext;
|
||||||
@ -42,16 +41,17 @@ import org.springframework.data.elasticsearch.annotations.CompletionField;
|
|||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Robert Gruendler
|
* @author Robert Gruendler
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
@ContextConfiguration(classes = { ElasticsearchTemplateConfiguration.class })
|
||||||
public class ElasticsearchTemplateCompletionWithContextsTests {
|
public class ElasticsearchTemplateCompletionWithContextsTests {
|
||||||
|
|
||||||
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
@ -24,10 +24,8 @@ import lombok.Data;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
@ -53,9 +51,10 @@ import org.springframework.data.elasticsearch.core.facet.result.TermResult;
|
|||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
||||||
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
import org.springframework.data.elasticsearch.core.query.SearchQuery;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
import org.springframework.data.elasticsearch.utils.IndexInitializer;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -64,8 +63,8 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
* @author Artur Konczak
|
* @author Artur Konczak
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
@ContextConfiguration(classes = { ElasticsearchTemplateConfiguration.class })
|
||||||
public class ElasticsearchTemplateFacetTests {
|
public class ElasticsearchTemplateFacetTests {
|
||||||
|
|
||||||
private static final String RIZWAN_IDREES = "Rizwan Idrees";
|
private static final String RIZWAN_IDREES = "Rizwan Idrees";
|
||||||
@ -79,7 +78,7 @@ public class ElasticsearchTemplateFacetTests {
|
|||||||
|
|
||||||
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
|
|
||||||
IndexInitializer.init(elasticsearchTemplate, ArticleEntity.class);
|
IndexInitializer.init(elasticsearchTemplate, ArticleEntity.class);
|
||||||
@ -342,56 +341,17 @@ public class ElasticsearchTemplateFacetTests {
|
|||||||
assertThat(facet.getMissing()).isEqualTo(0);
|
assertThat(facet.getMissing()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void shouldThrowExeptionsForMultiFieldFacet() {
|
public void shouldThrowExeptionsForMultiFieldFacet() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
String facetName = "fyears";
|
String facetName = "fyears";
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
assertThatThrownBy(() -> {
|
||||||
.withFacet(
|
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
||||||
new TermFacetRequestBuilder(facetName).fields("publishedYears", "authors.untouched").ascTerm().build())
|
.withFacet(
|
||||||
.build();
|
new TermFacetRequestBuilder(facetName).fields("publishedYears", "authors.untouched").ascTerm().build())
|
||||||
|
.build();
|
||||||
// when
|
}).isInstanceOf(IllegalArgumentException.class);
|
||||||
FacetedPage<ArticleEntity> result = elasticsearchTemplate.queryForPage(searchQuery, ArticleEntity.class);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result.getNumberOfElements()).isEqualTo(4);
|
|
||||||
|
|
||||||
TermResult facet = (TermResult) result.getFacet(facetName);
|
|
||||||
assertThat(facet.getTerms()).hasSize(7);
|
|
||||||
|
|
||||||
Term term = facet.getTerms().get(0);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2000));
|
|
||||||
assertThat(term.getCount()).isEqualTo(3);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(1);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2001));
|
|
||||||
assertThat(term.getCount()).isEqualTo(2);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(2);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2002));
|
|
||||||
assertThat(term.getCount()).isEqualTo(1);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(3);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(ARTUR_KONCZAK);
|
|
||||||
assertThat(term.getCount()).isEqualTo(3);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(4);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(JONATHAN_YAN);
|
|
||||||
assertThat(term.getCount()).isEqualTo(1);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(5);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(MOHSIN_HUSEN);
|
|
||||||
assertThat(term.getCount()).isEqualTo(2);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(6);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(RIZWAN_IDREES);
|
|
||||||
assertThat(term.getCount()).isEqualTo(4);
|
|
||||||
|
|
||||||
assertThat(facet.getTotal()).isEqualTo(16);
|
|
||||||
assertThat(facet.getOther()).isEqualTo(0);
|
|
||||||
assertThat(facet.getMissing()).isEqualTo(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -447,38 +407,15 @@ public class ElasticsearchTemplateFacetTests {
|
|||||||
assertThat(stringFacet.getMissing()).isEqualTo(0);
|
assertThat(stringFacet.getMissing()).isEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = UnsupportedOperationException.class)
|
@Test
|
||||||
public void shouldThrowExceptionForNativeFacets() {
|
public void shouldThrowExceptionForNativeFacets() {
|
||||||
|
|
||||||
// given
|
// given
|
||||||
String facetName = "fyears";
|
String facetName = "fyears";
|
||||||
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
assertThatThrownBy(() -> {
|
||||||
.withFacet(new NativeFacetRequest()).build();
|
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
||||||
|
.withFacet(new NativeFacetRequest()).build();
|
||||||
// when
|
}).isInstanceOf(UnsupportedOperationException.class);
|
||||||
FacetedPage<ArticleEntity> result = elasticsearchTemplate.queryForPage(searchQuery, ArticleEntity.class);
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(result.getNumberOfElements()).isEqualTo(4);
|
|
||||||
|
|
||||||
TermResult facet = (TermResult) result.getFacet(facetName);
|
|
||||||
assertThat(facet.getTerms()).hasSize(3);
|
|
||||||
|
|
||||||
Term term = facet.getTerms().get(0);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2000));
|
|
||||||
assertThat(term.getCount()).isEqualTo(3);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(1);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2001));
|
|
||||||
assertThat(term.getCount()).isEqualTo(2);
|
|
||||||
|
|
||||||
term = facet.getTerms().get(2);
|
|
||||||
assertThat(term.getTerm()).isEqualTo(Long.toString(YEAR_2002));
|
|
||||||
assertThat(term.getCount()).isEqualTo(1);
|
|
||||||
|
|
||||||
assertThat(facet.getTotal()).isEqualTo(6);
|
|
||||||
assertThat(facet.getOther()).isEqualTo(0);
|
|
||||||
assertThat(facet.getMissing()).isEqualTo(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -30,9 +30,8 @@ import java.lang.Long;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
@ -41,8 +40,9 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
|||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
import org.springframework.data.elasticsearch.annotations.Score;
|
import org.springframework.data.elasticsearch.annotations.Score;
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Rizwan Idrees
|
* @author Rizwan Idrees
|
||||||
@ -50,13 +50,13 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
* @author James Bodkin
|
* @author James Bodkin
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
@ContextConfiguration(classes = { ElasticsearchTemplateConfiguration.class })
|
||||||
public class CriteriaQueryTests {
|
public class CriteriaQueryTests {
|
||||||
|
|
||||||
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
@Autowired private ElasticsearchTemplate elasticsearchTemplate;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
|
|
||||||
elasticsearchTemplate.deleteIndex(SampleEntity.class);
|
elasticsearchTemplate.deleteIndex(SampleEntity.class);
|
||||||
|
@ -30,11 +30,11 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
@ -55,13 +55,13 @@ import org.springframework.data.repository.core.support.DefaultRepositoryMetadat
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class ElasticsearchStringQueryUnitTests {
|
public class ElasticsearchStringQueryUnitTests {
|
||||||
|
|
||||||
@Mock ElasticsearchOperations operations;
|
@Mock ElasticsearchOperations operations;
|
||||||
ElasticsearchConverter converter;
|
ElasticsearchConverter converter;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
|
converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,8 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@ -58,7 +58,7 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
|||||||
public static final String INDEX_NAME = "test-index-person-reactive-repository-query";
|
public static final String INDEX_NAME = "test-index-person-reactive-repository-query";
|
||||||
SimpleElasticsearchMappingContext mappingContext;
|
SimpleElasticsearchMappingContext mappingContext;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
mappingContext = new SimpleElasticsearchMappingContext();
|
mappingContext = new SimpleElasticsearchMappingContext();
|
||||||
}
|
}
|
||||||
@ -74,28 +74,32 @@ public class ReactiveElasticsearchQueryMethodUnitTests {
|
|||||||
assertThat(metadata.getIndexTypeName()).isEqualTo("user");
|
assertThat(metadata.getIndexTypeName()).isEqualTo("user");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class) // DATAES-519
|
@Test // DATAES-519
|
||||||
public void rejectsNullMappingContext() throws Exception {
|
public void rejectsNullMappingContext() throws Exception {
|
||||||
|
|
||||||
Method method = PersonRepository.class.getMethod("findByName", String.class);
|
Method method = PersonRepository.class.getMethod("findByName", String.class);
|
||||||
|
|
||||||
new ReactiveElasticsearchQueryMethod(method, new DefaultRepositoryMetadata(PersonRepository.class),
|
assertThatThrownBy(() -> new ReactiveElasticsearchQueryMethod(method,
|
||||||
new SpelAwareProxyProjectionFactory(), null);
|
new DefaultRepositoryMetadata(PersonRepository.class), new SpelAwareProxyProjectionFactory(), null))
|
||||||
|
.isInstanceOf(IllegalArgumentException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class) // DATAES-519
|
@Test // DATAES-519
|
||||||
public void rejectsMonoPageableResult() throws Exception {
|
public void rejectsMonoPageableResult() throws Exception {
|
||||||
queryMethod(PersonRepository.class, "findMonoByName", String.class, Pageable.class);
|
assertThatThrownBy(() -> queryMethod(PersonRepository.class, "findMonoByName", String.class, Pageable.class))
|
||||||
|
.isInstanceOf(IllegalStateException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidDataAccessApiUsageException.class) // DATAES-519
|
@Test // DATAES-519
|
||||||
public void throwsExceptionOnWrappedPage() throws Exception {
|
public void throwsExceptionOnWrappedPage() throws Exception {
|
||||||
queryMethod(PersonRepository.class, "findMonoPageByName", String.class, Pageable.class);
|
assertThatThrownBy(() -> queryMethod(PersonRepository.class, "findMonoPageByName", String.class, Pageable.class))
|
||||||
|
.isInstanceOf(InvalidDataAccessApiUsageException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = InvalidDataAccessApiUsageException.class) // DATAES-519
|
@Test // DATAES-519
|
||||||
public void throwsExceptionOnWrappedSlice() throws Exception {
|
public void throwsExceptionOnWrappedSlice() throws Exception {
|
||||||
queryMethod(PersonRepository.class, "findMonoSliceByName", String.class, Pageable.class);
|
assertThatThrownBy(() -> queryMethod(PersonRepository.class, "findMonoSliceByName", String.class, Pageable.class))
|
||||||
|
.isInstanceOf(InvalidDataAccessApiUsageException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-519
|
@Test // DATAES-519
|
||||||
|
@ -22,7 +22,6 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
@ -33,12 +32,12 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Ignore;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
@ -47,6 +46,7 @@ import org.springframework.data.elasticsearch.annotations.InnerField;
|
|||||||
import org.springframework.data.elasticsearch.annotations.MultiField;
|
import org.springframework.data.elasticsearch.annotations.MultiField;
|
||||||
import org.springframework.data.elasticsearch.annotations.Query;
|
import org.springframework.data.elasticsearch.annotations.Query;
|
||||||
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
||||||
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
|
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||||
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
import org.springframework.data.elasticsearch.core.query.StringQuery;
|
||||||
@ -60,7 +60,7 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
|
|||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class ReactiveElasticsearchStringQueryUnitTests {
|
public class ReactiveElasticsearchStringQueryUnitTests {
|
||||||
|
|
||||||
SpelExpressionParser PARSER = new SpelExpressionParser();
|
SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||||
@ -68,7 +68,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
|||||||
|
|
||||||
@Mock ReactiveElasticsearchOperations operations;
|
@Mock ReactiveElasticsearchOperations operations;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
|
converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ public class ReactiveElasticsearchStringQueryUnitTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-519
|
@Test // DATAES-519
|
||||||
@Ignore("TODO: fix spel query integration")
|
@Disabled("TODO: fix spel query integration")
|
||||||
public void bindsExpressionPropertyCorrectly() throws Exception {
|
public void bindsExpressionPropertyCorrectly() throws Exception {
|
||||||
|
|
||||||
ReactiveElasticsearchStringQuery elasticsearchStringQuery = createQueryForMethod("findByNameWithExpression",
|
ReactiveElasticsearchStringQuery elasticsearchStringQuery = createQueryForMethod("findByNameWithExpression",
|
||||||
|
@ -15,39 +15,50 @@
|
|||||||
*/
|
*/
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
package org.springframework.data.elasticsearch.repository.support;
|
||||||
|
|
||||||
import org.junit.Before;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
import java.util.HashSet;
|
||||||
import org.mockito.Mock;
|
import java.util.Set;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.data.mapping.context.MappingContext;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
|
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
||||||
|
import org.springframework.data.mapping.MappingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Florian Hopf
|
* @author Florian Hopf
|
||||||
* @author Mark Paluch
|
* @author Mark Paluch
|
||||||
*/
|
*/
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class ElasticsearchEntityInformationCreatorImplTests {
|
public class ElasticsearchEntityInformationCreatorImplTests {
|
||||||
|
|
||||||
@Mock MappingContext<? extends ElasticsearchPersistentEntity<?>, ElasticsearchPersistentProperty> mappingContext;
|
|
||||||
@Mock ElasticsearchPersistentEntity<String> persistentEntity;
|
|
||||||
|
|
||||||
ElasticsearchEntityInformationCreatorImpl entityInfoCreator;
|
ElasticsearchEntityInformationCreatorImpl entityInfoCreator;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
entityInfoCreator = new ElasticsearchEntityInformationCreatorImpl(mappingContext);
|
SimpleElasticsearchMappingContext context = new SimpleElasticsearchMappingContext();
|
||||||
|
Set<Class<?>> entites = new HashSet<>();
|
||||||
|
entites.add(EntityNoId.class);
|
||||||
|
context.setInitialEntitySet(entites);
|
||||||
|
entityInfoCreator = new ElasticsearchEntityInformationCreatorImpl(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void shouldThrowIllegalArgumentExceptionOnMissingEntity() {
|
public void shouldThrowMappingExceptionOnMissingEntity() {
|
||||||
entityInfoCreator.getEntityInformation(String.class);
|
assertThatThrownBy(() -> {
|
||||||
|
entityInfoCreator.getEntityInformation(String.class);
|
||||||
|
}).isInstanceOf(MappingException.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void shouldThrowIllegalArgumentExceptionOnMissingIdAnnotation() {
|
public void shouldThrowIllegalArgumentExceptionOnMissingIdAnnotation() {
|
||||||
entityInfoCreator.getEntityInformation(String.class);
|
assertThatThrownBy(() -> {
|
||||||
|
entityInfoCreator.getEntityInformation(EntityNoId.class);
|
||||||
|
}).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("No id property found");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Document(indexName = "whatever")
|
||||||
|
static class EntityNoId {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013-2019 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.elasticsearch.repository.support;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
|
||||||
import org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter;
|
|
||||||
import org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter;
|
|
||||||
import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext;
|
|
||||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
|
||||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
|
||||||
import org.springframework.data.repository.core.support.DefaultRepositoryMetadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rizwan Idrees
|
|
||||||
* @author Mohsin Husen
|
|
||||||
* @author Mark Paluch
|
|
||||||
* @author Peter-Josef Meisch
|
|
||||||
*/
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class ElasticsearchRepositoryFactoryTests {
|
|
||||||
|
|
||||||
@Mock private ElasticsearchOperations operations;
|
|
||||||
private ElasticsearchRepositoryFactory factory;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() {
|
|
||||||
ElasticsearchConverter converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
|
|
||||||
when(operations.getElasticsearchConverter()).thenReturn(converter);
|
|
||||||
factory = new ElasticsearchRepositoryFactory(operations);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
|
||||||
public void shouldThrowExceptionGivenQueryDslRepository() {
|
|
||||||
|
|
||||||
// given
|
|
||||||
RepositoryMetadata metadata = new DefaultRepositoryMetadata(QuerydslPredicateExecutor.class);
|
|
||||||
// when
|
|
||||||
factory.getRepositoryBaseClass(metadata);
|
|
||||||
}
|
|
||||||
}
|
|
@ -39,20 +39,18 @@ import org.elasticsearch.action.index.IndexRequest;
|
|||||||
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
import org.elasticsearch.action.support.WriteRequest.RefreshPolicy;
|
||||||
import org.elasticsearch.client.RequestOptions;
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.ClassRule;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
import org.springframework.data.annotation.Id;
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.annotation.Version;
|
import org.springframework.data.annotation.Version;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.domain.Sort.Order;
|
import org.springframework.data.domain.Sort.Order;
|
||||||
import org.springframework.data.elasticsearch.junit.junit4.TestNodeResource;
|
|
||||||
import org.springframework.data.elasticsearch.TestUtils;
|
import org.springframework.data.elasticsearch.TestUtils;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.annotations.Field;
|
import org.springframework.data.elasticsearch.annotations.Field;
|
||||||
@ -60,23 +58,23 @@ import org.springframework.data.elasticsearch.annotations.Query;
|
|||||||
import org.springframework.data.elasticsearch.annotations.Score;
|
import org.springframework.data.elasticsearch.annotations.Score;
|
||||||
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
|
import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient;
|
||||||
import org.springframework.data.elasticsearch.config.AbstractReactiveElasticsearchConfiguration;
|
import org.springframework.data.elasticsearch.config.AbstractReactiveElasticsearchConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration;
|
||||||
|
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
|
||||||
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
|
import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories;
|
||||||
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christoph Strobl
|
* @author Christoph Strobl
|
||||||
* @author Peter-Josef Meisch
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@SpringIntegrationTest
|
||||||
@ContextConfiguration
|
@ContextConfiguration(classes = { SimpleReactiveElasticsearchRepositoryTests.Config.class })
|
||||||
public class SimpleReactiveElasticsearchRepositoryTests {
|
public class SimpleReactiveElasticsearchRepositoryTests {
|
||||||
|
|
||||||
@ClassRule public static TestNodeResource testNodeResource = new TestNodeResource();
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
|
@Import({ ElasticsearchRestTemplateConfiguration.class })
|
||||||
@EnableReactiveElasticsearchRepositories(considerNestedRepositories = true)
|
@EnableReactiveElasticsearchRepositories(considerNestedRepositories = true)
|
||||||
static class Config extends AbstractReactiveElasticsearchConfiguration {
|
static class Config extends AbstractReactiveElasticsearchConfiguration {
|
||||||
|
|
||||||
@ -91,7 +89,7 @@ public class SimpleReactiveElasticsearchRepositoryTests {
|
|||||||
|
|
||||||
@Autowired ReactiveSampleEntityRepository repository;
|
@Autowired ReactiveSampleEntityRepository repository;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
TestUtils.deleteIndex(INDEX);
|
TestUtils.deleteIndex(INDEX);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user