@@ -186,11 +186,13 @@ void beforeEach() {
186
186
when (collection .aggregate (any (List .class ), any ())).thenReturn (aggregateIterable );
187
187
when (collection .withReadConcern (any ())).thenReturn (collection );
188
188
when (collection .withReadPreference (any ())).thenReturn (collection );
189
- when (collection .replaceOne (any (), any (), any (com .mongodb .client .model .ReplaceOptions .class ))).thenReturn (updateResult );
189
+ when (collection .replaceOne (any (), any (), any (com .mongodb .client .model .ReplaceOptions .class )))
190
+ .thenReturn (updateResult );
190
191
when (collection .withWriteConcern (any ())).thenReturn (collectionWithWriteConcern );
191
192
when (collection .distinct (anyString (), any (Document .class ), any ())).thenReturn (distinctIterable );
192
193
when (collectionWithWriteConcern .deleteOne (any (Bson .class ), any ())).thenReturn (deleteResult );
193
- when (collectionWithWriteConcern .replaceOne (any (), any (), any (com .mongodb .client .model .ReplaceOptions .class ))).thenReturn (updateResult );
194
+ when (collectionWithWriteConcern .replaceOne (any (), any (), any (com .mongodb .client .model .ReplaceOptions .class )))
195
+ .thenReturn (updateResult );
194
196
when (findIterable .projection (any ())).thenReturn (findIterable );
195
197
when (findIterable .sort (any (org .bson .Document .class ))).thenReturn (findIterable );
196
198
when (findIterable .collation (any ())).thenReturn (findIterable );
@@ -1263,7 +1265,8 @@ void saveVersionedEntityShouldCallUpdateCorrectly() {
1263
1265
1264
1266
template .save (entity );
1265
1267
1266
- verify (collection , times (1 )).replaceOne (queryCaptor .capture (), updateCaptor .capture (), any (com .mongodb .client .model .ReplaceOptions .class ));
1268
+ verify (collection , times (1 )).replaceOne (queryCaptor .capture (), updateCaptor .capture (),
1269
+ any (com .mongodb .client .model .ReplaceOptions .class ));
1267
1270
1268
1271
assertThat (queryCaptor .getValue ()).isEqualTo (new Document ("_id" , 1 ).append ("version" , 10 ));
1269
1272
assertThat (updateCaptor .getValue ())
@@ -1399,10 +1402,14 @@ void createCollectionShouldNotCollationIfNotPresent() {
1399
1402
Assertions .assertThat (options .getValue ().getCollation ()).isNull ();
1400
1403
}
1401
1404
1402
- @ Test // DATAMONGO-1854
1405
+ @ Test // DATAMONGO-1854, GH-4978
1403
1406
void createCollectionShouldApplyDefaultCollation () {
1404
1407
1405
- template .createCollection (Sith .class );
1408
+ template .createCollection (Sith .class , options -> {
1409
+
1410
+ assertThat (options .getCollation ()).contains (Collation .of ("de_AT" ));
1411
+ return options ;
1412
+ });
1406
1413
1407
1414
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
1408
1415
verify (db ).createCollection (any (), options .capture ());
@@ -1426,7 +1433,7 @@ void createCollectionShouldFavorExplicitOptionsOverDefaultCollation() {
1426
1433
@ Test // DATAMONGO-1854
1427
1434
void createCollectionShouldUseDefaultCollationIfCollectionOptionsAreNull () {
1428
1435
1429
- template .createCollection (Sith .class , null );
1436
+ template .createCollection (Sith .class , ( CollectionOptions ) null );
1430
1437
1431
1438
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
1432
1439
verify (db ).createCollection (any (), options .capture ());
@@ -2399,8 +2406,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromString() {
2399
2406
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
2400
2407
verify (db ).createCollection (any (), options .capture ());
2401
2408
2402
- assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES ))
2403
- .isEqualTo (10 );
2409
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES )).isEqualTo (10 );
2404
2410
}
2405
2411
2406
2412
@ Test // GH-4099
@@ -2413,8 +2419,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromProperty() {
2413
2419
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
2414
2420
verify (db ).createCollection (any (), options .capture ());
2415
2421
2416
- assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES ))
2417
- .isEqualTo (12 );
2422
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES )).isEqualTo (12 );
2418
2423
}
2419
2424
2420
2425
@ Test // GH-4099
@@ -2425,8 +2430,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromIso8601String() {
2425
2430
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
2426
2431
verify (db ).createCollection (any (), options .capture ());
2427
2432
2428
- assertThat (options .getValue ().getExpireAfter (TimeUnit .DAYS ))
2429
- .isEqualTo (1 );
2433
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .DAYS )).isEqualTo (1 );
2430
2434
}
2431
2435
2432
2436
@ Test // GH-4099
@@ -2437,8 +2441,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromExpression() {
2437
2441
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
2438
2442
verify (db ).createCollection (any (), options .capture ());
2439
2443
2440
- assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS ))
2441
- .isEqualTo (11 );
2444
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (11 );
2442
2445
}
2443
2446
2444
2447
@ Test // GH-4099
@@ -2449,16 +2452,14 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromExpressionReturningD
2449
2452
ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
2450
2453
verify (db ).createCollection (any (), options .capture ());
2451
2454
2452
- assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS ))
2453
- .isEqualTo (100 );
2455
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (100 );
2454
2456
}
2455
2457
2456
2458
@ Test // GH-4099
2457
2459
void createCollectionShouldSetUpTimeSeriesWithInvalidTimeoutExpiration () {
2458
2460
2459
- assertThatExceptionOfType (IllegalArgumentException .class ).isThrownBy (() ->
2460
- template .createCollection (TimeSeriesTypeWithInvalidExpireAfter .class )
2461
- );
2461
+ assertThatExceptionOfType (IllegalArgumentException .class )
2462
+ .isThrownBy (() -> template .createCollection (TimeSeriesTypeWithInvalidExpireAfter .class ));
2462
2463
}
2463
2464
2464
2465
@ Test // GH-3522
@@ -2611,32 +2612,31 @@ public WriteConcern resolve(MongoAction action) {
2611
2612
verify (collection ).withWriteConcern (eq (WriteConcern .UNACKNOWLEDGED ));
2612
2613
}
2613
2614
2614
- @ Test // GH-4099
2615
- void passOnTimeSeriesExpireOption () {
2616
-
2617
- template .createCollection ("time-series-collection" ,
2618
- CollectionOptions .timeSeries ("time_stamp" , options -> options .expireAfter (Duration .ofSeconds (10 ))));
2615
+ @ Test // GH-4099
2616
+ void passOnTimeSeriesExpireOption () {
2619
2617
2620
- ArgumentCaptor < CreateCollectionOptions > options = ArgumentCaptor . forClass ( CreateCollectionOptions . class );
2621
- verify ( db ). createCollection ( any () , options . capture ( ));
2618
+ template . createCollection ( "time-series-collection" ,
2619
+ CollectionOptions . timeSeries ( "time_stamp" , options -> options . expireAfter ( Duration . ofSeconds ( 10 )) ));
2622
2620
2623
- assertThat ( options . getValue (). getExpireAfter ( TimeUnit . SECONDS )). isEqualTo ( 10 );
2624
- }
2621
+ ArgumentCaptor < CreateCollectionOptions > options = ArgumentCaptor . forClass ( CreateCollectionOptions . class );
2622
+ verify ( db ). createCollection ( any (), options . capture ());
2625
2623
2626
- @ Test // GH-4099
2627
- void doNotSetTimeSeriesExpireOptionForNegativeValue () {
2624
+ assertThat ( options . getValue (). getExpireAfter ( TimeUnit . SECONDS )). isEqualTo ( 10 );
2625
+ }
2628
2626
2629
- template . createCollection ( "time-series-collection" ,
2630
- CollectionOptions . timeSeries ( "time_stamp" , options -> options . expireAfter ( Duration . ofSeconds (- 10 ))));
2627
+ @ Test // GH-4099
2628
+ void doNotSetTimeSeriesExpireOptionForNegativeValue () {
2631
2629
2632
- ArgumentCaptor < CreateCollectionOptions > options = ArgumentCaptor . forClass ( CreateCollectionOptions . class );
2633
- verify ( db ). createCollection ( any () , options . capture ( ));
2630
+ template . createCollection ( "time-series-collection" ,
2631
+ CollectionOptions . timeSeries ( "time_stamp" , options -> options . expireAfter ( Duration . ofSeconds (- 10 )) ));
2634
2632
2635
- assertThat ( options . getValue (). getExpireAfter ( TimeUnit . SECONDS )). isEqualTo ( 0L );
2636
- }
2633
+ ArgumentCaptor < CreateCollectionOptions > options = ArgumentCaptor . forClass ( CreateCollectionOptions . class );
2634
+ verify ( db ). createCollection ( any (), options . capture ());
2637
2635
2636
+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (0L );
2637
+ }
2638
2638
2639
- class AutogenerateableId {
2639
+ class AutogenerateableId {
2640
2640
2641
2641
@ Id BigInteger id ;
2642
2642
}
0 commit comments