DATAES-211 - updated to ES-2.2, test fixes round 1

This commit is contained in:
Artur Konczak
2016-02-10 13:40:14 +00:00
committed by Mohsin Husen
parent a853ca359a
commit 8963123ffe
70 changed files with 701 additions and 496 deletions

View File

@@ -26,7 +26,7 @@ import org.springframework.data.elasticsearch.annotations.ScriptedField;
* @author Rizwan Idrees
* @author Mohsin Husen
*/
@Document(indexName = "test-index", type = "test-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-index", type = "test-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleEntity {
@Id

View File

@@ -15,12 +15,12 @@
*/
package org.springframework.data.elasticsearch;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import static org.elasticsearch.node.NodeBuilder.*;
import java.util.UUID;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.common.settings.Settings;
/**
* @author Mohsin Husen
@@ -28,13 +28,11 @@ import org.elasticsearch.common.settings.ImmutableSettings;
public class Utils {
public static NodeClient getNodeClient() {
ImmutableSettings.Builder settings = ImmutableSettings.settingsBuilder()
return (NodeClient) nodeBuilder().settings(Settings.builder()
.put("http.enabled", "false")
.put("path.data", "target/elasticsearchTestData");
return (NodeClient) nodeBuilder().settings(settings).clusterName(UUID.randomUUID().toString()).local(true).node()
.put("path.data", "target/elasticsearchTestData")
.put("path.home", "test-home-dir"))
.clusterName(UUID.randomUUID().toString()).local(true).node()
.client();
}
}

View File

@@ -52,7 +52,7 @@ public class AliasTests {
settings.put("index.refresh_interval", "-1");
settings.put("index.number_of_replicas", "0");
settings.put("index.number_of_shards", "2");
settings.put("index.store.type", "memory");
settings.put("index.store.type", "fs");
elasticsearchTemplate.deleteIndex(INDEX_NAME);
elasticsearchTemplate.createIndex(INDEX_NAME, settings);

View File

@@ -50,7 +50,6 @@ public class ElasticsearchTemplateParentChildTests {
clean();
elasticsearchTemplate.createIndex(ParentEntity.class);
elasticsearchTemplate.createIndex(ChildEntity.class);
elasticsearchTemplate.putMapping(ParentEntity.class);
elasticsearchTemplate.putMapping(ChildEntity.class);
}
@@ -82,28 +81,6 @@ public class ElasticsearchTemplateParentChildTests {
assertThat("parents", parents, contains(hasProperty("id", is(parent1.getId()))));
}
@Test
public void shouldSearchTopChildrenForGivenParent() {
// index two parents
ParentEntity parent1 = index("parent1", "First Parent");
ParentEntity parent2 = index("parent2", "Second Parent");
// index a child for each parent
String child1name = "First";
index("child1", parent1.getId(), child1name);
index("child2", parent2.getId(), "Second");
elasticsearchTemplate.refresh(ParentEntity.class, true);
elasticsearchTemplate.refresh(ChildEntity.class, true);
// find all parents that have the first child using topChildren Query
QueryBuilder query = topChildrenQuery(ParentEntity.CHILD_TYPE, QueryBuilders.termQuery("name", child1name.toLowerCase()));
List<ParentEntity> parents = elasticsearchTemplate.queryForList(new NativeSearchQuery(query), ParentEntity.class);
// we're expecting only the first parent as result
assertThat("parents", parents, contains(hasProperty("id", is(parent1.getId()))));
}
private ParentEntity index(String parentId, String name) {
ParentEntity parent = new ParentEntity(parentId, name);
IndexQuery index = new IndexQuery();

View File

@@ -16,7 +16,6 @@
package org.springframework.data.elasticsearch.core;
import static org.apache.commons.lang.RandomStringUtils.*;
import static org.elasticsearch.index.query.FilterBuilders.*;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
@@ -30,6 +29,8 @@ import org.elasticsearch.action.get.MultiGetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.engine.DocumentMissingException;
import org.elasticsearch.script.Script;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.highlight.HighlightBuilder;
import org.elasticsearch.search.sort.FieldSortBuilder;
@@ -48,7 +49,6 @@ 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;
@@ -360,7 +360,7 @@ public class ElasticsearchTemplateTests {
elasticsearchTemplate.refresh(SampleEntity.class, true);
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
.withFilter(boolFilter().must(termFilter("id", documentId))).build();
.withFilter(boolQuery().filter(termQuery("id", documentId))).build();
// when
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class);
// then
@@ -466,35 +466,35 @@ public class ElasticsearchTemplateTests {
assertThat(sampleEntities.getTotalElements(), equalTo(1L));
}
@Test
public void shouldUseScriptedFields() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setRate(2);
sampleEntity.setMessage("some message");
sampleEntity.setVersion(System.currentTimeMillis());
@Test
public void shouldUseScriptedFields() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = new SampleEntity();
sampleEntity.setId(documentId);
sampleEntity.setRate(2);
sampleEntity.setMessage("some message");
sampleEntity.setVersion(System.currentTimeMillis());
IndexQuery indexQuery = new IndexQuery();
indexQuery.setId(documentId);
indexQuery.setObject(sampleEntity);
IndexQuery indexQuery = new IndexQuery();
indexQuery.setId(documentId);
indexQuery.setObject(sampleEntity);
elasticsearchTemplate.index(indexQuery);
elasticsearchTemplate.refresh(SampleEntity.class, true);
elasticsearchTemplate.index(indexQuery);
elasticsearchTemplate.refresh(SampleEntity.class, true);
Map<String, Object> params = new HashMap<String, Object>();
params.put("factor", 2);
// when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.withScriptField(new ScriptField("scriptedRate", "doc['rate'].value * factor", params))
.build();
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class);
// then
assertThat(sampleEntities.getTotalElements(), equalTo(1L));
assertThat(sampleEntities.getContent().get(0).getScriptedRate(), equalTo(4L));
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("factor", 2);
// when
SearchQuery searchQuery = new NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.withScriptField(new ScriptField("scriptedRate", new Script("doc['rate'].value * factor", ScriptService.ScriptType.INLINE, "groovy", params)))
.build();
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class);
// then
assertThat(sampleEntities.getTotalElements(), equalTo(1L));
assertThat(sampleEntities.getContent().get(0).getScriptedRate(), equalTo(4L));
}
@Test
public void shouldReturnPageableResultsGivenStringQuery() {
@@ -1229,27 +1229,6 @@ public class ElasticsearchTemplateTests {
assertThat(sampleEntities.getContent().get(0).getHighlightedMessage(), is(highlightedMessage));
}
@Test
public void shouldDeleteSpecifiedTypeFromAnIndex() {
// given
String documentId = randomNumeric(5);
SampleEntity sampleEntity = SampleEntity.builder().id(documentId)
.message("some message")
.version(System.currentTimeMillis()).build();
IndexQuery indexQuery = getIndexQuery(sampleEntity);
elasticsearchTemplate.index(indexQuery);
elasticsearchTemplate.refresh(SampleEntity.class, true);
// when
elasticsearchTemplate.deleteType(INDEX_NAME, TYPE_NAME);
elasticsearchTemplate.refresh(SampleEntity.class, true);
//then
boolean typeExists = elasticsearchTemplate.typeExists(INDEX_NAME, TYPE_NAME);
assertThat(typeExists, is(false));
}
@Test
public void shouldDeleteDocumentBySpecifiedTypeUsingDeleteQuery() {
// given
@@ -1882,7 +1861,7 @@ public class ElasticsearchTemplateTests {
assertThat((String) map.get("index.refresh_interval"), is("-1"));
assertThat((String) map.get("index.number_of_replicas"), is("0"));
assertThat((String) map.get("index.number_of_shards"), is("1"));
assertThat((String) map.get("index.store.type"), is("memory"));
assertThat((String) map.get("index.store.type"), is("fs"));
}
/*

View File

@@ -7,7 +7,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
/**
* @author Mewes Kochheim
*/
@Document(indexName = "test-completion-index", type = "annotated-completion-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-completion-index", type = "annotated-completion-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class AnnotatedCompletionEntity {
@Id

View File

@@ -9,7 +9,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
* @author Mohsin Husen
* @author Mewes Kochheim
*/
@Document(indexName = "test-completion-index", type = "completion-annotation-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-completion-index", type = "completion-annotation-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class CompletionAnnotatedEntity {
@Id

View File

@@ -6,7 +6,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
/**
* @author Mewes Kochheim
*/
@Document(indexName = "test-completion-index", type = "completion-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-completion-index", type = "completion-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class CompletionEntity {
@Id

View File

@@ -34,7 +34,7 @@ import org.springframework.data.elasticsearch.annotations.NestedField;
* @author Artur Konczak
* @author Mohsin Husen
*/
@Document(indexName = "articles", type = "article", shards = 1, replicas = 0, refreshInterval = "-1", indexStoreType = "memory")
@Document(indexName = "articles", type = "article", shards = 1, replicas = 0, refreshInterval = "-1")
public class ArticleEntity {
@Id

View File

@@ -12,7 +12,8 @@
* 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.core.facet;
import static org.elasticsearch.index.query.QueryBuilders.*;
@@ -35,12 +36,14 @@ import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
/**
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Jonathan Yan
* @author Artur Konczak
*/
*//*
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
public class ElasticsearchTemplateFacetTests {
@@ -632,3 +635,4 @@ public class ElasticsearchTemplateFacetTests {
assertThat(unit.getCount(), is(1L));
}
}
*/

View File

@@ -12,7 +12,8 @@
* 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.core.facet;
import static org.elasticsearch.index.query.QueryBuilders.*;
@@ -38,12 +39,14 @@ import org.springframework.data.elasticsearch.core.query.SearchQuery;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
/**
* @author Rizwan Idrees
* @author Mohsin Husen
* @author Jonathan Yan
* @author Artur Konczak
*/
*//*
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:elasticsearch-template-test.xml")
public class ElasticsearchTemplateHistogramFacetTests {
@@ -137,3 +140,4 @@ public class ElasticsearchTemplateHistogramFacetTests {
assertThat(unit.getCount(), is(1L));
}
}
*/

View File

@@ -32,7 +32,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
* @author Mohsin Husen
*/
@Document(indexName = "test-log-index", type = "test-log-type", shards = 1, replicas = 0, refreshInterval = "-1", indexStoreType = "memory")
@Document(indexName = "test-log-index", type = "test-log-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class LogEntity {
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");

View File

@@ -22,7 +22,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
* @author Franck Marchand
* @author Mohsin Husen
*/
@Document(indexName = "test-geo-index", type = "geo-class-point-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-geo-index", type = "geo-class-point-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class AuthorMarkerEntity {
@Id

View File

@@ -22,8 +22,8 @@ import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import org.elasticsearch.common.geo.GeoHashUtils;
import org.elasticsearch.index.query.FilterBuilders;
import com.spatial4j.core.io.GeohashUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -192,7 +192,7 @@ public class ElasticsearchTemplateGeoTests {
public void shouldFindAllMarkersForNativeSearchQuery() {
//Given
loadAnnotationBaseEntities();
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoBoundingBoxFilter("locationAsArray").topLeft(52, -1).bottomRight(50, 1));
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoBoundingBoxQuery("locationAsArray").topLeft(52, -1).bottomRight(50, 1));
//When
List<LocationMarkerEntity> geoAuthorsForGeoCriteria = elasticsearchTemplate.queryForList(queryBuilder.build(), LocationMarkerEntity.class);
//Then
@@ -222,7 +222,7 @@ public class ElasticsearchTemplateGeoTests {
//given
loadClassBaseEntities();
CriteriaQuery geoLocationCriteriaQuery3 = new CriteriaQuery(
new Criteria("location").boundedBy(GeoHashUtils.encode(53.5171d, 0), GeoHashUtils.encode(49.5171d, 0.2062d)));
new Criteria("location").boundedBy(GeohashUtils.encodeLatLon(53.5171d, 0), GeohashUtils.encodeLatLon(49.5171d, 0.2062d)));
//when
List<AuthorMarkerEntity> geoAuthorsForGeoCriteria3 = elasticsearchTemplate.queryForList(geoLocationCriteriaQuery3, AuthorMarkerEntity.class);
@@ -273,13 +273,13 @@ public class ElasticsearchTemplateGeoTests {
//u1044k2bd6u - with precision = 5 -> u, u1, u10, u104, u1044
loadAnnotationBaseEntities();
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision3 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(3));
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision4 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(4));
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision5 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(5));
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision3 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(3));
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision4 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(4));
NativeSearchQueryBuilder locationWithPrefixAsDistancePrecision5 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsDistance").geohash("u1044k2bd6u").precision(5));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision4 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(4));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision5 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(5));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision6 = new NativeSearchQueryBuilder().withFilter(FilterBuilders.geoHashCellFilter("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(6));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision4 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(4));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision5 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(5));
NativeSearchQueryBuilder locationWithPrefixAsLengthOfGeoHashPrecision6 = new NativeSearchQueryBuilder().withFilter(QueryBuilders.geoHashCellQuery("box-one").field("locationWithPrefixAsLengthOfGeoHash").geohash("u1044k2bd6u").precision(6));
//when
List<LocationMarkerEntity> resultDistancePrecision3 = elasticsearchTemplate.queryForList(locationWithPrefixAsDistancePrecision3.build(), LocationMarkerEntity.class);
List<LocationMarkerEntity> resultDistancePrecision4 = elasticsearchTemplate.queryForList(locationWithPrefixAsDistancePrecision4.build(), LocationMarkerEntity.class);

View File

@@ -28,7 +28,7 @@ import org.springframework.data.elasticsearch.annotations.GeoPointField;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "test-geo-index", type = "geo-annotation-point-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-geo-index", type = "geo-annotation-point-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class LocationMarkerEntity {
@Id

View File

@@ -34,7 +34,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "book", type = "book", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "book", type = "book", shards = 1, replicas = 0, refreshInterval = "-1")
public class Book {
@Id

View File

@@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
* @author Mohsin Husen
*/
@Document(indexName = "double-keyed-entity", type = "double-keyed-entity", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "double-keyed-entity", type = "double-keyed-entity", shards = 1, replicas = 0, refreshInterval = "-1")
public class DoubleIDEntity {
@Id

View File

@@ -19,7 +19,7 @@ import org.springframework.data.geo.Polygon;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "geo-test-index", type = "geo-test-index", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "geo-test-index", type = "geo-test-index", shards = 1, replicas = 0, refreshInterval = "-1")
public class GeoEntity {
@Id

View File

@@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
* @author Mohsin Husen
*/
@Document(indexName = "integer-keyed-entity", type = "integer-keyed-entity", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "integer-keyed-entity", type = "integer-keyed-entity", shards = 1, replicas = 0, refreshInterval = "-1")
public class IntegerIDEntity {
@Id

View File

@@ -25,7 +25,7 @@ import org.springframework.data.elasticsearch.annotations.*;
* @author Philipp Jardas
* @author Mohsin Husen
*/
@Document(indexName = ParentEntity.INDEX, type = ParentEntity.PARENT_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = ParentEntity.INDEX, type = ParentEntity.PARENT_TYPE, shards = 1, replicas = 0, refreshInterval = "-1")
public class ParentEntity {
public static final String INDEX = "parent-child";
@@ -58,7 +58,7 @@ public class ParentEntity {
return new ToStringCreator(this).append("id", id).append("name", name).toString();
}
@Document(indexName = INDEX, type = CHILD_TYPE, indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = INDEX, type = CHILD_TYPE, shards = 1, replicas = 0, refreshInterval = "-1")
public static class ChildEntity {
@Id

View File

@@ -29,7 +29,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
* @author Artur Konczak
*/
@Document(indexName = "person", type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "person", type = "user", shards = 1, replicas = 0, refreshInterval = "-1")
public class Person {
@Id

View File

@@ -29,7 +29,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
* @author Artur Konczak
*/
@Document(indexName = "person-multiple-level-nested", type = "user", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "person-multiple-level-nested", type = "user", shards = 1, replicas = 0, refreshInterval = "-1")
public class PersonMultipleLevelNested {
@Id

View File

@@ -33,7 +33,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "test-product-index", type = "test-product-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-product-index", type = "test-product-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class Product {
@Id

View File

@@ -14,7 +14,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
/**
* @author Jakub Vavrik
*/
@Document(indexName = "test-datemapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-datemapping", type = "mapping", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleDateMappingEntity {
@Id

View File

@@ -32,7 +32,7 @@ import org.springframework.data.elasticsearch.core.geo.GeoPoint;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "test-index", type = "test-type", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-index", type = "test-type", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleEntity {
@Id

View File

@@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
/**
* @author Kevin Leturc
*/
@Document(indexName = "test-inherited-mapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-inherited-mapping", type = "mapping", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleInheritedEntity extends AbstractInheritedEntity {
@Field(type = String, index = not_analyzed, store = true, searchAnalyzer = "standard", indexAnalyzer = "standard")

View File

@@ -26,7 +26,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
* @author Rizwan Idrees
* @author Mohsin Husen
*/
@Document(indexName = "test-mapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-mapping", type = "mapping", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleMappingEntity {
@Id

View File

@@ -26,7 +26,7 @@ import org.springframework.data.elasticsearch.annotations.Field;
/**
* @author Jakub Vavrik
*/
@Document(indexName = "test-recursive-mapping", type = "mapping", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "test-recursive-mapping", type = "mapping", shards = 1, replicas = 0, refreshInterval = "-1")
public class SampleTransientEntity {
@Id

View File

@@ -24,7 +24,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
* @author Stuart Stevenson
* @author Mohsin Husen
*/
@Document(indexName = "circular-objects", type = "circular-object", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "circular-objects", type = "circular-object", shards = 1, replicas = 0, refreshInterval = "-1")
public class SimpleRecursiveEntity {
@Id

View File

@@ -23,7 +23,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
*
* @author Artur Konczak
*/
@Document(indexName = "#{'abz'+'-'+'entity'}", type = "#{'my'+'Type'}", indexStoreType = "memory", shards = 1,
@Document(indexName = "#{'abz'+'-'+'entity'}", type = "#{'my'+'Type'}", shards = 1,
replicas = 0, refreshInterval = "-1")
public class SpELEntity {

View File

@@ -32,7 +32,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "stock", type = "price", indexStoreType = "memory", shards = 1, replicas = 0, refreshInterval = "-1")
@Document(indexName = "stock", type = "price", shards = 1, replicas = 0, refreshInterval = "-1")
public class StockPrice {
@Id

View File

@@ -12,7 +12,7 @@ import org.springframework.data.elasticsearch.annotations.Document;
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "test-index-server-configuration", type = "test-type", useServerConfiguration = true, indexStoreType = "memory", shards = 10, replicas = 10, refreshInterval = "-1")
@Document(indexName = "test-index-server-configuration", type = "test-type", useServerConfiguration = true, shards = 10, replicas = 10, refreshInterval = "-1")
public class UseServerConfigurationEntity {
@Id

View File

@@ -1,95 +1,95 @@
/*
* Copyright 2014 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
*
* http://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.repositories.cdi;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import org.apache.webbeans.cditest.CdiTestContainer;
import org.apache.webbeans.cditest.CdiTestContainerLoader;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.data.elasticsearch.entities.Product;
/**
* @author Mohsin Husen
*/
public class CdiRepositoryTests {
private static CdiTestContainer cdiContainer;
private CdiProductRepository repository;
private SamplePersonRepository personRepository;
@BeforeClass
public static void init() throws Exception {
cdiContainer = CdiTestContainerLoader.getCdiContainer();
cdiContainer.startApplicationScope();
cdiContainer.bootContainer();
}
@AfterClass
public static void shutdown() throws Exception {
cdiContainer.stopContexts();
cdiContainer.shutdownContainer();
}
@Before
public void setUp() {
CdiRepositoryClient client = cdiContainer.getInstance(CdiRepositoryClient.class);
repository = client.getRepository();
personRepository = client.getSamplePersonRepository();
}
@Test
public void testCdiRepository() {
assertNotNull(repository);
Product bean = new Product();
bean.setId("id-1");
bean.setName("cidContainerTest-1");
repository.save(bean);
assertTrue(repository.exists(bean.getId()));
Product retrieved = repository.findOne(bean.getId());
assertNotNull(retrieved);
assertEquals(bean.getId(), retrieved.getId());
assertEquals(bean.getName(), retrieved.getName());
assertEquals(1, repository.count());
assertTrue(repository.exists(bean.getId()));
repository.delete(bean);
assertEquals(0, repository.count());
retrieved = repository.findOne(bean.getId());
assertNull(retrieved);
}
/**
* @see DATAES-113
*/
@Test
public void returnOneFromCustomImpl() {
assertThat(personRepository.returnOne(), is(1));
}
}
///*
// * Copyright 2014 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
// *
// * http://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.repositories.cdi;
//
//import static org.hamcrest.CoreMatchers.is;
//import static org.junit.Assert.*;
//
//import org.apache.webbeans.cditest.CdiTestContainer;
//import org.apache.webbeans.cditest.CdiTestContainerLoader;
//import org.junit.AfterClass;
//import org.junit.Before;
//import org.junit.BeforeClass;
//import org.junit.Test;
//import org.springframework.data.elasticsearch.entities.Product;
//
///**
// * @author Mohsin Husen
// */
//TODO: ako cdi - jar hell
//public class CdiRepositoryTests {
//
// private static CdiTestContainer cdiContainer;
// private CdiProductRepository repository;
// private SamplePersonRepository personRepository;
//
// @BeforeClass
// public static void init() throws Exception {
// cdiContainer = CdiTestContainerLoader.getCdiContainer();
// cdiContainer.startApplicationScope();
// cdiContainer.bootContainer();
// }
//
// @AfterClass
// public static void shutdown() throws Exception {
// cdiContainer.stopContexts();
// cdiContainer.shutdownContainer();
// }
//
// @Before
// public void setUp() {
// CdiRepositoryClient client = cdiContainer.getInstance(CdiRepositoryClient.class);
// repository = client.getRepository();
// personRepository = client.getSamplePersonRepository();
// }
//
// @Test
// public void testCdiRepository() {
// assertNotNull(repository);
//
// Product bean = new Product();
// bean.setId("id-1");
// bean.setName("cidContainerTest-1");
//
// repository.save(bean);
//
// assertTrue(repository.exists(bean.getId()));
//
// Product retrieved = repository.findOne(bean.getId());
// assertNotNull(retrieved);
// assertEquals(bean.getId(), retrieved.getId());
// assertEquals(bean.getName(), retrieved.getName());
//
// assertEquals(1, repository.count());
//
// assertTrue(repository.exists(bean.getId()));
//
// repository.delete(bean);
//
// assertEquals(0, repository.count());
// retrieved = repository.findOne(bean.getId());
// assertNull(retrieved);
// }
//
// /**
// * @see DATAES-113
// */
// @Test
// public void returnOneFromCustomImpl() {
//
// assertThat(personRepository.returnOne(), is(1));
// }
//}

View File

@@ -24,7 +24,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.elasticsearch.common.collect.Lists;
import com.google.common.collect.Lists;
import org.apache.lucene.util.CollectionUtil;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;