mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-31 09:12:11 +00:00
parent
407c8c6c17
commit
bbf4c24195
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
@ -343,10 +343,10 @@ public class NestedObjectTests {
|
||||
Book book1 = new Book();
|
||||
Book book2 = new Book();
|
||||
|
||||
book1.setId(randomNumeric(5));
|
||||
book1.setId(nextIdAsString());
|
||||
book1.setName("testBook1");
|
||||
|
||||
book2.setId(randomNumeric(5));
|
||||
book2.setId(nextIdAsString());
|
||||
book2.setName("testBook2");
|
||||
|
||||
Map<Integer, Collection<String>> map1 = new HashMap<>();
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -67,7 +67,7 @@ public class ElasticsearchRestTemplateTests extends ElasticsearchTemplateTests {
|
||||
// when
|
||||
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
|
||||
.create();
|
||||
UpdateQuery updateQuery = UpdateQuery.builder(randomNumeric(5)).withDocument(document).build();
|
||||
UpdateQuery updateQuery = UpdateQuery.builder(nextIdAsString()).withDocument(document).build();
|
||||
assertThatThrownBy(() -> operations.update(updateQuery, index))
|
||||
.isInstanceOf(UncategorizedElasticsearchException.class);
|
||||
}
|
||||
|
@ -16,11 +16,11 @@
|
||||
package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static java.util.Collections.*;
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.core.document.Document.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -159,7 +159,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenCriteriaQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -181,7 +181,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -202,7 +202,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnObjectForGivenId() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
IndexQuery indexQuery = getIndexQuery(sampleEntity);
|
||||
@ -220,12 +220,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -249,12 +249,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -264,7 +264,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
indexOperations.refresh();
|
||||
|
||||
// when
|
||||
List<String> idsToSearch = Arrays.asList(documentId, randomNumeric(5), documentId2);
|
||||
List<String> idsToSearch = Arrays.asList(documentId, nextIdAsString(), documentId2);
|
||||
assertThat(idsToSearch).hasSize(3);
|
||||
|
||||
NativeSearchQuery query = new NativeSearchQueryBuilder().withIds(idsToSearch).build();
|
||||
@ -282,12 +282,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message").type("type1")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some message").type("type2")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -309,7 +309,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnSearchHitsForGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -333,7 +333,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnSearchHitsUsingLocalPreferenceForGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -357,7 +357,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldThrowExceptionWhenInvalidPreferenceForSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -378,7 +378,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldPassIndicesOptionsForGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -406,12 +406,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -432,7 +432,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDoBulkUpdate() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
String messageBeforeUpdate = "some test message";
|
||||
String messageAfterUpdate = "test message";
|
||||
|
||||
@ -466,7 +466,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDeleteDocumentForGivenId() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -489,7 +489,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDeleteEntityForGivenId() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -511,7 +511,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDeleteDocumentForGivenQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -540,12 +540,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
.version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
|
||||
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(nextIdAsString()).withObject(sampleEntity).build();
|
||||
|
||||
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME));
|
||||
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
|
||||
|
||||
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
|
||||
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(nextIdAsString()).withObject(sampleEntity).build();
|
||||
|
||||
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME));
|
||||
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
|
||||
@ -572,12 +572,12 @@ public abstract class ElasticsearchTemplateTests {
|
||||
.version(System.currentTimeMillis()) //
|
||||
.build();
|
||||
|
||||
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
|
||||
IndexQuery idxQuery1 = new IndexQueryBuilder().withId(nextIdAsString()).withObject(sampleEntity).build();
|
||||
|
||||
operations.index(idxQuery1, IndexCoordinates.of(INDEX_1_NAME));
|
||||
operations.indexOps(IndexCoordinates.of(INDEX_1_NAME)).refresh();
|
||||
|
||||
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(randomNumeric(5)).withObject(sampleEntity).build();
|
||||
IndexQuery idxQuery2 = new IndexQueryBuilder().withId(nextIdAsString()).withObject(sampleEntity).build();
|
||||
|
||||
operations.index(idxQuery2, IndexCoordinates.of(INDEX_2_NAME));
|
||||
operations.indexOps(IndexCoordinates.of(INDEX_2_NAME)).refresh();
|
||||
@ -600,7 +600,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldFilterSearchResultsForGivenFilter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -624,17 +624,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("xyz").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -660,17 +660,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("xyz").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -699,17 +699,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
List<IndexQuery> indexQueries;
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).rate(10).version(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
@ -737,17 +737,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
List<IndexQuery> indexQueries;
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).rate(10).version(System.currentTimeMillis())
|
||||
.build();
|
||||
|
||||
@ -798,7 +798,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldExecuteStringQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -820,7 +820,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldUseScriptedFields() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setRate(2);
|
||||
@ -852,7 +852,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnPageableResultsGivenStringQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -874,7 +874,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnSortedResultsGivenStringQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -901,7 +901,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnObjectMatchingGivenStringQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -936,7 +936,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldExecuteGivenCriteriaQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -957,7 +957,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDeleteGivenCriteriaQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -982,7 +982,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnSpecifiedFields() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
String message = "some test message";
|
||||
String type = "some type";
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message(message).type(type)
|
||||
@ -1011,7 +1011,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnFieldsBasedOnSourceFilter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
String message = "some test message";
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message(message)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
@ -1046,7 +1046,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
+ "we want our search server to be always available, we want to be able to start with one machine and scale to hundreds, "
|
||||
+ "we want real-time search, we want simple multi-tenancy, and we want a solution that is built for the cloud.";
|
||||
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId1).message(sampleMessage)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1054,7 +1054,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
operations.index(indexQuery, index);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
|
||||
operations.index(
|
||||
getIndexQuery(
|
||||
@ -1351,17 +1351,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("test test").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("some message").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1388,17 +1388,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("test test").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("some message").rate(15)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1463,7 +1463,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDoPartialUpdateForExistingDocument() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
String messageBeforeUpdate = "some test message";
|
||||
String messageAfterUpdate = "test message";
|
||||
|
||||
@ -1541,7 +1541,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDoUpsertIfDocumentDoesNotExist() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
|
||||
.create();
|
||||
document.put("message", "test message");
|
||||
@ -1563,7 +1563,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
long scrollTimeInMillis = 3000;
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1662,7 +1662,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldDeleteDocumentBySpecifiedTypeUsingDeleteQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1901,7 +1901,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldIndexGteEntityWithVersionType() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
GTEVersionEntity entity = GTEVersionEntity.builder().id(documentId).name("FooBar")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1931,7 +1931,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldIndexSampleEntityWithIndexAndTypeAtRuntime() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1954,7 +1954,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenCriteriaQueryWithGivenIndexUsingCriteriaQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1974,7 +1974,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenSearchQueryWithGivenIndexUsingSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -1994,7 +1994,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenCriteriaQueryWithGivenIndexAndTypeUsingCriteriaQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2014,7 +2014,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnCountForGivenSearchQueryWithGivenIndexAndTypeUsingSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2035,13 +2035,13 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
cleanUpIndices();
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId1).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2066,13 +2066,13 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
cleanUpIndices();
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId1).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2136,13 +2136,13 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
cleanUpIndices();
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId1).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2167,13 +2167,13 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
cleanUpIndices();
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId1).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2197,7 +2197,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldThrowAnExceptionForGivenCriteriaQueryWhenNoIndexSpecifiedForCountQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2215,7 +2215,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldThrowAnExceptionForGivenSearchQueryWhenNoIndexSpecifiedForCountQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(documentId).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2302,13 +2302,13 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldTestResultsAcrossMultipleIndices() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId1).message("some message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(sampleEntity1.getId()).withObject(sampleEntity1).build();
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("some test message")
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2336,8 +2336,8 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldComposeObjectsReturnedFromHeterogeneousIndexes() {
|
||||
|
||||
// given
|
||||
HetroEntity1 entity1 = new HetroEntity1(randomNumeric(3), "aFirstName");
|
||||
HetroEntity2 entity2 = new HetroEntity2(randomNumeric(4), "aLastName");
|
||||
HetroEntity1 entity1 = new HetroEntity1(nextIdAsString(), "aFirstName");
|
||||
HetroEntity2 entity2 = new HetroEntity2(nextIdAsString(), "aLastName");
|
||||
|
||||
IndexQuery indexQuery1 = new IndexQueryBuilder().withId(entity1.getId()).withObject(entity1).build();
|
||||
IndexQuery indexQuery2 = new IndexQueryBuilder().withId(entity2.getId()).withObject(entity2).build();
|
||||
@ -2588,17 +2588,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("xyz").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2635,17 +2635,17 @@ public abstract class ElasticsearchTemplateTests {
|
||||
|
||||
// given
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("abc").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(documentId2).message("xyz").rate(5)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
// third document
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(documentId3).message("xyz").rate(10)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
@ -2682,11 +2682,11 @@ public abstract class ElasticsearchTemplateTests {
|
||||
public void shouldReturnDocumentWithCollapsedField() {
|
||||
|
||||
// given
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(randomNumeric(5)).message("message 1").rate(1)
|
||||
SampleEntity sampleEntity = SampleEntity.builder().id(nextIdAsString()).message("message 1").rate(1)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(randomNumeric(5)).message("message 2").rate(2)
|
||||
SampleEntity sampleEntity2 = SampleEntity.builder().id(nextIdAsString()).message("message 2").rate(2)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(randomNumeric(5)).message("message 1").rate(1)
|
||||
SampleEntity sampleEntity3 = SampleEntity.builder().id(nextIdAsString()).message("message 1").rate(1)
|
||||
.version(System.currentTimeMillis()).build();
|
||||
|
||||
List<IndexQuery> indexQueries = getIndexQueries(Arrays.asList(sampleEntity, sampleEntity2, sampleEntity3));
|
||||
@ -2761,7 +2761,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
indexOperations.addAlias(aliasQuery1);
|
||||
indexOperations.addAlias(aliasQuery2);
|
||||
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity entity = SampleEntity.builder() //
|
||||
.id(documentId) //
|
||||
.message("some message") //
|
||||
@ -2809,7 +2809,7 @@ public abstract class ElasticsearchTemplateTests {
|
||||
// when
|
||||
indexOperations.addAlias(aliasQuery);
|
||||
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = SampleEntity.builder() //
|
||||
.id(documentId) //
|
||||
.message("some message") //
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.val;
|
||||
@ -65,7 +65,7 @@ public class ElasticsearchTransportTemplateTests extends ElasticsearchTemplateTe
|
||||
// when
|
||||
org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document
|
||||
.create();
|
||||
UpdateQuery updateQuery = UpdateQuery.builder(randomNumeric(5)).withDocument(document).build();
|
||||
UpdateQuery updateQuery = UpdateQuery.builder(nextIdAsString()).withDocument(document).build();
|
||||
assertThatThrownBy(() -> operations.update(updateQuery, index)).isInstanceOf(DocumentMissingException.class);
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.query;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IndexBuilder.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -87,7 +87,7 @@ public class CriteriaQueryTests {
|
||||
public void shouldPerformAndOperation() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some test message");
|
||||
@ -116,7 +116,7 @@ public class CriteriaQueryTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("some message");
|
||||
@ -128,7 +128,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message");
|
||||
@ -159,7 +159,7 @@ public class CriteriaQueryTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -190,7 +190,7 @@ public class CriteriaQueryTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -219,7 +219,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -249,7 +249,7 @@ public class CriteriaQueryTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("some message");
|
||||
@ -261,7 +261,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message");
|
||||
@ -291,7 +291,7 @@ public class CriteriaQueryTests {
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("some message");
|
||||
@ -303,7 +303,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message end");
|
||||
@ -333,7 +333,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("start some message");
|
||||
@ -345,7 +345,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message");
|
||||
@ -375,7 +375,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("contains some message");
|
||||
@ -387,7 +387,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message");
|
||||
@ -416,7 +416,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("elasticsearch search");
|
||||
@ -428,7 +428,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test message");
|
||||
@ -457,7 +457,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("some message search");
|
||||
@ -469,7 +469,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("test test message");
|
||||
@ -499,7 +499,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("bar");
|
||||
@ -511,7 +511,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("foo");
|
||||
@ -541,7 +541,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(100);
|
||||
@ -554,7 +554,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(200);
|
||||
@ -583,7 +583,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(300);
|
||||
@ -596,7 +596,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(400);
|
||||
@ -626,7 +626,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(500);
|
||||
@ -639,7 +639,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(600);
|
||||
@ -669,7 +669,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(700);
|
||||
@ -682,7 +682,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(800);
|
||||
@ -712,7 +712,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(900);
|
||||
@ -725,7 +725,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(1000);
|
||||
@ -755,7 +755,7 @@ public class CriteriaQueryTests {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setRate(700);
|
||||
@ -768,7 +768,7 @@ public class CriteriaQueryTests {
|
||||
indexQueries.add(indexQuery1);
|
||||
|
||||
// second document
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setRate(800);
|
||||
@ -819,7 +819,7 @@ public class CriteriaQueryTests {
|
||||
public void shouldEscapeValue() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("Hello World!");
|
||||
|
@ -15,9 +15,9 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repositories.custommethod;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -100,7 +100,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethod() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -119,7 +119,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForNot() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("some");
|
||||
@ -137,7 +137,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -157,7 +157,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithLessThan() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -165,7 +165,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
sampleEntity.setMessage("some message");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -185,7 +185,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithBefore() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -205,7 +205,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithAfter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -225,7 +225,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithLike() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -245,7 +245,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForStartingWith() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -265,7 +265,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForEndingWith() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -285,7 +285,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForContains() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -305,7 +305,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForIn() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -313,7 +313,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -334,7 +334,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForNotIn() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -342,7 +342,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -363,13 +363,13 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldHandleManyValuesQueryingIn() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(32);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setKeyword("foo");
|
||||
repository.save(sampleEntity1);
|
||||
|
||||
String documentId2 = randomNumeric(32);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setKeyword("bar");
|
||||
@ -379,7 +379,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
keywords.add("foo");
|
||||
|
||||
for (int i = 0; i < 1025; i++) {
|
||||
keywords.add(randomNumeric(32));
|
||||
keywords.add(nextIdAsString());
|
||||
}
|
||||
|
||||
// when
|
||||
@ -394,13 +394,13 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldHandleManyValuesQueryingNotIn() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(32);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setKeyword("foo");
|
||||
repository.save(sampleEntity1);
|
||||
|
||||
String documentId2 = randomNumeric(32);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setKeyword("bar");
|
||||
@ -410,7 +410,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
keywords.add("foo");
|
||||
|
||||
for (int i = 0; i < 1025; i++) {
|
||||
keywords.add(randomNumeric(32));
|
||||
keywords.add(nextIdAsString());
|
||||
}
|
||||
|
||||
// when
|
||||
@ -425,7 +425,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForTrue() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -434,7 +434,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -453,7 +453,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForFalse() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -462,7 +462,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -482,7 +482,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodForOrderBy() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("abc");
|
||||
@ -491,7 +491,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// document 2
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("xyz");
|
||||
@ -500,7 +500,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity2);
|
||||
|
||||
// document 3
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId3);
|
||||
sampleEntity3.setType("def");
|
||||
@ -520,7 +520,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithBooleanParameter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -529,7 +529,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -549,7 +549,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldReturnPageableInUnwrappedPageResult() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -558,7 +558,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -601,21 +601,21 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldReturnPageableResultsWithGivenSortingOrder() {
|
||||
|
||||
// given
|
||||
String documentId = random(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("abc");
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("abd");
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity2);
|
||||
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId3);
|
||||
sampleEntity3.setMessage("abe");
|
||||
@ -635,21 +635,21 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldReturnListForMessage() {
|
||||
|
||||
// given
|
||||
String documentId = random(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("abc");
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("abd");
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity2);
|
||||
|
||||
String documentId3 = randomNumeric(5);
|
||||
String documentId3 = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId3);
|
||||
sampleEntity3.setMessage("abe");
|
||||
@ -667,7 +667,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithGeoPoint() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -689,7 +689,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithGeoPointAndString() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -699,7 +699,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -722,7 +722,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithWithinGeoPoint() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -745,7 +745,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithWithinPoint() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -768,7 +768,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithNearBox() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -778,7 +778,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test2");
|
||||
@ -808,7 +808,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldExecuteCustomMethodWithNearPointAndDistance() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -846,7 +846,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethod() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -854,7 +854,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test2");
|
||||
@ -873,7 +873,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForNot() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("some");
|
||||
@ -881,7 +881,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -900,7 +900,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithBooleanParameter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -909,7 +909,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -928,7 +928,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithLessThan() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -936,7 +936,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
sampleEntity.setMessage("some message");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -955,7 +955,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithBefore() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -964,7 +964,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -984,7 +984,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithAfter() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -993,7 +993,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1013,7 +1013,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithLike() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1022,7 +1022,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1042,7 +1042,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForStartingWith() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1051,7 +1051,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1071,7 +1071,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForEndingWith() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1080,7 +1080,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1100,7 +1100,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForContains() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1109,7 +1109,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1129,7 +1129,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForIn() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1137,7 +1137,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1157,7 +1157,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForNotIn() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1165,7 +1165,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1185,7 +1185,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForTrue() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1194,7 +1194,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1212,7 +1212,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodForFalse() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1221,7 +1221,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
repository.save(sampleEntity);
|
||||
|
||||
// given
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1240,7 +1240,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithWithinGeoPoint() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1250,7 +1250,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1271,7 +1271,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithWithinPoint() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1281,7 +1281,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
@ -1302,7 +1302,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithNearBox() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1312,7 +1312,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test2");
|
||||
@ -1333,7 +1333,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
public void shouldCountCustomMethodWithNearPointAndDistance() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setType("test");
|
||||
@ -1343,7 +1343,7 @@ public abstract class CustomMethodRepositoryBaseTests {
|
||||
|
||||
repository.save(sampleEntity);
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("test");
|
||||
|
@ -16,11 +16,11 @@
|
||||
package org.springframework.data.elasticsearch.repositories.doubleid;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -75,13 +75,13 @@ public class DoubleIDRepositoryTests {
|
||||
public void shouldDoBulkIndexDocument() {
|
||||
|
||||
// given
|
||||
Double documentId1 = RandomUtils.nextDouble();
|
||||
Double documentId1 = nextIdAsDouble();
|
||||
DoubleIDEntity sampleEntity1 = new DoubleIDEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setMessage("some message");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
Double documentId2 = RandomUtils.nextDouble();
|
||||
Double documentId2 = nextIdAsDouble();
|
||||
DoubleIDEntity sampleEntity2 = new DoubleIDEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("some message");
|
||||
@ -102,7 +102,7 @@ public class DoubleIDRepositoryTests {
|
||||
public void shouldSaveDocument() {
|
||||
|
||||
// given
|
||||
Double documentId = RandomUtils.nextDouble();
|
||||
Double documentId = nextIdAsDouble();
|
||||
DoubleIDEntity sampleEntity = new DoubleIDEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
|
@ -16,11 +16,11 @@
|
||||
package org.springframework.data.elasticsearch.repositories.integer;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -76,13 +76,13 @@ public class IntegerIDRepositoryTests {
|
||||
public void shouldDoBulkIndexDocument() {
|
||||
|
||||
// given
|
||||
Integer documentId1 = RandomUtils.nextInt();
|
||||
Integer documentId1 = nextIdAsInt();
|
||||
IntegerIDEntity sampleEntity1 = new IntegerIDEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setMessage("some message");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
Integer documentId2 = RandomUtils.nextInt();
|
||||
Integer documentId2 = nextIdAsInt();
|
||||
IntegerIDEntity sampleEntity2 = new IntegerIDEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("some message");
|
||||
@ -103,7 +103,7 @@ public class IntegerIDRepositoryTests {
|
||||
public void shouldSaveDocument() {
|
||||
|
||||
// given
|
||||
Integer documentId = RandomUtils.nextInt();
|
||||
Integer documentId = nextIdAsInt();
|
||||
IntegerIDEntity sampleEntity = new IntegerIDEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.data.elasticsearch.repositories.nestedobject;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -85,7 +85,7 @@ public class InnerObjectTests {
|
||||
public void shouldIndexInnerObject() {
|
||||
|
||||
// given
|
||||
String id = randomAlphanumeric(5);
|
||||
String id = nextIdAsString();
|
||||
Book book = new Book();
|
||||
book.setId(id);
|
||||
book.setName("xyz");
|
||||
|
@ -17,10 +17,10 @@ package org.springframework.data.elasticsearch.repositories.setting.dynamic;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.core.document.Document.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -99,14 +99,14 @@ public class DynamicSettingAndMappingEntityRepositoryTests {
|
||||
|
||||
// given
|
||||
DynamicSettingAndMappingEntity dynamicSettingAndMappingEntity1 = new DynamicSettingAndMappingEntity();
|
||||
dynamicSettingAndMappingEntity1.setId(RandomStringUtils.randomNumeric(5));
|
||||
dynamicSettingAndMappingEntity1.setId(nextIdAsString());
|
||||
dynamicSettingAndMappingEntity1.setName("test-setting1");
|
||||
dynamicSettingAndMappingEntity1.setEmail("test_setting1@Test.com");
|
||||
|
||||
repository.save(dynamicSettingAndMappingEntity1);
|
||||
|
||||
DynamicSettingAndMappingEntity dynamicSettingAndMappingEntity2 = new DynamicSettingAndMappingEntity();
|
||||
dynamicSettingAndMappingEntity2.setId(RandomStringUtils.randomNumeric(5));
|
||||
dynamicSettingAndMappingEntity2.setId(nextIdAsString());
|
||||
dynamicSettingAndMappingEntity2.setName("test-setting2");
|
||||
dynamicSettingAndMappingEntity2.setEmail("test_setting2@Test.com");
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repository.support.simple;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
import static org.springframework.data.elasticsearch.utils.IdGenerator.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -101,13 +101,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDoBulkIndexDocument() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setMessage("some message");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("some message");
|
||||
@ -128,7 +128,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldSaveDocument() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -158,7 +158,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldFindDocumentById() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -177,7 +177,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldReturnCountOfDocuments() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -205,7 +205,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteDocument() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some message");
|
||||
@ -224,7 +224,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldSearchDocumentsGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("some test message");
|
||||
@ -245,7 +245,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldSearchDocumentsGivenElasticsearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -264,14 +264,14 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldFindAllByIdQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello world.");
|
||||
@ -289,13 +289,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldSaveIterableEntities() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("hello world.");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello world.");
|
||||
@ -315,7 +315,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldReturnTrueGivenDocumentWithIdExists() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -333,7 +333,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldReturnFalseGivenDocumentWithIdDoesNotExist() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
|
||||
// when
|
||||
boolean exist = repository.existsById(documentId);
|
||||
@ -346,7 +346,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldReturnResultsForGivenSearchQuery() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -365,7 +365,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteAll() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -385,7 +385,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteById() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -406,21 +406,21 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteByMessageAndReturnList() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("hello world 1");
|
||||
sampleEntity1.setAvailable(true);
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setMessage("hello world 2");
|
||||
sampleEntity2.setAvailable(true);
|
||||
sampleEntity2.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId);
|
||||
sampleEntity3.setMessage("hello world 3");
|
||||
@ -442,19 +442,19 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteByListForMessage() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("hello world 1");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setMessage("hello world 2");
|
||||
sampleEntity2.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId);
|
||||
sampleEntity3.setMessage("hello world 3");
|
||||
@ -475,19 +475,19 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteByType() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setType("book");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId);
|
||||
sampleEntity2.setType("article");
|
||||
sampleEntity2.setVersion(System.currentTimeMillis());
|
||||
|
||||
documentId = randomNumeric(5);
|
||||
documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity3 = new SampleEntity();
|
||||
sampleEntity3.setId(documentId);
|
||||
sampleEntity3.setType("image");
|
||||
@ -507,7 +507,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteEntity() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("hello world.");
|
||||
@ -527,14 +527,14 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldReturnIterableEntities() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setMessage("hello world.");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
repository.save(sampleEntity1);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello world.");
|
||||
@ -552,13 +552,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldDeleteIterableEntities() {
|
||||
|
||||
// given
|
||||
String documentId1 = randomNumeric(5);
|
||||
String documentId1 = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId1);
|
||||
sampleEntity1.setMessage("hello world.");
|
||||
sampleEntity1.setVersion(System.currentTimeMillis());
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello world.");
|
||||
@ -579,7 +579,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldIndexEntity() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
@ -597,7 +597,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldIndexWithoutRefreshEntity() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setVersion(System.currentTimeMillis());
|
||||
@ -620,13 +620,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldSortByGivenField() {
|
||||
|
||||
// given
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("world");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello");
|
||||
@ -664,13 +664,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
public void shouldIndexNotEmptyList() {
|
||||
// given
|
||||
List<SampleEntity> list = new ArrayList<>();
|
||||
String documentId = randomNumeric(5);
|
||||
String documentId = nextIdAsString();
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setId(documentId);
|
||||
sampleEntity1.setMessage("world");
|
||||
list.add(sampleEntity1);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
String documentId2 = nextIdAsString();
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("hello");
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2020 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.utils;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Class to provide sequential IDs. Uses an integer, 2^31 -1 values should be enough for the test runs.
|
||||
*
|
||||
* @author Peter-Josef Meisch
|
||||
*/
|
||||
public final class IdGenerator {
|
||||
|
||||
private static final AtomicInteger NEXT = new AtomicInteger();
|
||||
|
||||
private IdGenerator() {}
|
||||
|
||||
public static int nextIdAsInt() {
|
||||
return NEXT.incrementAndGet();
|
||||
}
|
||||
|
||||
public static double nextIdAsDouble() {
|
||||
return NEXT.incrementAndGet();
|
||||
}
|
||||
public static String nextIdAsString() {
|
||||
return "" + nextIdAsInt();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user