DATAMONGO-1774 - Fix infinite loop in ReactiveMongoOperations#remove(Mono, String).
Original pull request: #498.
This commit is contained in:
committed by
Mark Paluch
parent
7cf69c5b1a
commit
d3d6242a16
@@ -1446,7 +1446,7 @@ public class ReactiveMongoTemplate implements ReactiveMongoOperations, Applicati
|
||||
*/
|
||||
@Override
|
||||
public Mono<DeleteResult> remove(Mono<? extends Object> objectToRemove, String collection) {
|
||||
return objectToRemove.flatMap(o -> remove(objectToRemove, collection));
|
||||
return objectToRemove.flatMap(it -> remove(it, collection));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -461,6 +461,52 @@ public class ReactiveMongoTemplateTests {
|
||||
StepVerifier.create(template.findOne(new Query(), Sample.class)).expectNext(data).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1774
|
||||
public void removeWithEmptyMonoShouldDoNothing() {
|
||||
|
||||
Sample spring = new Sample("100", "spring");
|
||||
Sample data = new Sample("200", "data");
|
||||
Sample mongodb = new Sample("300", "mongodb");
|
||||
|
||||
StepVerifier.create(template.insert(Arrays.asList(spring, data, mongodb), Sample.class)) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(template.remove(Mono.empty())).verifyComplete();
|
||||
StepVerifier.create(template.count(new Query(), Sample.class)).expectNext(3L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1774
|
||||
public void removeWithMonoShouldDeleteElement() {
|
||||
|
||||
Sample spring = new Sample("100", "spring");
|
||||
Sample data = new Sample("200", "data");
|
||||
Sample mongodb = new Sample("300", "mongodb");
|
||||
|
||||
StepVerifier.create(template.insert(Arrays.asList(spring, data, mongodb), Sample.class)) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(template.remove(Mono.just(spring))).expectNextCount(1).verifyComplete();
|
||||
StepVerifier.create(template.count(new Query(), Sample.class)).expectNext(2L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1774
|
||||
public void removeWithMonoAndCollectionShouldDeleteElement() {
|
||||
|
||||
Sample spring = new Sample("100", "spring");
|
||||
Sample data = new Sample("200", "data");
|
||||
Sample mongodb = new Sample("300", "mongodb");
|
||||
|
||||
StepVerifier.create(template.insert(Arrays.asList(spring, data, mongodb), Sample.class)) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(template.remove(Mono.just(spring), template.determineCollectionName(Sample.class)))
|
||||
.expectNextCount(1).verifyComplete();
|
||||
StepVerifier.create(template.count(new Query(), Sample.class)).expectNext(2L).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAMONGO-1444
|
||||
public void optimisticLockingHandling() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user