DATAES-143 added support for turning off auto index creation based on Document annotation.
This commit is contained in:
committed by
Artur Konczak
parent
485f0e7252
commit
751302d6f0
@@ -48,6 +48,7 @@ import org.springframework.data.elasticsearch.ElasticsearchException;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
import org.springframework.data.elasticsearch.core.query.*;
|
||||
import org.springframework.data.elasticsearch.entities.*;
|
||||
import org.springframework.data.elasticsearch.repositories.existing.index.CreateIndexFalseEntity;
|
||||
import org.springframework.data.util.CloseableIterator;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
@@ -58,6 +59,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Franck Marchand
|
||||
* @author Abdul Mohammed
|
||||
* @author Kevin Leturc
|
||||
* @author Mason Chan
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.springframework.data.elasticsearch.repositories.existing.index;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.elasticsearch.annotations.Document;
|
||||
|
||||
/**
|
||||
* CreateIndexFalseEntity
|
||||
*
|
||||
* @author Mason Chan
|
||||
*/
|
||||
|
||||
@Document(indexName = "test-index", type = "test-type", createIndex = false)
|
||||
public class CreateIndexFalseEntity {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.springframework.data.elasticsearch.repositories.existing.index;
|
||||
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
|
||||
/**
|
||||
* Created by akonczak on 16/12/2015.
|
||||
*/
|
||||
public interface CreateIndexFalseRepository extends ElasticsearchRepository<CreateIndexFalseEntity, String> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package org.springframework.data.elasticsearch.repositories.existing.index;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:/existing-index-repository-test.xml")
|
||||
public class CreateIndexFalseRepositoryTest {
|
||||
|
||||
@Autowired
|
||||
private CreateIndexFalseRepository repository;
|
||||
|
||||
@Autowired
|
||||
private ElasticsearchTemplate elasticsearchTemplate;
|
||||
|
||||
|
||||
/*
|
||||
DATAES-143
|
||||
*/
|
||||
@Test
|
||||
public void shouldNotCreateIndex() {
|
||||
//given
|
||||
|
||||
//when
|
||||
//then
|
||||
assertFalse(elasticsearchTemplate.indexExists(CreateIndexFalseEntity.class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user