Search in sources :

Example 16 with IndexInfo

use of org.springframework.data.mongodb.core.index.IndexInfo in project spring-data-mongodb by spring-projects.

the class GeoSpatialIndexTests method useGeneratedNameShouldGenerateAnIndexName.

// DATAMONGO-827
@Test
public void useGeneratedNameShouldGenerateAnIndexName() {
    try {
        GeoSpatialEntity2dWithGeneratedIndex geo = new GeoSpatialEntity2dWithGeneratedIndex(45.2, 4.6);
        template.save(geo);
        IndexOperations indexOps = template.indexOps(GeoSpatialEntity2dWithGeneratedIndex.class);
        List<IndexInfo> indexInfo = indexOps.getIndexInfo();
        assertThat(indexInfo, hasSize(2));
        assertThat(indexInfo.get(1), is(notNullValue()));
        assertThat(indexInfo.get(1).getName(), is("location_2d"));
    } finally {
        template.dropCollection(GeoSpatialEntity2D.class);
    }
}
Also used : IndexOperations(org.springframework.data.mongodb.core.index.IndexOperations) IndexInfo(org.springframework.data.mongodb.core.index.IndexInfo) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)16 IndexInfo (org.springframework.data.mongodb.core.index.IndexInfo)16 Index (org.springframework.data.mongodb.core.index.Index)11 IndexDefinition (org.springframework.data.mongodb.core.index.IndexDefinition)10 Document (org.bson.Document)7 QueryMapper (org.springframework.data.mongodb.core.convert.QueryMapper)7 MongoClient (com.mongodb.reactivestreams.client.MongoClient)5 MongoClients (com.mongodb.reactivestreams.client.MongoClients)5 MongoCollection (com.mongodb.reactivestreams.client.MongoCollection)5 Predicate (java.util.function.Predicate)5 Assertions (org.assertj.core.api.Assertions)5 Assume (org.junit.Assume)5 Before (org.junit.Before)5 RunWith (org.junit.runner.RunWith)5 Autowired (org.springframework.beans.factory.annotation.Autowired)5 Configuration (org.springframework.context.annotation.Configuration)5 Direction (org.springframework.data.domain.Sort.Direction)5 AbstractReactiveMongoConfiguration (org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration)5 PartialIndexFilter (org.springframework.data.mongodb.core.index.PartialIndexFilter)5 Field (org.springframework.data.mongodb.core.mapping.Field)5