18
18
import static org .assertj .core .api .Assertions .*;
19
19
import static org .springframework .data .mongodb .core .query .Criteria .*;
20
20
import static org .springframework .data .mongodb .core .query .Query .*;
21
+ import static org .springframework .data .mongodb .test .util .DirtiesStateExtension .*;
21
22
22
23
import lombok .AllArgsConstructor ;
23
24
import lombok .Data ;
35
36
import org .bson .BsonString ;
36
37
import org .bson .BsonValue ;
37
38
import org .bson .Document ;
38
- import org .junit .jupiter .api .BeforeEach ;
39
39
import org .junit .jupiter .api .Test ;
40
+ import org .junit .jupiter .api .TestInstance ;
40
41
import org .junit .jupiter .api .extension .ExtendWith ;
42
+
41
43
import org .springframework .beans .factory .annotation .Value ;
42
44
import org .springframework .dao .IncorrectResultSizeDataAccessException ;
43
45
import org .springframework .dao .InvalidDataAccessApiUsageException ;
50
52
import org .springframework .data .mongodb .core .query .Criteria ;
51
53
import org .springframework .data .mongodb .core .query .NearQuery ;
52
54
import org .springframework .data .mongodb .test .util .Client ;
55
+ import org .springframework .data .mongodb .test .util .DirtiesStateExtension ;
53
56
import org .springframework .data .mongodb .test .util .MongoClientExtension ;
54
57
55
58
import com .mongodb .client .MongoClient ;
61
64
* @author Christoph Strobl
62
65
* @author Juergen Zimmermann
63
66
*/
64
- @ ExtendWith (MongoClientExtension .class )
65
- class ReactiveFindOperationSupportTests {
67
+ @ ExtendWith ({ MongoClientExtension .class , DirtiesStateExtension .class })
68
+ @ TestInstance (TestInstance .Lifecycle .PER_CLASS )
69
+ class ReactiveFindOperationSupportTests implements StateFunctions {
66
70
67
71
private static final String STAR_WARS = "star-wars" ;
68
72
private MongoTemplate blocking ;
@@ -74,15 +78,25 @@ class ReactiveFindOperationSupportTests {
74
78
private Person han ;
75
79
private Person luke ;
76
80
77
- @ BeforeEach
78
81
void setUp () {
79
-
80
82
blocking = new MongoTemplate (new SimpleMongoClientDatabaseFactory (client , "ExecutableFindOperationSupportTests" ));
83
+ template = new ReactiveMongoTemplate (reactiveClient , "ExecutableFindOperationSupportTests" );
84
+ }
85
+
86
+ @ Override
87
+ public void clear () {
88
+ if (blocking == null ) {
89
+ setUp ();
90
+ }
81
91
recreateCollection (STAR_WARS , false );
92
+ }
82
93
94
+ @ Override
95
+ public void setupState () {
96
+ if (blocking == null ) {
97
+ setUp ();
98
+ }
83
99
insertObjects ();
84
-
85
- template = new ReactiveMongoTemplate (reactiveClient , "ExecutableFindOperationSupportTests" );
86
100
}
87
101
88
102
void insertObjects () {
@@ -244,6 +258,7 @@ void findByTooManyResults() {
244
258
}
245
259
246
260
@ Test // DATAMONGO-1719
261
+ @ DirtiesState
247
262
void findAllNearBy () {
248
263
249
264
blocking .indexOps (Planet .class ).ensureIndex (
@@ -264,6 +279,7 @@ void findAllNearBy() {
264
279
}
265
280
266
281
@ Test // DATAMONGO-1719
282
+ @ DirtiesState
267
283
void findAllNearByWithCollectionAndProjection () {
268
284
269
285
blocking .indexOps (Planet .class ).ensureIndex (
@@ -287,6 +303,7 @@ void findAllNearByWithCollectionAndProjection() {
287
303
}
288
304
289
305
@ Test // DATAMONGO-1719
306
+ @ DirtiesState
290
307
void findAllNearByReturningGeoResultContentAsClosedInterfaceProjection () {
291
308
292
309
blocking .indexOps (Planet .class ).ensureIndex (
@@ -310,6 +327,7 @@ void findAllNearByReturningGeoResultContentAsClosedInterfaceProjection() {
310
327
}
311
328
312
329
@ Test // DATAMONGO-1719
330
+ @ DirtiesState
313
331
void findAllNearByReturningGeoResultContentAsOpenInterfaceProjection () {
314
332
315
333
blocking .indexOps (Planet .class ).ensureIndex (
@@ -333,6 +351,7 @@ void findAllNearByReturningGeoResultContentAsOpenInterfaceProjection() {
333
351
}
334
352
335
353
@ Test // DATAMONGO-2080
354
+ @ ProvidesState
336
355
void tail () throws InterruptedException {
337
356
338
357
recreateCollection (STAR_WARS , true );
@@ -361,6 +380,7 @@ void tail() throws InterruptedException {
361
380
}
362
381
363
382
@ Test // DATAMONGO-2080
383
+ @ ProvidesState
364
384
void tailWithProjection () {
365
385
366
386
recreateCollection (STAR_WARS , true );
@@ -374,6 +394,7 @@ void tailWithProjection() {
374
394
}
375
395
376
396
@ Test // DATAMONGO-2080
397
+ @ ProvidesState
377
398
void tailWithClosedInterfaceProjection () {
378
399
379
400
recreateCollection (STAR_WARS , true );
@@ -391,6 +412,7 @@ void tailWithClosedInterfaceProjection() {
391
412
}
392
413
393
414
@ Test // DATAMONGO-2080
415
+ @ ProvidesState
394
416
void tailWithOpenInterfaceProjection () {
395
417
396
418
recreateCollection (STAR_WARS , true );
@@ -431,6 +453,7 @@ void existsShouldReturnTrueIfAtLeastOneElementExistsInCollection() {
431
453
}
432
454
433
455
@ Test // DATAMONGO-1719
456
+ @ DirtiesState
434
457
void existsShouldReturnFalseIfNoElementExistsInCollection () {
435
458
436
459
blocking .remove (new BasicQuery ("{}" ), STAR_WARS );
@@ -462,6 +485,7 @@ void distinctReturnsEmptyListIfNoMatchFound() {
462
485
}
463
486
464
487
@ Test // DATAMONGO-1761
488
+ @ DirtiesState
465
489
void distinctReturnsSimpleFieldValuesCorrectlyForCollectionHavingReturnTypeSpecifiedThatCanBeConvertedDirectlyByACodec () {
466
490
467
491
Person anakin = new Person ();
@@ -476,6 +500,7 @@ void distinctReturnsSimpleFieldValuesCorrectlyForCollectionHavingReturnTypeSpeci
476
500
}
477
501
478
502
@ Test // DATAMONGO-1761
503
+ @ DirtiesState
479
504
void distinctReturnsSimpleFieldValuesCorrectly () {
480
505
481
506
Person anakin = new Person ();
@@ -504,6 +529,7 @@ void distinctReturnsSimpleFieldValuesCorrectly() {
504
529
}
505
530
506
531
@ Test // DATAMONGO-1761
532
+ @ DirtiesState
507
533
void distinctReturnsComplexValuesCorrectly () {
508
534
509
535
Sith sith = new Sith ();
@@ -521,6 +547,7 @@ void distinctReturnsComplexValuesCorrectly() {
521
547
}
522
548
523
549
@ Test // DATAMONGO-1761
550
+ @ DirtiesState
524
551
void distinctReturnsComplexValuesCorrectlyHavingReturnTypeSpecified () {
525
552
526
553
Sith sith = new Sith ();
@@ -538,6 +565,7 @@ void distinctReturnsComplexValuesCorrectlyHavingReturnTypeSpecified() {
538
565
}
539
566
540
567
@ Test // DATAMONGO-1761
568
+ @ DirtiesState
541
569
void distinctReturnsComplexValuesCorrectlyReturnTypeDocumentSpecified () {
542
570
543
571
Sith sith = new Sith ();
@@ -573,6 +601,7 @@ void distinctReturnsRawValuesIfReturnTypeIsBsonValue() {
573
601
}
574
602
575
603
@ Test // DATAMONGO-1761
604
+ @ DirtiesState
576
605
void distinctReturnsValuesMappedToTheirJavaTypeEvenWhenNotExplicitlyDefinedByTheDomainType () {
577
606
578
607
blocking .save (new Document ("darth" , "vader" ), STAR_WARS );
@@ -583,6 +612,7 @@ void distinctReturnsValuesMappedToTheirJavaTypeEvenWhenNotExplicitlyDefinedByThe
583
612
}
584
613
585
614
@ Test // DATAMONGO-1761
615
+ @ DirtiesState
586
616
void distinctReturnsMappedDomainTypeForProjections () {
587
617
588
618
luke .father = new Person ();
@@ -596,6 +626,7 @@ void distinctReturnsMappedDomainTypeForProjections() {
596
626
}
597
627
598
628
@ Test // DATAMONGO-1761
629
+ @ DirtiesState
599
630
void distinctAlllowsQueryUsingObjectSourceType () {
600
631
601
632
luke .father = new Person ();
@@ -609,6 +640,7 @@ void distinctAlllowsQueryUsingObjectSourceType() {
609
640
}
610
641
611
642
@ Test // DATAMONGO-1761
643
+ @ DirtiesState
612
644
void distinctReturnsMappedDomainTypeExtractedFromPropertyWhenNoExplicitTypePresent () {
613
645
614
646
luke .father = new Person ();
0 commit comments