@@ -21,14 +21,15 @@ import com.mongodb.MongoException
2121import com.mongodb.OperationFunctionalSpecification
2222import org.bson.BsonDocument
2323import org.bson.BsonInt32
24+ import org.bson.BsonInt64
2425import org.bson.Document
2526import org.bson.codecs.DocumentCodec
2627import org.junit.experimental.categories.Category
2728
2829import static com.mongodb.ClusterFixture.executeAsync
2930import static com.mongodb.ClusterFixture.getBinding
3031
31- class DropIndexesOperationSpecification extends OperationFunctionalSpecification {
32+ class DropIndexOperationSpecification extends OperationFunctionalSpecification {
3233
3334 def ' should not error when dropping non-existent index on non-existent collection' () {
3435 when :
@@ -84,8 +85,8 @@ class DropIndexesOperationSpecification extends OperationFunctionalSpecification
8485 }
8586
8687 def ' should drop existing index by keys' () {
87- def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
8888 given :
89+ def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
8990 collectionHelper. createIndex(keys)
9091
9192 when :
@@ -100,8 +101,40 @@ class DropIndexesOperationSpecification extends OperationFunctionalSpecification
100101 @Category (Async )
101102 def ' should drop existing index asynchronously' () {
102103 given :
103- collectionHelper. createIndex(new BsonDocument (' theField' , new BsonInt32 (1 )))
104- def operation = new DropIndexOperation (getNamespace(), ' theField_1' );
104+ def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
105+ collectionHelper. createIndex(keys)
106+ def operation = new DropIndexOperation (getNamespace(), keys);
107+
108+ when :
109+ executeAsync(operation)
110+ List<Document > indexes = getIndexes()
111+
112+ then :
113+ indexes. size() == 1
114+ indexes[0 ]. name == ' _id_'
115+ }
116+
117+
118+ def ' should drop existing index by key when using BsonInt64' () {
119+ given :
120+ def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
121+ collectionHelper. createIndex(keys)
122+
123+ when :
124+ new DropIndexOperation (getNamespace(), new BsonDocument (' theField' , new BsonInt64 (1 ))). execute(getBinding())
125+ List<Document > indexes = getIndexes()
126+
127+ then :
128+ indexes. size() == 1
129+ indexes[0 ]. name == ' _id_'
130+ }
131+
132+ @Category (Async )
133+ def ' should drop existing index by key when using BsonInt64 asynchronously' () {
134+ given :
135+ def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
136+ collectionHelper. createIndex(keys)
137+ def operation = new DropIndexOperation (getNamespace(), new BsonDocument (' theField' , new BsonInt64 (1 )));
105138
106139 when :
107140 executeAsync(operation)
0 commit comments