Skip to content

Commit 785d221

Browse files
committed
Fix broken explain tests
JAVA-3909
1 parent c814e94 commit 785d221

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

driver-core/src/test/functional/com/mongodb/internal/operation/AggregateOperationSpecification.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
339339
async << [true, false]
340340
}
341341

342+
@IgnoreIf({ !serverVersionAtLeast(3, 6) })
342343
def 'should be able to explain an empty pipeline'() {
343344
given:
344345
def operation = new AggregateOperation(getNamespace(), [], new BsonDocumentCodec())
@@ -384,7 +385,7 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
384385

385386
when:
386387
execute(operation, async)
387-
BsonDocument explainPlan = execute(operation.asExplainableOperation(QUERY_PLANNER), async)
388+
BsonDocument explainPlan = execute(operation.asExplainableOperation(QUERY_PLANNER, new BsonDocumentCodec()), async)
388389

389390
then:
390391
getKeyPattern(explainPlan.getArray('stages').get(0).asDocument().getDocument('$cursor')) == index

driver-legacy/src/test/functional/com/mongodb/DBCollectionAggregationTest.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,10 @@ public List<DBObject> prepareData() {
106106

107107
@Test
108108
public void testExplain() {
109+
assumeTrue(serverVersionAtLeast(3, 6));
109110
List<DBObject> pipeline = new ArrayList<DBObject>(prepareData());
110-
pipeline.add(new BasicDBObject("$out", "aggCollection"));
111-
CommandResult out = collection.explainAggregate(pipeline, AggregationOptions.builder()
112-
.allowDiskUse(true)
113-
.build());
114-
assertTrue(out.keySet()
115-
.iterator()
116-
.hasNext());
111+
CommandResult out = collection.explainAggregate(pipeline, AggregationOptions.builder().build());
112+
assertTrue(out.keySet().iterator().hasNext());
117113
}
118114

119115
@Test(expected = IllegalArgumentException.class)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public void testExplainOfAggregateWithNewResponseStructure() {
124124
public void testExplainOfAggregateWithOldResponseStructure() {
125125
// Aggregate explain is supported on earlier versions, but the structure of the response on which we're asserting in this test
126126
// changed radically in 4.2. So here we just assert that we got a non-error respinse
127+
assumeTrue(serverVersionAtLeast(3, 6));
127128
assumeTrue(serverVersionLessThan(4, 2));
128129

129130
MongoCollection<BsonDocument> collection = client.getDatabase(getDefaultDatabaseName())

0 commit comments

Comments
 (0)