51
51
import org .mockito .Mockito ;
52
52
import org .mockito .junit .jupiter .MockitoSettings ;
53
53
import org .mockito .quality .Strictness ;
54
+
54
55
import org .springframework .beans .factory .annotation .Value ;
55
56
import org .springframework .context .ApplicationContext ;
56
57
import org .springframework .context .ApplicationListener ;
121
122
import com .mongodb .client .MongoCollection ;
122
123
import com .mongodb .client .MongoCursor ;
123
124
import 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 ;
125
135
import com .mongodb .client .result .DeleteResult ;
126
136
import com .mongodb .client .result .UpdateResult ;
127
137
@@ -499,6 +509,17 @@ void aggregateStreamShouldHonorOptionsReadPreferenceWhenSet() {
499
509
verify (collection ).withReadPreference (ReadPreference .secondary ());
500
510
}
501
511
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
+
502
523
@ Test // DATAMONGO-2153
503
524
void aggregateShouldHonorOptionsComment () {
504
525
@@ -848,8 +869,7 @@ void executeQueryShouldUseBatchSizeWhenPresent() {
848
869
@ Test // GH-4277
849
870
void findShouldUseReadConcernWhenPresent () {
850
871
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 );
853
873
854
874
verify (collection ).withReadConcern (ReadConcern .SNAPSHOT );
855
875
}
@@ -1132,8 +1152,7 @@ void countShouldApplyQueryHintAsIndexNameIfPresent() {
1132
1152
void appliesFieldsWhenInterfaceProjectionIsClosedAndQueryDoesNotDefineFields () {
1133
1153
1134
1154
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 );
1137
1156
1138
1157
verify (findIterable ).projection (eq (new Document ("firstname" , 1 )));
1139
1158
}
@@ -1142,8 +1161,7 @@ void appliesFieldsWhenInterfaceProjectionIsClosedAndQueryDoesNotDefineFields() {
1142
1161
void doesNotApplyFieldsWhenInterfaceProjectionIsClosedAndQueryDefinesFields () {
1143
1162
1144
1163
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 );
1147
1165
1148
1166
verify (findIterable ).projection (eq (new Document ("bar" , 1 )));
1149
1167
}
@@ -1152,8 +1170,7 @@ void doesNotApplyFieldsWhenInterfaceProjectionIsClosedAndQueryDefinesFields() {
1152
1170
void doesNotApplyFieldsWhenInterfaceProjectionIsOpen () {
1153
1171
1154
1172
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 );
1157
1174
1158
1175
verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
1159
1176
}
@@ -1162,8 +1179,7 @@ void doesNotApplyFieldsWhenInterfaceProjectionIsOpen() {
1162
1179
void appliesFieldsToDtoProjection () {
1163
1180
1164
1181
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 );
1167
1183
1168
1184
verify (findIterable ).projection (eq (new Document ("firstname" , 1 )));
1169
1185
}
@@ -1172,8 +1188,7 @@ void appliesFieldsToDtoProjection() {
1172
1188
void doesNotApplyFieldsToDtoProjectionWhenQueryDefinesFields () {
1173
1189
1174
1190
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 );
1177
1192
1178
1193
verify (findIterable ).projection (eq (new Document ("bar" , 1 )));
1179
1194
}
@@ -1182,8 +1197,7 @@ void doesNotApplyFieldsToDtoProjectionWhenQueryDefinesFields() {
1182
1197
void doesNotApplyFieldsWhenTargetIsNotAProjection () {
1183
1198
1184
1199
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 );
1187
1201
1188
1202
verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
1189
1203
}
@@ -1192,8 +1206,7 @@ void doesNotApplyFieldsWhenTargetIsNotAProjection() {
1192
1206
void doesNotApplyFieldsWhenTargetExtendsDomainType () {
1193
1207
1194
1208
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 );
1197
1210
1198
1211
verify (findIterable ).projection (eq (BsonUtils .EMPTY_DOCUMENT ));
1199
1212
}
0 commit comments