Skip to content

Commit c4ab59a

Browse files
committed
Test fixes: Work in pre Java 1.8 and typo fix
1 parent a0134e1 commit c4ab59a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

bson/src/test/scala/org/mongodb/scala/bson/collections/MutableDocumentSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class MutableDocumentSpec extends FlatSpec with Matchers {
311311
doc1 should equal(Document("key" -> BsonString("value")))
312312
}
313313

314-
it should "support clearn" in {
314+
it should "support clear" in {
315315
val doc1: Document = Document("key" -> BsonString("value"), "key2" -> BsonString("value2"))
316316

317317
doc1.clear()

driver/src/it/scala/org/mongodb/scala/CrudSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ class CrudSpec extends RequiresMongoDBISpec {
194194
private def doInsertOne(arguments: BsonDocument): BsonValue = {
195195
val document = arguments.getDocument("document")
196196
collection.get.insertOne(document).futureValue
197-
Document(("insertedId", document.getOrDefault("_id", BsonNull()))).underlying
197+
Document(("insertedId", Option(document.get("_id")).getOrElse(BsonNull()))).underlying
198198
}
199199

200200
private def doInsertMany(arguments: BsonDocument): BsonValue = {
201201
val documents = arguments.getArray("documents").asScala.map(_.asDocument())
202202
collection.get.insertMany(documents).futureValue
203-
Document(("insertedIds", documents.map(_.getOrDefault("_id", BsonNull())))).underlying
203+
Document(("insertedIds", documents.map(doc => Option(doc.get("_id")).getOrElse(BsonNull())))).underlying
204204
}
205205

206206
private def doReplaceOne(arguments: BsonDocument): BsonValue = {

0 commit comments

Comments
 (0)