Skip to content

Commit aaf600c

Browse files
committed
Fix findOne support in JsonPoweredCrudTestHelper classes
1 parent 06b5441 commit aaf600c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

driver-async/src/test/functional/com/mongodb/async/client/JsonPoweredCrudTestHelper.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,19 @@ BsonDocument getDistinctResult(final BsonDocument collectionOptions, final BsonD
474474
@SuppressWarnings("deprecation")
475475
BsonDocument getFindOneResult(final BsonDocument collectionOptions, final BsonDocument arguments,
476476
@Nullable final ClientSession clientSession) {
477-
return getFindResult(collectionOptions, arguments, clientSession);
477+
FutureResultCallback<BsonDocument> futureResultCallback = new FutureResultCallback<BsonDocument>();
478+
createFindIterable(collectionOptions, arguments, clientSession).first(futureResultCallback);
479+
return toResult(futureResult(futureResultCallback));
478480
}
479481

480482
@SuppressWarnings("deprecation")
481483
BsonDocument getFindResult(final BsonDocument collectionOptions, final BsonDocument arguments,
482484
@Nullable final ClientSession clientSession) {
485+
return toResult(createFindIterable(collectionOptions, arguments, clientSession));
486+
}
487+
488+
private FindIterable<BsonDocument> createFindIterable(final BsonDocument collectionOptions, final BsonDocument arguments,
489+
@Nullable final ClientSession clientSession) {
483490
FindIterable<BsonDocument> iterable;
484491
if (clientSession == null) {
485492
iterable = getCollection(collectionOptions).find(arguments.getDocument("filter", new BsonDocument()));
@@ -505,7 +512,7 @@ BsonDocument getFindResult(final BsonDocument collectionOptions, final BsonDocum
505512
if (arguments.containsKey("collation")) {
506513
iterable.collation(getCollation(arguments.getDocument("collation")));
507514
}
508-
return toResult(iterable);
515+
return iterable;
509516
}
510517

511518
BsonDocument getMapReduceResult(final BsonDocument collectionOptions, final BsonDocument arguments,

driver-sync/src/test/functional/com/mongodb/client/JsonPoweredCrudTestHelper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,12 +449,17 @@ BsonDocument getDistinctResult(final BsonDocument collectionOptions, final BsonD
449449
@SuppressWarnings("deprecation")
450450
BsonDocument getFindOneResult(final BsonDocument collectionOptions, final BsonDocument arguments,
451451
@Nullable final ClientSession clientSession) {
452-
return getFindResult(collectionOptions, arguments, clientSession);
452+
return toResult(createFindIterable(collectionOptions, arguments, clientSession).first());
453453
}
454454

455455
@SuppressWarnings("deprecation")
456456
BsonDocument getFindResult(final BsonDocument collectionOptions, final BsonDocument arguments,
457457
@Nullable final ClientSession clientSession) {
458+
return toResult(createFindIterable(collectionOptions, arguments, clientSession));
459+
}
460+
461+
private FindIterable<BsonDocument> createFindIterable(final BsonDocument collectionOptions, final BsonDocument arguments,
462+
@Nullable final ClientSession clientSession) {
458463
FindIterable<BsonDocument> iterable;
459464
if (clientSession == null) {
460465
iterable = getCollection(collectionOptions).find(arguments.getDocument("filter", new BsonDocument()));
@@ -480,7 +485,7 @@ BsonDocument getFindResult(final BsonDocument collectionOptions, final BsonDocum
480485
if (arguments.containsKey("collation")) {
481486
iterable.collation(getCollation(arguments.getDocument("collation")));
482487
}
483-
return toResult(iterable);
488+
return iterable;
484489
}
485490

486491
BsonDocument getMapReduceResult(final BsonDocument collectionOptions, final BsonDocument arguments,

0 commit comments

Comments
 (0)