Skip to content

Commit ecc8e23

Browse files
committed
Make map and reduce functions more realistic in mapReduce collation test
The functions that were used exposed a subtle difference in server behavior that the test was not intending to exercise. This change ensures that the map and reduce functions will behave consistently on all server versions JAVA-3555
1 parent 84a80a6 commit ecc8e23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,17 +238,17 @@ class MapReduceWithInlineResultsOperationSpecification extends OperationFunction
238238
getCollectionHelper().insertDocuments(document)
239239
def operation = new MapReduceWithInlineResultsOperation<BsonDocument>(
240240
namespace,
241-
new BsonJavaScript('function(){ emit( this._id, this.str ); }'),
242-
new BsonJavaScript('function(key, values){ return key, values; }'),
241+
new BsonJavaScript('function(){ emit( this.str, 1 ); }'),
242+
new BsonJavaScript('function(key, values){ return Array.sum(values); }'),
243243
bsonDocumentCodec)
244244
.filter(BsonDocument.parse('{str: "FOO"}'))
245245
.collation(caseInsensitiveCollation)
246246

247247
when:
248-
def results = executeAndCollectBatchCursorResults(operation, async) as Set
248+
def results = executeAndCollectBatchCursorResults(operation, async)
249249

250250
then:
251-
results == [Document.parse('{_id: 1.0, value: "foo"}')]
251+
results == [new BsonDocument('_id', new BsonString('foo')).append('value', new BsonDouble(1))]
252252

253253
where:
254254
async << [true, false]

0 commit comments

Comments
 (0)