@@ -21,14 +21,15 @@ import com.mongodb.MongoException
21
21
import com.mongodb.OperationFunctionalSpecification
22
22
import org.bson.BsonDocument
23
23
import org.bson.BsonInt32
24
+ import org.bson.BsonInt64
24
25
import org.bson.Document
25
26
import org.bson.codecs.DocumentCodec
26
27
import org.junit.experimental.categories.Category
27
28
28
29
import static com.mongodb.ClusterFixture.executeAsync
29
30
import static com.mongodb.ClusterFixture.getBinding
30
31
31
- class DropIndexesOperationSpecification extends OperationFunctionalSpecification {
32
+ class DropIndexOperationSpecification extends OperationFunctionalSpecification {
32
33
33
34
def ' should not error when dropping non-existent index on non-existent collection' () {
34
35
when :
@@ -84,8 +85,8 @@ class DropIndexesOperationSpecification extends OperationFunctionalSpecification
84
85
}
85
86
86
87
def ' should drop existing index by keys' () {
87
- def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
88
88
given :
89
+ def keys = new BsonDocument (' theField' , new BsonInt32 (1 ))
89
90
collectionHelper. createIndex(keys)
90
91
91
92
when :
@@ -100,8 +101,40 @@ class DropIndexesOperationSpecification extends OperationFunctionalSpecification
100
101
@Category (Async )
101
102
def ' should drop existing index asynchronously' () {
102
103
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 )));
105
138
106
139
when :
107
140
executeAsync(operation)
0 commit comments