Skip to content

Commit c2d9b07

Browse files
committed
Add assertions.
JAVA-5530
1 parent b7c5bfa commit c2d9b07

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

driver-core/src/test/functional/com/mongodb/client/test/CollectionHelper.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,17 +357,17 @@ public void replaceOne(final Bson filter, final Bson update, final boolean isUps
357357
}
358358

359359
public void deleteOne(final Bson filter) {
360-
new MixedBulkWriteOperation(namespace,
361-
singletonList(new DeleteRequest(filter.toBsonDocument(Document.class, registry))),
362-
true, WriteConcern.ACKNOWLEDGED, false)
363-
.execute(getBinding());
360+
delete(filter, false);
364361
}
365362

366363
public void deleteMany(final Bson filter) {
364+
delete(filter, true);
365+
}
366+
367+
private void delete(final Bson filter, final boolean multi) {
367368
new MixedBulkWriteOperation(namespace,
368-
singletonList(new DeleteRequest(filter.toBsonDocument(Document.class, registry)).multi(true)),
369-
true, WriteConcern.ACKNOWLEDGED, false)
370-
.execute(getBinding());
369+
singletonList(new DeleteRequest(filter.toBsonDocument(Document.class, registry))),
370+
true, WriteConcern.ACKNOWLEDGED, false);
371371
}
372372

373373
public List<T> find(final Bson filter) {

driver-core/src/test/functional/com/mongodb/internal/operation/AsyncCommandBatchCursorFunctionalTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void shouldExhaustCursorAsyncWithMultipleBatches() {
133133

134134
int totalDocuments = resultBatches.stream().mapToInt(List::size).sum();
135135
assertEquals(10, totalDocuments, "Expected a total of 10 documents.");
136+
assertTrue(cursor.isClosed(), "Expected cursor to be closed.");
136137
});
137138
}
138139

@@ -190,8 +191,8 @@ void shouldExhaustCursorAsyncWithEmptyCursor() {
190191
// then
191192
assertDoesNotThrow(() -> {
192193
List<List<Document>> resultBatches = futureResult.get(5, TimeUnit.SECONDS);
193-
194194
assertTrue(resultBatches.isEmpty(), "Expected no batches for an empty cursor.");
195+
assertTrue(cursor.isClosed(), "Expected cursor to be closed.");
195196
});
196197
}
197198

driver-core/src/test/functional/com/mongodb/internal/operation/CommandBatchCursorFunctionalTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ void shouldExhaustCursorAsyncWithMultipleBatches() {
118118

119119
int totalDocuments = result.stream().mapToInt(List::size).sum();
120120
assertEquals(10, totalDocuments, "Expected a total of 10 documents.");
121+
assertTrue(cursor.isClosed(), "Expected cursor to be closed.");
121122
}
122123

123124
@Test
@@ -149,6 +150,7 @@ void shouldExhaustCursorAsyncWithEmptyCursor() {
149150

150151
// then
151152
assertTrue(result.isEmpty(), "Expected no batches for an empty cursor.");
153+
assertTrue(cursor.isClosed(), "Expected cursor to be closed.");
152154
}
153155

154156
@Test

0 commit comments

Comments
 (0)