5151import org .mockito .Mockito ;
5252import org .mockito .junit .jupiter .MockitoSettings ;
5353import org .mockito .quality .Strictness ;
54+
5455import org .springframework .beans .factory .annotation .Value ;
5556import org .springframework .context .ApplicationContext ;
5657import org .springframework .context .ApplicationListener ;
121122import com .mongodb .client .MongoCollection ;
122123import com .mongodb .client .MongoCursor ;
123124import com .mongodb .client .MongoDatabase ;
124- import com .mongodb .client .model .*;
125+ import com .mongodb .client .model .CountOptions ;
126+ import com .mongodb .client .model .CreateCollectionOptions ;
127+ import com .mongodb .client .model .DeleteOptions ;
128+ import com .mongodb .client .model .FindOneAndDeleteOptions ;
129+ import com .mongodb .client .model .FindOneAndReplaceOptions ;
130+ import com .mongodb .client .model .FindOneAndUpdateOptions ;
131+ import com .mongodb .client .model .MapReduceAction ;
132+ import com .mongodb .client .model .ReplaceOptions ;
133+ import com .mongodb .client .model .TimeSeriesGranularity ;
134+ import com .mongodb .client .model .UpdateOptions ;
125135import com .mongodb .client .result .DeleteResult ;
126136import com .mongodb .client .result .UpdateResult ;
127137
@@ -499,6 +509,17 @@ void aggregateStreamShouldHonorOptionsReadPreferenceWhenSet() {
499509 verify (collection ).withReadPreference (ReadPreference .secondary ());
500510 }
501511
512+ @ Test // GH-4644
513+ void aggregateStreamShouldHonorMaxTimeIfSet () {
514+
515+ AggregationOptions options = AggregationOptions .builder ().maxTime (Duration .ofSeconds (20 )).build ();
516+
517+ template .aggregateStream (newAggregation (Aggregation .unwind ("foo" )).withOptions (options ), "collection-1" ,
518+ Wrapper .class );
519+
520+ verify (aggregateIterable ).maxTime (20000 , TimeUnit .MILLISECONDS );
521+ }
522+
502523 @ Test // DATAMONGO-2153
503524 void aggregateShouldHonorOptionsComment () {
504525
@@ -848,8 +869,7 @@ void executeQueryShouldUseBatchSizeWhenPresent() {
848869 @ Test // GH-4277
849870 void findShouldUseReadConcernWhenPresent () {
850871
851- template .find (new BasicQuery ("{'foo' : 'bar'}" ).withReadConcern (ReadConcern .SNAPSHOT ),
852- AutogenerateableId .class );
872+ template .find (new BasicQuery ("{'foo' : 'bar'}" ).withReadConcern (ReadConcern .SNAPSHOT ), AutogenerateableId .class );
853873
854874 verify (collection ).withReadConcern (ReadConcern .SNAPSHOT );
855875 }
@@ -1132,8 +1152,7 @@ void countShouldApplyQueryHintAsIndexNameIfPresent() {
11321152 void appliesFieldsWhenInterfaceProjectionIsClosedAndQueryDoesNotDefineFields () {
11331153
11341154 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document (), Person .class ,
1135- PersonProjection .class ,
1136- CursorPreparer .NO_OP_PREPARER );
1155+ PersonProjection .class , CursorPreparer .NO_OP_PREPARER );
11371156
11381157 verify (findIterable ).projection (eq (new Document ("firstname" , 1 )));
11391158 }
@@ -1142,8 +1161,7 @@ void appliesFieldsWhenInterfaceProjectionIsClosedAndQueryDoesNotDefineFields() {
11421161 void doesNotApplyFieldsWhenInterfaceProjectionIsClosedAndQueryDefinesFields () {
11431162
11441163 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document ("bar" , 1 ), Person .class ,
1145- PersonProjection .class ,
1146- CursorPreparer .NO_OP_PREPARER );
1164+ PersonProjection .class , CursorPreparer .NO_OP_PREPARER );
11471165
11481166 verify (findIterable ).projection (eq (new Document ("bar" , 1 )));
11491167 }
@@ -1152,8 +1170,7 @@ void doesNotApplyFieldsWhenInterfaceProjectionIsClosedAndQueryDefinesFields() {
11521170 void doesNotApplyFieldsWhenInterfaceProjectionIsOpen () {
11531171
11541172 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document (), Person .class ,
1155- PersonSpELProjection .class ,
1156- CursorPreparer .NO_OP_PREPARER );
1173+ PersonSpELProjection .class , CursorPreparer .NO_OP_PREPARER );
11571174
11581175 verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
11591176 }
@@ -1162,8 +1179,7 @@ void doesNotApplyFieldsWhenInterfaceProjectionIsOpen() {
11621179 void appliesFieldsToDtoProjection () {
11631180
11641181 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document (), Person .class ,
1165- Jedi .class ,
1166- CursorPreparer .NO_OP_PREPARER );
1182+ Jedi .class , CursorPreparer .NO_OP_PREPARER );
11671183
11681184 verify (findIterable ).projection (eq (new Document ("firstname" , 1 )));
11691185 }
@@ -1172,8 +1188,7 @@ void appliesFieldsToDtoProjection() {
11721188 void doesNotApplyFieldsToDtoProjectionWhenQueryDefinesFields () {
11731189
11741190 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document ("bar" , 1 ), Person .class ,
1175- Jedi .class ,
1176- CursorPreparer .NO_OP_PREPARER );
1191+ Jedi .class , CursorPreparer .NO_OP_PREPARER );
11771192
11781193 verify (findIterable ).projection (eq (new Document ("bar" , 1 )));
11791194 }
@@ -1182,8 +1197,7 @@ void doesNotApplyFieldsToDtoProjectionWhenQueryDefinesFields() {
11821197 void doesNotApplyFieldsWhenTargetIsNotAProjection () {
11831198
11841199 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document (), Person .class ,
1185- Person .class ,
1186- CursorPreparer .NO_OP_PREPARER );
1200+ Person .class , CursorPreparer .NO_OP_PREPARER );
11871201
11881202 verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
11891203 }
@@ -1192,8 +1206,7 @@ void doesNotApplyFieldsWhenTargetIsNotAProjection() {
11921206 void doesNotApplyFieldsWhenTargetExtendsDomainType () {
11931207
11941208 template .doFind (CollectionPreparer .identity (), "star-wars" , new Document (), new Document (), Person .class ,
1195- PersonExtended .class ,
1196- CursorPreparer .NO_OP_PREPARER );
1209+ PersonExtended .class , CursorPreparer .NO_OP_PREPARER );
11971210
11981211 verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
11991212 }
0 commit comments