mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-21 19:42:10 +00:00
findAllById returns all requested documents.
Original Pull Request #2421 Closes #2417 (cherry picked from commit 28489ffee8f405d8f5d2000bb40161d61b21485d) (cherry picked from commit 6551a80ccc503b20c09eae2ebc3ac33dafcb3c34)
This commit is contained in:
parent
b896694d3a
commit
87540bcabc
@ -202,29 +202,27 @@ abstract class ElasticsearchRepositoryIntegrationTests {
|
|||||||
assertThat(entityFromElasticSearch).isNotPresent();
|
assertThat(entityFromElasticSearch).isNotPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // DATAES-82
|
@Test // DATAES-82, #2417
|
||||||
void shouldFindAllByIdQuery() {
|
void shouldFindAllByIdQuery() {
|
||||||
|
|
||||||
// given
|
// create more than 10 documents to see that the number of input ids is set as requested size
|
||||||
String documentId = nextIdAsString();
|
int numEntities = 20;
|
||||||
SampleEntity sampleEntity = new SampleEntity();
|
List<String> ids = new ArrayList<>(numEntities);
|
||||||
sampleEntity.setId(documentId);
|
List<SampleEntity> entities = new ArrayList<>(numEntities);
|
||||||
sampleEntity.setMessage("hello world.");
|
for (int i = 0; i < numEntities; i++) {
|
||||||
sampleEntity.setVersion(System.currentTimeMillis());
|
String documentId = nextIdAsString();
|
||||||
repository.save(sampleEntity);
|
ids.add(documentId);
|
||||||
|
SampleEntity sampleEntity = new SampleEntity();
|
||||||
|
sampleEntity.setId(documentId);
|
||||||
|
sampleEntity.setMessage("hello world.");
|
||||||
|
sampleEntity.setVersion(System.currentTimeMillis());
|
||||||
|
entities.add(sampleEntity);
|
||||||
|
}
|
||||||
|
repository.saveAll(entities);
|
||||||
|
|
||||||
String documentId2 = nextIdAsString();
|
Iterable<SampleEntity> sampleEntities = repository.findAllById(ids);
|
||||||
SampleEntity sampleEntity2 = new SampleEntity();
|
|
||||||
sampleEntity2.setId(documentId2);
|
|
||||||
sampleEntity2.setMessage("hello world.");
|
|
||||||
sampleEntity2.setVersion(System.currentTimeMillis());
|
|
||||||
repository.save(sampleEntity2);
|
|
||||||
|
|
||||||
// when
|
assertThat(sampleEntities).isNotNull().hasSize(numEntities);
|
||||||
Iterable<SampleEntity> sampleEntities = repository.findAllById(Arrays.asList(documentId, documentId2));
|
|
||||||
|
|
||||||
// then
|
|
||||||
assertThat(sampleEntities).isNotNull().hasSize(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -17,11 +17,13 @@ package org.springframework.data.elasticsearch.repository.support;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.springframework.data.elasticsearch.core.query.Query.*;
|
import static org.springframework.data.elasticsearch.core.query.Query.*;
|
||||||
|
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||||
|
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -63,13 +65,10 @@ import org.springframework.lang.Nullable;
|
|||||||
@SpringIntegrationTest
|
@SpringIntegrationTest
|
||||||
abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
||||||
|
|
||||||
@Autowired
|
@Autowired ReactiveElasticsearchOperations operations;
|
||||||
ReactiveElasticsearchOperations operations;
|
@Autowired ReactiveSampleEntityRepository repository;
|
||||||
@Autowired
|
|
||||||
ReactiveSampleEntityRepository repository;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired private IndexNameProvider indexNameProvider;
|
||||||
private IndexNameProvider indexNameProvider;
|
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void before() {
|
void before() {
|
||||||
@ -84,7 +83,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void saveShouldSaveSingleEntity() {
|
void saveShouldSaveSingleEntity() {
|
||||||
|
|
||||||
repository.save(new SampleEntity()) //
|
repository.save(new SampleEntity()) //
|
||||||
@ -99,7 +98,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void saveShouldComputeMultipleEntities() {
|
void saveShouldComputeMultipleEntities() {
|
||||||
|
|
||||||
repository.saveAll(Arrays.asList(new SampleEntity(), new SampleEntity(), new SampleEntity()))
|
repository.saveAll(Arrays.asList(new SampleEntity(), new SampleEntity(), new SampleEntity()))
|
||||||
@ -113,7 +112,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519, DATAES-767, DATAES-822
|
// DATAES-519, DATAES-767, DATAES-822
|
||||||
void findByIdShouldErrorIfIndexDoesNotExist() {
|
void findByIdShouldErrorIfIndexDoesNotExist() {
|
||||||
|
|
||||||
operations.indexOps(SampleEntity.class).delete().block();
|
operations.indexOps(SampleEntity.class).delete().block();
|
||||||
@ -124,13 +123,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void findShouldRetrieveSingleEntityById() {
|
void findShouldRetrieveSingleEntityById() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two"), //
|
new SampleEntity("id-two"), //
|
||||||
new SampleEntity("id-three")) //
|
new SampleEntity("id-three")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findById("id-two").as(StepVerifier::create)//
|
repository.findById("id-two").as(StepVerifier::create)//
|
||||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-two")) //
|
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-two")) //
|
||||||
@ -138,27 +137,27 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void findByIdShouldCompleteIfNothingFound() {
|
void findByIdShouldCompleteIfNothingFound() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two"), //
|
new SampleEntity("id-two"), //
|
||||||
new SampleEntity("id-three")) //
|
new SampleEntity("id-three")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findById("does-not-exist").as(StepVerifier::create) //
|
repository.findById("does-not-exist").as(StepVerifier::create) //
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-720
|
// DATAES-720
|
||||||
void findAllShouldReturnAllElements() {
|
void findAllShouldReturnAllElements() {
|
||||||
// make sure to be above the default page size of the Query interface
|
// make sure to be above the default page size of the Query interface
|
||||||
int count = DEFAULT_PAGE_SIZE * 2;
|
int count = DEFAULT_PAGE_SIZE * 2;
|
||||||
bulkIndex(IntStream.range(1, count + 1) //
|
bulkIndex(IntStream.range(1, count + 1) //
|
||||||
.mapToObj(it -> new SampleEntity(String.valueOf(it))) //
|
.mapToObj(it -> new SampleEntity(String.valueOf(it))) //
|
||||||
.toArray(SampleEntity[]::new)) //
|
.toArray(SampleEntity[]::new)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAll() //
|
repository.findAll() //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -167,35 +166,43 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void findAllByIdByIdShouldCompleteIfIndexDoesNotExist() {
|
void findAllByIdByIdShouldCompleteIfIndexDoesNotExist() {
|
||||||
repository.findAllById(Arrays.asList("id-two", "id-two")).as(StepVerifier::create).verifyComplete();
|
repository.findAllById(Arrays.asList("id-two", "id-two")).as(StepVerifier::create).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test // DATAES-519, #2417
|
||||||
// DATAES-519
|
|
||||||
void findAllByIdShouldRetrieveMatchingDocuments() {
|
void findAllByIdShouldRetrieveMatchingDocuments() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
// create more than 10 documents to see that the number of input ids is set as requested size
|
||||||
new SampleEntity("id-two"), //
|
int numEntities = 20;
|
||||||
new SampleEntity("id-three")) //
|
List<String> ids = new ArrayList<>(numEntities);
|
||||||
.block();
|
List<SampleEntity> entities = new ArrayList<>(numEntities);
|
||||||
|
for (int i = 0; i < numEntities; i++) {
|
||||||
|
String documentId = nextIdAsString();
|
||||||
|
ids.add(documentId);
|
||||||
|
SampleEntity sampleEntity = new SampleEntity();
|
||||||
|
sampleEntity.setId(documentId);
|
||||||
|
sampleEntity.setMessage("hello world.");
|
||||||
|
sampleEntity.setVersion(System.currentTimeMillis());
|
||||||
|
entities.add(sampleEntity);
|
||||||
|
}
|
||||||
|
repository.saveAll(entities).blockLast();
|
||||||
|
|
||||||
repository.findAllById(Arrays.asList("id-one", "id-two")) //
|
repository.findAllById(ids) //
|
||||||
.as(StepVerifier::create)//
|
.as(StepVerifier::create)//
|
||||||
.expectNextMatches(entity -> entity.getId().equals("id-one") || entity.getId().equals("id-two")) //
|
.expectNextCount(numEntities) //
|
||||||
.expectNextMatches(entity -> entity.getId().equals("id-one") || entity.getId().equals("id-two")) //
|
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void findAllByIdShouldCompleteWhenNothingFound() {
|
void findAllByIdShouldCompleteWhenNothingFound() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two"), //
|
new SampleEntity("id-two"), //
|
||||||
new SampleEntity("id-three")) //
|
new SampleEntity("id-three")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllById(Arrays.asList("can't", "touch", "this")) //
|
repository.findAllById(Arrays.asList("can't", "touch", "this")) //
|
||||||
.as(StepVerifier::create)//
|
.as(StepVerifier::create)//
|
||||||
@ -203,13 +210,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-717
|
// DATAES-717
|
||||||
void shouldReturnFluxOfSearchHit() {
|
void shouldReturnFluxOfSearchHit() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "message"), //
|
new SampleEntity("id-two", "message"), //
|
||||||
new SampleEntity("id-three", "message")) //
|
new SampleEntity("id-three", "message")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.queryAllByMessage("message") //
|
repository.queryAllByMessage("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -219,13 +226,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-717
|
// DATAES-717
|
||||||
void shouldReturnFluxOfSearchHitForStringQuery() {
|
void shouldReturnFluxOfSearchHitForStringQuery() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "message"), //
|
new SampleEntity("id-two", "message"), //
|
||||||
new SampleEntity("id-three", "message")) //
|
new SampleEntity("id-three", "message")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.queryByMessageWithString("message") //
|
repository.queryByMessageWithString("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -235,13 +242,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-372
|
// DATAES-372
|
||||||
void shouldReturnHighlightsOnAnnotatedMethod() {
|
void shouldReturnHighlightsOnAnnotatedMethod() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "message"), //
|
new SampleEntity("id-two", "message"), //
|
||||||
new SampleEntity("id-three", "message")) //
|
new SampleEntity("id-three", "message")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.queryAllByMessage("message") //
|
repository.queryAllByMessage("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -254,13 +261,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-372
|
// DATAES-372
|
||||||
void shouldReturnHighlightsOnAnnotatedStringQueryMethod() {
|
void shouldReturnHighlightsOnAnnotatedStringQueryMethod() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "message"), //
|
new SampleEntity("id-two", "message"), //
|
||||||
new SampleEntity("id-three", "message")) //
|
new SampleEntity("id-three", "message")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.queryByMessageWithString("message") //
|
repository.queryByMessageWithString("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -273,7 +280,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519, DATAES-767, DATAES-822
|
// DATAES-519, DATAES-767, DATAES-822
|
||||||
void countShouldErrorWhenIndexDoesNotExist() {
|
void countShouldErrorWhenIndexDoesNotExist() {
|
||||||
|
|
||||||
operations.indexOps(SampleEntity.class).delete().block();
|
operations.indexOps(SampleEntity.class).delete().block();
|
||||||
@ -284,24 +291,24 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void countShouldCountDocuments() {
|
void countShouldCountDocuments() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two")) //
|
new SampleEntity("id-two")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.count().as(StepVerifier::create).expectNext(2L).verifyComplete();
|
repository.count().as(StepVerifier::create).expectNext(2L).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void existsByIdShouldReturnTrueIfExists() {
|
void existsByIdShouldReturnTrueIfExists() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.existsById("id-two") //
|
repository.existsById("id-two") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -310,13 +317,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void existsByIdShouldReturnFalseIfNotExists() {
|
void existsByIdShouldReturnFalseIfNotExists() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.existsById("wrecking ball") //
|
repository.existsById("wrecking ball") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -325,7 +332,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void countShouldCountMatchingDocuments() {
|
void countShouldCountMatchingDocuments() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
@ -353,13 +360,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void existsShouldReturnTrueIfExists() {
|
void existsShouldReturnTrueIfExists() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.existsAllByMessage("message") //
|
repository.existsAllByMessage("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -368,13 +375,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void existsShouldReturnFalseIfNotExists() {
|
void existsShouldReturnFalseIfNotExists() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.existsAllByMessage("these days") //
|
repository.existsAllByMessage("these days") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -383,18 +390,18 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void deleteByIdShouldCompleteIfNothingDeleted() {
|
void deleteByIdShouldCompleteIfNothingDeleted() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two")) //
|
new SampleEntity("id-two")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.deleteById("does-not-exist").as(StepVerifier::create).verifyComplete();
|
repository.deleteById("does-not-exist").as(StepVerifier::create).verifyComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519, DATAES-767, DATAES-822, DATAES-678
|
// DATAES-519, DATAES-767, DATAES-822, DATAES-678
|
||||||
void deleteByIdShouldCompleteWhenIndexDoesNotExist() {
|
void deleteByIdShouldCompleteWhenIndexDoesNotExist() {
|
||||||
repository.deleteById("does-not-exist") //
|
repository.deleteById("does-not-exist") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -402,7 +409,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void deleteByIdShouldDeleteEntry() {
|
void deleteByIdShouldDeleteEntry() {
|
||||||
|
|
||||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||||
@ -415,21 +422,20 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-976
|
// DATAES-976
|
||||||
void deleteAllByIdShouldDeleteEntry() {
|
void deleteAllByIdShouldDeleteEntry() {
|
||||||
|
|
||||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||||
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
bulkIndex(new SampleEntity("id-one"), toBeDeleted) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create)
|
repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create).verifyComplete();
|
||||||
.verifyComplete();
|
|
||||||
|
|
||||||
assertThat(documentWithIdExistsInIndex(toBeDeleted.getId()).block()).isFalse();
|
assertThat(documentWithIdExistsInIndex(toBeDeleted.getId()).block()).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void deleteShouldDeleteEntry() {
|
void deleteShouldDeleteEntry() {
|
||||||
|
|
||||||
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
SampleEntity toBeDeleted = new SampleEntity("id-two");
|
||||||
@ -442,7 +448,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void deleteAllShouldDeleteGivenEntries() {
|
void deleteAllShouldDeleteGivenEntries() {
|
||||||
|
|
||||||
SampleEntity toBeDeleted = new SampleEntity("id-one");
|
SampleEntity toBeDeleted = new SampleEntity("id-one");
|
||||||
@ -460,13 +466,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void deleteAllShouldDeleteAllEntries() {
|
void deleteAllShouldDeleteAllEntries() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one"), //
|
bulkIndex(new SampleEntity("id-one"), //
|
||||||
new SampleEntity("id-two"), //
|
new SampleEntity("id-two"), //
|
||||||
new SampleEntity("id-three")) //
|
new SampleEntity("id-three")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
repository.deleteAll().as(StepVerifier::create).verifyComplete();
|
||||||
|
|
||||||
@ -477,13 +483,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderMethodShouldBeExecutedCorrectly() {
|
void derivedFinderMethodShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllByMessageLike("test") //
|
repository.findAllByMessageLike("test") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -492,13 +498,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() {
|
void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllByMessage(Mono.just("test")) //
|
repository.findAllByMessage(Mono.just("test")) //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -507,13 +513,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() {
|
void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||||
new SampleEntity("id-two", "test test", 1), //
|
new SampleEntity("id-two", "test test", 1), //
|
||||||
new SampleEntity("id-three", "test test", 2)) //
|
new SampleEntity("id-three", "test test", 2)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllByMessageLikeOrderByRate("test") //
|
repository.findAllByMessageLikeOrderByRate("test") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -524,13 +530,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() {
|
void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||||
new SampleEntity("id-two", "test test", 1), //
|
new SampleEntity("id-two", "test test", 1), //
|
||||||
new SampleEntity("id-three", "test test", 2)) //
|
new SampleEntity("id-three", "test test", 2)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllByMessage("test", Sort.by(Order.asc("rate"))) //
|
repository.findAllByMessage("test", Sort.by(Order.asc("rate"))) //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -541,13 +547,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() {
|
void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||||
new SampleEntity("id-two", "test test", 1), //
|
new SampleEntity("id-two", "test test", 1), //
|
||||||
new SampleEntity("id-three", "test test", 2)) //
|
new SampleEntity("id-three", "test test", 2)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllByMessage("test", PageRequest.of(0, 2, Sort.by(Order.asc("rate")))) //
|
repository.findAllByMessage("test", PageRequest.of(0, 2, Sort.by(Order.asc("rate")))) //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -557,13 +563,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() {
|
void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findFirstByMessageLike("test") //
|
repository.findFirstByMessageLike("test") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -572,7 +578,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void annotatedFinderMethodShouldBeExecutedCorrectly() {
|
void annotatedFinderMethodShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
int count = 30;
|
int count = 30;
|
||||||
@ -589,7 +595,7 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// #1917
|
// #1917
|
||||||
void annotatedFinderMethodPagedShouldBeExecutedCorrectly() {
|
void annotatedFinderMethodPagedShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
int count = 30;
|
int count = 30;
|
||||||
@ -610,13 +616,13 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// DATAES-519
|
// DATAES-519
|
||||||
void derivedDeleteMethodShouldBeExecutedCorrectly() {
|
void derivedDeleteMethodShouldBeExecutedCorrectly() {
|
||||||
|
|
||||||
bulkIndex(new SampleEntity("id-one", "message"), //
|
bulkIndex(new SampleEntity("id-one", "message"), //
|
||||||
new SampleEntity("id-two", "test message"), //
|
new SampleEntity("id-two", "test message"), //
|
||||||
new SampleEntity("id-three", "test test")) //
|
new SampleEntity("id-three", "test test")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.deleteAllByMessage("message") //
|
repository.deleteAllByMessage("message") //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -629,12 +635,12 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// #2135
|
// #2135
|
||||||
void FluxOfSearchHitForArrayQuery() {
|
void FluxOfSearchHitForArrayQuery() {
|
||||||
bulkIndex(new SampleEntity("id-one", "message1"), //
|
bulkIndex(new SampleEntity("id-one", "message1"), //
|
||||||
new SampleEntity("id-two", "message2"), //
|
new SampleEntity("id-two", "message2"), //
|
||||||
new SampleEntity("id-three", "message3")) //
|
new SampleEntity("id-three", "message3")) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllViaAnnotatedQueryByMessageIn(Arrays.asList("message1", "message3")) //
|
repository.findAllViaAnnotatedQueryByMessageIn(Arrays.asList("message1", "message3")) //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -645,12 +651,12 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// #2135
|
// #2135
|
||||||
void FluxOfSearchHitForIntegerArrayQuery() {
|
void FluxOfSearchHitForIntegerArrayQuery() {
|
||||||
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
bulkIndex(new SampleEntity("id-one", "test", 3), //
|
||||||
new SampleEntity("id-two", "test test", 1), //
|
new SampleEntity("id-two", "test test", 1), //
|
||||||
new SampleEntity("id-three", "test test", 2)) //
|
new SampleEntity("id-three", "test test", 2)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllViaAnnotatedQueryByRatesIn(Arrays.asList(2, 3)) //
|
repository.findAllViaAnnotatedQueryByRatesIn(Arrays.asList(2, 3)) //
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
@ -661,17 +667,16 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// #2135
|
// #2135
|
||||||
void FluxOfSearchHitForStringAndIntegerArrayQuery() {
|
void FluxOfSearchHitForStringAndIntegerArrayQuery() {
|
||||||
bulkIndex(new SampleEntity("id-one", "message1", 1), //
|
bulkIndex(new SampleEntity("id-one", "message1", 1), //
|
||||||
new SampleEntity("id-two", "message2", 2), //
|
new SampleEntity("id-two", "message2", 2), //
|
||||||
new SampleEntity("id-three", "message3", 3), //
|
new SampleEntity("id-three", "message3", 3), //
|
||||||
new SampleEntity("id-four", "message4", 4), //
|
new SampleEntity("id-four", "message4", 4), //
|
||||||
new SampleEntity("id-five", "message5", 5)) //
|
new SampleEntity("id-five", "message5", 5)) //
|
||||||
.block();
|
.block();
|
||||||
|
|
||||||
repository.findAllViaAnnotatedQueryByMessageInAndRatesIn(Arrays.asList("message5", "message3"), Arrays.asList(2,
|
repository.findAllViaAnnotatedQueryByMessageInAndRatesIn(Arrays.asList("message5", "message3"), Arrays.asList(2, 3)) //
|
||||||
3)) //
|
|
||||||
.as(StepVerifier::create) //
|
.as(StepVerifier::create) //
|
||||||
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-three")) //
|
.consumeNextWith(it -> assertThat(it.getId()).isEqualTo("id-three")) //
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
@ -694,11 +699,11 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
|
|
||||||
Flux<SampleEntity> findAllByMessage(Publisher<String> message);
|
Flux<SampleEntity> findAllByMessage(Publisher<String> message);
|
||||||
|
|
||||||
@Highlight(fields = {@HighlightField(name = "message")})
|
@Highlight(fields = { @HighlightField(name = "message") })
|
||||||
Flux<SearchHit<SampleEntity>> queryAllByMessage(String message);
|
Flux<SearchHit<SampleEntity>> queryAllByMessage(String message);
|
||||||
|
|
||||||
@Query("{\"bool\": {\"must\": [{\"term\": {\"message\": \"?0\"}}]}}")
|
@Query("{\"bool\": {\"must\": [{\"term\": {\"message\": \"?0\"}}]}}")
|
||||||
@Highlight(fields = {@HighlightField(name = "message")})
|
@Highlight(fields = { @HighlightField(name = "message") })
|
||||||
Flux<SearchHit<SampleEntity>> queryByMessageWithString(String message);
|
Flux<SearchHit<SampleEntity>> queryByMessageWithString(String message);
|
||||||
|
|
||||||
@Query("{ \"bool\" : { \"must\" : { \"term\" : { \"message\" : \"?0\" } } } }")
|
@Query("{ \"bool\" : { \"must\" : { \"term\" : { \"message\" : \"?0\" } } } }")
|
||||||
@ -732,24 +737,17 @@ abstract class SimpleReactiveElasticsearchRepositoryIntegrationTests {
|
|||||||
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
@Document(indexName = "#{@indexNameProvider.indexName()}")
|
||||||
static class SampleEntity {
|
static class SampleEntity {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Id
|
@Id private String id;
|
||||||
private String id;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Field(type = FieldType.Text, store = true, fielddata = true)
|
@Field(type = FieldType.Text, store = true, fielddata = true) private String type;
|
||||||
private String type;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Field(type = FieldType.Text, store = true, fielddata = true)
|
@Field(type = FieldType.Text, store = true, fielddata = true) private String message;
|
||||||
private String message;
|
@Nullable private int rate;
|
||||||
|
@Nullable private boolean available;
|
||||||
@Nullable
|
@Nullable
|
||||||
private int rate;
|
@Version private Long version;
|
||||||
@Nullable
|
|
||||||
private boolean available;
|
|
||||||
@Nullable
|
|
||||||
@Version
|
|
||||||
private Long version;
|
|
||||||
|
|
||||||
public SampleEntity() {
|
public SampleEntity() {}
|
||||||
}
|
|
||||||
|
|
||||||
public SampleEntity(@Nullable String id) {
|
public SampleEntity(@Nullable String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user