31
31
import org .junit .jupiter .params .ParameterizedTest ;
32
32
import org .junit .jupiter .params .provider .Arguments ;
33
33
import org .junit .jupiter .params .provider .MethodSource ;
34
-
35
34
import org .springframework .beans .factory .annotation .Autowired ;
36
35
import org .springframework .context .annotation .Configuration ;
37
36
import org .springframework .data .mongodb .config .AbstractMongoClientConfiguration ;
@@ -84,7 +83,7 @@ void beforeEach() {
84
83
template .dropCollection (COLLECTION_NAME );
85
84
}
86
85
87
- @ ParameterizedTest // GH-4185
86
+ @ ParameterizedTest // GH-4185, GH-4989
88
87
@ MethodSource ("collectionOptions" )
89
88
public void createsCollectionWithEncryptedFieldsCorrectly (CollectionOptions collectionOptions ) {
90
89
@@ -103,23 +102,33 @@ public void createsCollectionWithEncryptedFieldsCorrectly(CollectionOptions coll
103
102
.containsEntry ("bsonType" , "long" ) //
104
103
.containsEntry ("queries" , List .of (Document .parse (
105
104
"{'queryType': 'range', 'contention': { '$numberLong' : '0' }, 'min': { '$numberLong' : '-1' }, 'max': { '$numberLong' : '1' }}" )));
105
+
106
+ assertThat (fields .get (2 )).containsEntry ("path" , "encryptedDouble" ) //
107
+ .containsEntry ("bsonType" , "double" ) //
108
+ .containsEntry ("queries" , List .of (Document .parse (
109
+ "{'queryType': 'range', 'contention': { '$numberLong' : '1' }, 'min': { '$numberDouble' : '-1.123' }, 'max': { '$numberDouble' : '1.123' }, 'precision': { '$numberInt' : '5'}}" )));
106
110
}
107
111
108
112
private static Stream <Arguments > collectionOptions () {
109
113
110
114
BsonBinary key1 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
111
115
BsonBinary key2 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
116
+ BsonBinary key3 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
112
117
113
118
CollectionOptions manualOptions = CollectionOptions .encryptedCollection (options -> options //
114
119
.queryable (encrypted (int32 ("encryptedInt" )).keys (key1 ), range ().min (5 ).max (100 ).contention (1 )) //
115
120
.queryable (encrypted (JsonSchemaProperty .int64 ("nested.encryptedLong" )).keys (key2 ),
116
- range ().min (-1L ).max (1L ).contention (0 )));
121
+ range ().min (-1L ).max (1L ).contention (0 )) //
122
+ .queryable (encrypted (JsonSchemaProperty .float64 ("encryptedDouble" )).keys (key3 ),
123
+ range ().min (-1.123D ).max (1.123D ).precision (5 ).contention (1 )));
117
124
118
125
CollectionOptions schemaOptions = CollectionOptions .encryptedCollection (MongoJsonSchema .builder ()
119
126
.property (
120
127
queryable (encrypted (int32 ("encryptedInt" )).keyId (key1 ), List .of (range ().min (5 ).max (100 ).contention (1 ))))
121
128
.property (queryable (encrypted (int64 ("nested.encryptedLong" )).keyId (key2 ),
122
129
List .of (range ().min (-1L ).max (1L ).contention (0 ))))
130
+ .property (queryable (encrypted (float64 ("encryptedDouble" )).keyId (key3 ),
131
+ List .of (range ().min (-1.123D ).max (1.123D ).precision (5 ).contention (1 ))))
123
132
.build ());
124
133
125
134
return Stream .of (Arguments .of (manualOptions ), Arguments .of (schemaOptions ));
0 commit comments