@@ -186,11 +186,13 @@ void beforeEach() {
186186 when (collection .aggregate (any (List .class ), any ())).thenReturn (aggregateIterable );
187187 when (collection .withReadConcern (any ())).thenReturn (collection );
188188 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 );
190191 when (collection .withWriteConcern (any ())).thenReturn (collectionWithWriteConcern );
191192 when (collection .distinct (anyString (), any (Document .class ), any ())).thenReturn (distinctIterable );
192193 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 );
194196 when (findIterable .projection (any ())).thenReturn (findIterable );
195197 when (findIterable .sort (any (org .bson .Document .class ))).thenReturn (findIterable );
196198 when (findIterable .collation (any ())).thenReturn (findIterable );
@@ -1263,7 +1265,8 @@ void saveVersionedEntityShouldCallUpdateCorrectly() {
12631265
12641266 template .save (entity );
12651267
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 ));
12671270
12681271 assertThat (queryCaptor .getValue ()).isEqualTo (new Document ("_id" , 1 ).append ("version" , 10 ));
12691272 assertThat (updateCaptor .getValue ())
@@ -1399,10 +1402,14 @@ void createCollectionShouldNotCollationIfNotPresent() {
13991402 Assertions .assertThat (options .getValue ().getCollation ()).isNull ();
14001403 }
14011404
1402- @ Test // DATAMONGO-1854
1405+ @ Test // DATAMONGO-1854, GH-4978
14031406 void createCollectionShouldApplyDefaultCollation () {
14041407
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+ });
14061413
14071414 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
14081415 verify (db ).createCollection (any (), options .capture ());
@@ -1426,7 +1433,7 @@ void createCollectionShouldFavorExplicitOptionsOverDefaultCollation() {
14261433 @ Test // DATAMONGO-1854
14271434 void createCollectionShouldUseDefaultCollationIfCollectionOptionsAreNull () {
14281435
1429- template .createCollection (Sith .class , null );
1436+ template .createCollection (Sith .class , ( CollectionOptions ) null );
14301437
14311438 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
14321439 verify (db ).createCollection (any (), options .capture ());
@@ -2399,8 +2406,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromString() {
23992406 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
24002407 verify (db ).createCollection (any (), options .capture ());
24012408
2402- assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES ))
2403- .isEqualTo (10 );
2409+ assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES )).isEqualTo (10 );
24042410 }
24052411
24062412 @ Test // GH-4099
@@ -2413,8 +2419,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromProperty() {
24132419 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
24142420 verify (db ).createCollection (any (), options .capture ());
24152421
2416- assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES ))
2417- .isEqualTo (12 );
2422+ assertThat (options .getValue ().getExpireAfter (TimeUnit .MINUTES )).isEqualTo (12 );
24182423 }
24192424
24202425 @ Test // GH-4099
@@ -2425,8 +2430,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromIso8601String() {
24252430 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
24262431 verify (db ).createCollection (any (), options .capture ());
24272432
2428- assertThat (options .getValue ().getExpireAfter (TimeUnit .DAYS ))
2429- .isEqualTo (1 );
2433+ assertThat (options .getValue ().getExpireAfter (TimeUnit .DAYS )).isEqualTo (1 );
24302434 }
24312435
24322436 @ Test // GH-4099
@@ -2437,8 +2441,7 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromExpression() {
24372441 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
24382442 verify (db ).createCollection (any (), options .capture ());
24392443
2440- assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS ))
2441- .isEqualTo (11 );
2444+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (11 );
24422445 }
24432446
24442447 @ Test // GH-4099
@@ -2449,16 +2452,14 @@ void createCollectionShouldSetUpTimeSeriesWithExpirationFromExpressionReturningD
24492452 ArgumentCaptor <CreateCollectionOptions > options = ArgumentCaptor .forClass (CreateCollectionOptions .class );
24502453 verify (db ).createCollection (any (), options .capture ());
24512454
2452- assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS ))
2453- .isEqualTo (100 );
2455+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (100 );
24542456 }
24552457
24562458 @ Test // GH-4099
24572459 void createCollectionShouldSetUpTimeSeriesWithInvalidTimeoutExpiration () {
24582460
2459- assertThatExceptionOfType (IllegalArgumentException .class ).isThrownBy (() ->
2460- template .createCollection (TimeSeriesTypeWithInvalidExpireAfter .class )
2461- );
2461+ assertThatExceptionOfType (IllegalArgumentException .class )
2462+ .isThrownBy (() -> template .createCollection (TimeSeriesTypeWithInvalidExpireAfter .class ));
24622463 }
24632464
24642465 @ Test // GH-3522
@@ -2611,32 +2612,31 @@ public WriteConcern resolve(MongoAction action) {
26112612 verify (collection ).withWriteConcern (eq (WriteConcern .UNACKNOWLEDGED ));
26122613 }
26132614
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 () {
26192617
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 )) ));
26222620
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 ());
26252623
2626- @ Test // GH-4099
2627- void doNotSetTimeSeriesExpireOptionForNegativeValue () {
2624+ assertThat ( options . getValue (). getExpireAfter ( TimeUnit . SECONDS )). isEqualTo ( 10 );
2625+ }
26282626
2629- template . createCollection ( "time-series-collection" ,
2630- CollectionOptions . timeSeries ( "time_stamp" , options -> options . expireAfter ( Duration . ofSeconds (- 10 ))));
2627+ @ Test // GH-4099
2628+ void doNotSetTimeSeriesExpireOptionForNegativeValue () {
26312629
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 )) ));
26342632
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 ());
26372635
2636+ assertThat (options .getValue ().getExpireAfter (TimeUnit .SECONDS )).isEqualTo (0L );
2637+ }
26382638
2639- class AutogenerateableId {
2639+ class AutogenerateableId {
26402640
26412641 @ Id BigInteger id ;
26422642 }
0 commit comments