DATAES-6 : Instead of storing data in "fs" it should store "in memory" for unit tests
This commit is contained in:
@@ -21,7 +21,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Document(indexName = "book",type = "book")
|
||||
@Document(indexName = "book",type = "book", indexStoreType = "memory")
|
||||
public class Book {
|
||||
|
||||
@Id
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
|
||||
|
||||
@Document(indexName = "double-keyed-entity", type = "double-keyed-entity")
|
||||
@Document(indexName = "double-keyed-entity", type = "double-keyed-entity", indexStoreType = "memory")
|
||||
public class DoubleIDEntity {
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
|
||||
|
||||
@Document(indexName = "integer-keyed-entity", type = "integer-keyed-entity")
|
||||
@Document(indexName = "integer-keyed-entity", type = "integer-keyed-entity", indexStoreType = "memory")
|
||||
public class IntegerIDEntity {
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Document(indexName = "test-index", type = "test-type")
|
||||
@Document(indexName = "test-index", type = "test-type", indexStoreType = "memory")
|
||||
public class SampleEntity {
|
||||
|
||||
@Id
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
@Document(indexName = "test-mapping", type = "mapping")
|
||||
@Document(indexName = "test-mapping", type = "mapping", indexStoreType = "memory")
|
||||
public class SampleMappingEntity {
|
||||
|
||||
@Id
|
||||
|
||||
@@ -25,17 +25,13 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.apache.commons.lang.RandomStringUtils.randomNumeric;
|
||||
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
/**
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
@@ -56,7 +52,6 @@ public class CriteriaQueryTests {
|
||||
elasticsearchTemplate.refresh(SampleEntity.class, true);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldPerformAndOperation(){
|
||||
//given
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.elasticsearch.repositories;
|
||||
|
||||
import org.springframework.data.elasticsearch.IntegerIDEntity;
|
||||
import org.springframework.data.elasticsearch.SampleEntity;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
public interface IntegerIDRepository extends ElasticsearchRepository<IntegerIDEntity,Integer> {
|
||||
|
||||
@@ -377,13 +377,13 @@ public class DoubleIDRepositoryTests {
|
||||
Double documentId = RandomUtils.nextDouble();
|
||||
DoubleIDEntity sampleEntity = new DoubleIDEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("A. hello world.");
|
||||
sampleEntity.setMessage("abc");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
Double documentId2 = RandomUtils.nextDouble();
|
||||
DoubleIDEntity sampleEntity2 = new DoubleIDEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("B.hello world.");
|
||||
sampleEntity2.setMessage("xyz");
|
||||
repository.save(sampleEntity2);
|
||||
//when
|
||||
Iterable<DoubleIDEntity> sampleEntities=repository.findAll(new Sort(new Sort.Order(Sort.Direction.ASC,"message")));
|
||||
|
||||
@@ -377,13 +377,13 @@ public class IntegerIDRepositoryTests {
|
||||
Integer documentId = RandomUtils.nextInt();
|
||||
IntegerIDEntity sampleEntity = new IntegerIDEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("A. hello world.");
|
||||
sampleEntity.setMessage("hello");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
Integer documentId2 = RandomUtils.nextInt();
|
||||
IntegerIDEntity sampleEntity2 = new IntegerIDEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("B.hello world.");
|
||||
sampleEntity2.setMessage("world");
|
||||
repository.save(sampleEntity2);
|
||||
//when
|
||||
Iterable<IntegerIDEntity> sampleEntities=repository.findAll(new Sort(new Sort.Order(Sort.Direction.ASC,"message")));
|
||||
|
||||
@@ -373,13 +373,13 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(documentId);
|
||||
sampleEntity.setMessage("A. hello world.");
|
||||
sampleEntity.setMessage("world");
|
||||
repository.save(sampleEntity);
|
||||
|
||||
String documentId2 = randomNumeric(5);
|
||||
SampleEntity sampleEntity2 = new SampleEntity();
|
||||
sampleEntity2.setId(documentId2);
|
||||
sampleEntity2.setMessage("B.hello world.");
|
||||
sampleEntity2.setMessage("hello");
|
||||
repository.save(sampleEntity2);
|
||||
//when
|
||||
Iterable<SampleEntity> sampleEntities=repository.findAll(new Sort(new Sort.Order(Sort.Direction.ASC,"message")));
|
||||
|
||||
Reference in New Issue
Block a user