3131import org .junit .jupiter .params .ParameterizedTest ;
3232import org .junit .jupiter .params .provider .Arguments ;
3333import org .junit .jupiter .params .provider .MethodSource ;
34-
3534import org .springframework .beans .factory .annotation .Autowired ;
3635import org .springframework .context .annotation .Configuration ;
3736import org .springframework .data .mongodb .config .AbstractMongoClientConfiguration ;
@@ -84,7 +83,7 @@ void beforeEach() {
8483 template .dropCollection (COLLECTION_NAME );
8584 }
8685
87- @ ParameterizedTest // GH-4185
86+ @ ParameterizedTest // GH-4185, GH-4989
8887 @ MethodSource ("collectionOptions" )
8988 public void createsCollectionWithEncryptedFieldsCorrectly (CollectionOptions collectionOptions ) {
9089
@@ -103,23 +102,33 @@ public void createsCollectionWithEncryptedFieldsCorrectly(CollectionOptions coll
103102 .containsEntry ("bsonType" , "long" ) //
104103 .containsEntry ("queries" , List .of (Document .parse (
105104 "{'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'}}" )));
106110 }
107111
108112 private static Stream <Arguments > collectionOptions () {
109113
110114 BsonBinary key1 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
111115 BsonBinary key2 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
116+ BsonBinary key3 = new BsonBinary (UUID .randomUUID (), UuidRepresentation .STANDARD );
112117
113118 CollectionOptions manualOptions = CollectionOptions .encryptedCollection (options -> options //
114119 .queryable (encrypted (int32 ("encryptedInt" )).keys (key1 ), range ().min (5 ).max (100 ).contention (1 )) //
115120 .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 )));
117124
118125 CollectionOptions schemaOptions = CollectionOptions .encryptedCollection (MongoJsonSchema .builder ()
119126 .property (
120127 queryable (encrypted (int32 ("encryptedInt" )).keyId (key1 ), List .of (range ().min (5 ).max (100 ).contention (1 ))))
121128 .property (queryable (encrypted (int64 ("nested.encryptedLong" )).keyId (key2 ),
122129 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 ))))
123132 .build ());
124133
125134 return Stream .of (Arguments .of (manualOptions ), Arguments .of (schemaOptions ));
0 commit comments