@@ -461,6 +461,52 @@ public void testFindAllAndRemoveFullyReturnsAndRemovesDocuments() {
461
461
StepVerifier .create (template .findOne (new Query (), Sample .class )).expectNext (data ).verifyComplete ();
462
462
}
463
463
464
+ @ Test // DATAMONGO-1774
465
+ public void removeWithEmptyMonoShouldDoNothing () {
466
+
467
+ Sample spring = new Sample ("100" , "spring" );
468
+ Sample data = new Sample ("200" , "data" );
469
+ Sample mongodb = new Sample ("300" , "mongodb" );
470
+
471
+ StepVerifier .create (template .insert (Arrays .asList (spring , data , mongodb ), Sample .class )) //
472
+ .expectNextCount (3 ) //
473
+ .verifyComplete ();
474
+
475
+ StepVerifier .create (template .remove (Mono .empty ())).verifyComplete ();
476
+ StepVerifier .create (template .count (new Query (), Sample .class )).expectNext (3L ).verifyComplete ();
477
+ }
478
+
479
+ @ Test // DATAMONGO-1774
480
+ public void removeWithMonoShouldDeleteElement () {
481
+
482
+ Sample spring = new Sample ("100" , "spring" );
483
+ Sample data = new Sample ("200" , "data" );
484
+ Sample mongodb = new Sample ("300" , "mongodb" );
485
+
486
+ StepVerifier .create (template .insert (Arrays .asList (spring , data , mongodb ), Sample .class )) //
487
+ .expectNextCount (3 ) //
488
+ .verifyComplete ();
489
+
490
+ StepVerifier .create (template .remove (Mono .just (spring ))).expectNextCount (1 ).verifyComplete ();
491
+ StepVerifier .create (template .count (new Query (), Sample .class )).expectNext (2L ).verifyComplete ();
492
+ }
493
+
494
+ @ Test // DATAMONGO-1774
495
+ public void removeWithMonoAndCollectionShouldDeleteElement () {
496
+
497
+ Sample spring = new Sample ("100" , "spring" );
498
+ Sample data = new Sample ("200" , "data" );
499
+ Sample mongodb = new Sample ("300" , "mongodb" );
500
+
501
+ StepVerifier .create (template .insert (Arrays .asList (spring , data , mongodb ), Sample .class )) //
502
+ .expectNextCount (3 ) //
503
+ .verifyComplete ();
504
+
505
+ StepVerifier .create (template .remove (Mono .just (spring ), template .determineCollectionName (Sample .class )))
506
+ .expectNextCount (1 ).verifyComplete ();
507
+ StepVerifier .create (template .count (new Query (), Sample .class )).expectNext (2L ).verifyComplete ();
508
+ }
509
+
464
510
@ Test // DATAMONGO-1444
465
511
public void optimisticLockingHandling () {
466
512
0 commit comments