diff --git a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/MongoShellConverter.kt b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/MongoShellConverter.kt index 39cbdda7ee..5892e08a37 100644 --- a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/MongoShellConverter.kt +++ b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/MongoShellConverter.kt @@ -6,6 +6,7 @@ import com.mongodb.mongosh.result.* import com.mongodb.mongosh.service.Either import com.mongodb.mongosh.service.Left import com.mongodb.mongosh.service.Right +import org.bson.BsonTimestamp import org.bson.Document import org.bson.json.JsonReader import org.bson.types.* @@ -22,11 +23,22 @@ internal class MongoShellConverter(private val context: MongoShellContext, priva fun toJs(o: Any?): Any? { return when (o) { - is Iterable<*> -> toJs(o) - is Array<*> -> toJs(o) - is Map<*, *> -> toJs(o) - Unit -> context.eval("undefined") - else -> o + is Iterable<*> -> toJs(o) + is Array<*> -> toJs(o) + is Map<*, *> -> toJs(o) + is Unit -> context.eval("undefined") + is MaxKey -> bsonTypes.maxKey.newInstance() + is MinKey -> bsonTypes.minKey.newInstance() + is Binary -> bsonTypes.binData.newInstance(toJs(o.data), o.type) + is Symbol -> bsonTypes.bsonSymbol.newInstance(o.symbol) + is Decimal128 -> bsonTypes.numberDecimal.newInstance(o.bigDecimalValue().toPlainString()) + is Long -> bsonTypes.numberLong.newInstance(o.toString()) + is Int -> bsonTypes.numberInt.newInstance(o.toString()) + is BsonTimestamp -> bsonTypes.timestamp.newInstance(o.inc, o.time) + is CodeWithScope -> bsonTypes.code.newInstance(o.code, toJs(o.scope)) + is Code -> bsonTypes.code.newInstance(o.code) + is DBRef -> bsonTypes.dbRef.newInstance(o.collectionName, toJs(o.id), o.databaseName) + else -> o } } @@ -47,6 +59,14 @@ internal class MongoShellConverter(private val context: MongoShellContext, priva return array } + private fun toJs(array: ByteArray): Value { + val jsArray = context.eval("[]") + array.forEachIndexed { index, v -> + jsArray.setArrayElement(index.toLong(), v) + } + return jsArray + } + private fun toJs(list: Array<*>): Value { val array = context.eval("[]") list.forEachIndexed { index, v -> @@ -96,25 +116,26 @@ internal class MongoShellConverter(private val context: MongoShellContext, priva // document with aggregation explain result also has type AggregationCursor, so we need to make sure that value contains cursor type == "AggregationCursor" && v.hasMember("_cursor") -> CursorResult(Cursor(v, this)) type == "InsertOneResult" -> InsertOneResult(v["acknowledged"]!!.asBoolean(), v["insertedId"]!!.asString()) - type == "DeleteResult" -> DeleteResult(v["acknowledged"]!!.asBoolean(), v["deletedCount"]!!.asLong()) + type == "DeleteResult" -> DeleteResult(v["acknowledged"]!!.asBoolean(), (toJava(v["deletedCount"]!!) as LongResult).value) type == "UpdateResult" -> { val res = if (v["acknowledged"]!!.asBoolean()) { UpdateResult.acknowledged( - v["matchedCount"]!!.asLong(), - v["modifiedCount"]!!.asLong(), - null + (toJava(v["matchedCount"]!!) as LongResult).value, + (toJava(v["modifiedCount"]!!) as LongResult).value, + null ) } else UpdateResult.unacknowledged() MongoShellUpdateResult(res) } type == "BulkWriteResult" -> BulkWriteResult( - v["acknowledged"]!!.asBoolean(), - v["insertedCount"]!!.asLong(), - v["matchedCount"]!!.asLong(), - v["modifiedCount"]!!.asLong(), - v["deletedCount"]!!.asLong(), - v["upsertedCount"]!!.asLong(), - (toJava(v["upsertedIds"]!!) as ArrayResult).value) + v["acknowledged"]!!.asBoolean(), + (toJava(v["insertedCount"]!!) as IntResult).value, + (toJava(v["matchedCount"]!!) as IntResult).value, + (toJava(v["modifiedCount"]!!) as IntResult).value, + (toJava(v["deletedCount"]!!) as IntResult).value, + (toJava(v["upsertedCount"]!!) as IntResult).value, + (toJava(v["upsertedIds"]!!) as ArrayResult).value + ) type == "InsertManyResult" -> InsertManyResult(v["acknowledged"]!!.asBoolean(), toJava(v["insertedIds"]!!).value as List) v.instanceOf(context, "RegExp") -> { val pattern = v["source"]!!.asString() @@ -143,7 +164,7 @@ internal class MongoShellConverter(private val context: MongoShellContext, priva v.instanceOf(context, bsonTypes.dbRef) -> { val databaseName = v["db"]?.let { if (it.isNull) null else it }?.asString() val collectionName = v["collection"]!!.asString() - val value = toJava(v["oid"]!!).value + val value = toJava(v["oid"]!!).value!! DBRefResult(DBRef(databaseName, collectionName, value)) } v.instanceOf(context, bsonTypes.numberLong) -> LongResult(JsonReader(v.invokeMember("toExtendedJSON").toString()).readInt64()) diff --git a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/result/MongoShellResult.kt b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/result/MongoShellResult.kt index 3fe075648e..26d5a495be 100644 --- a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/result/MongoShellResult.kt +++ b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/result/MongoShellResult.kt @@ -111,11 +111,11 @@ class DeleteResult(val acknowledged: Boolean, val deletedCount: Long) : MongoShe } class BulkWriteResult(val acknowledged: Boolean, - val insertedCount: Long, - val matchedCount: Long, - val modifiedCount: Long, - val deletedCount: Long, - val upsertedCount: Long, + val insertedCount: Int, + val matchedCount: Int, + val modifiedCount: Int, + val deletedCount: Int, + val upsertedCount: Int, val upsertedIds: List) : MongoShellResult>() { override val value: Map get() = mapOf("acknowledged" to acknowledged, diff --git a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/Cursor.kt b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/Cursor.kt index 3a97bfd7f6..0fe119bcab 100644 --- a/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/Cursor.kt +++ b/packages/java-shell/src/main/kotlin/com/mongodb/mongosh/service/Cursor.kt @@ -191,22 +191,14 @@ internal class Cursor(private var helper: BaseMongoIterableHelper<*>, private va @HostAccess.Export override fun next(): Any? { - /* findOne returns single document as a result. - * Mongosh core will try to defineProperty on it and fail if value is not wrapped in JS object */ - val shouldWrap = iterator == null && helper.limit() == 1 val value = getOrCreateIterator().next() - return if (shouldWrap) wrapper.wrap(value) // it's possibly a findOne call - else value + return converter.toJs(value) } @HostAccess.Export override fun tryNext(): Any? { - /* findOne returns single document as a result. - * Mongosh core will try to defineProperty on it and fail if value is not wrapped in JS object */ - val shouldWrap = iterator == null && helper.limit() == 1 val value = getOrCreateIterator().tryNext() - return if (shouldWrap) wrapper.wrap(value) // it's possibly a findOne call - else value + return converter.toJs(value) } @HostAccess.Export diff --git a/packages/java-shell/src/test/resources/collection/insertOne.expected.txt b/packages/java-shell/src/test/resources/collection/insertOne.expected.txt index 2e980a0abe..cb5bc7b87f 100644 --- a/packages/java-shell/src/test/resources/collection/insertOne.expected.txt +++ b/packages/java-shell/src/test/resources/collection/insertOne.expected.txt @@ -1,3 +1,3 @@ { "acknowledged": true, "insertedId": "UNKNOWN" } true -[ { "_id": , "a": 1, "objectId": , "maxKey": {"$maxKey": 1}, "minKey": {"$minKey": 1}, "binData": {"$binary": {"base64": "MTIzNA==", "subType": "10"}}, "date": {"$date": {"$numberLong": "1355875200000"}}, "isoDate": {"$date": {"$numberLong": "1355875200000"}}, "numberInt": 24, "timestamp": Timestamp{value=429496729600, seconds=100, inc=0}, "undefined": null, "null": null, "uuid": } ] \ No newline at end of file +[ { "_id": , "a": 1, "objectId": , "maxKey": {"$maxKey": 1}, "minKey": {"$minKey": 1}, "binData": {"$binary": {"base64": "MTIzNA==", "subType": "10"}}, "date": {"$date": {"$numberLong": "1355875200000"}}, "isoDate": {"$date": {"$numberLong": "1355875200000"}}, "numberInt": 24, "timestamp": {"$timestamp": {"t": 100, "i": 0}}, "undefined": null, "null": null, "uuid": } ] diff --git a/packages/java-shell/src/test/resources/cursor/next.expected.txt b/packages/java-shell/src/test/resources/cursor/next.expected.txt index a227c198b6..f195b670fb 100644 --- a/packages/java-shell/src/test/resources/cursor/next.expected.txt +++ b/packages/java-shell/src/test/resources/cursor/next.expected.txt @@ -1 +1,2 @@ -{ "_id": , "name": "value1", "v": 1 } \ No newline at end of file +{ "_id": , "name": "value1", "v": 1 } +value1 diff --git a/packages/java-shell/src/test/resources/cursor/next.js b/packages/java-shell/src/test/resources/cursor/next.js index 4ee77d174f..015dde78e6 100644 --- a/packages/java-shell/src/test/resources/cursor/next.js +++ b/packages/java-shell/src/test/resources/cursor/next.js @@ -5,5 +5,7 @@ db.coll.insertOne({name: "value2", v: 2}); db.coll.insertOne({name: "value2", v: 3}); // command db.coll.find().next(); +// command +db.coll.find().next().name; // clear db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/BSONSymbol.expected.txt b/packages/java-shell/src/test/resources/literal/BSONSymbol.expected.txt index 92c85486dd..b5eec6adda 100644 --- a/packages/java-shell/src/test/resources/literal/BSONSymbol.expected.txt +++ b/packages/java-shell/src/test/resources/literal/BSONSymbol.expected.txt @@ -1,2 +1,3 @@ SymbolResult: a -SymbolResult: b \ No newline at end of file +SymbolResult: b +SymbolResult: c diff --git a/packages/java-shell/src/test/resources/literal/BSONSymbol.js b/packages/java-shell/src/test/resources/literal/BSONSymbol.js index c7c5fc3d81..a646f1a467 100644 --- a/packages/java-shell/src/test/resources/literal/BSONSymbol.js +++ b/packages/java-shell/src/test/resources/literal/BSONSymbol.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new BSONSymbol('c')}); // command checkResultClass BSONSymbol('a') // command checkResultClass -new BSONSymbol('b') \ No newline at end of file +new BSONSymbol('b') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); diff --git a/packages/java-shell/src/test/resources/literal/BinData.expected.txt b/packages/java-shell/src/test/resources/literal/BinData.expected.txt index 8bceaf500d..33608aa466 100644 --- a/packages/java-shell/src/test/resources/literal/BinData.expected.txt +++ b/packages/java-shell/src/test/resources/literal/BinData.expected.txt @@ -1,3 +1,4 @@ BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} -BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "04"}} \ No newline at end of file +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "04"}} +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} diff --git a/packages/java-shell/src/test/resources/literal/BinData.js b/packages/java-shell/src/test/resources/literal/BinData.js index 7780ff6ba3..c24e287ba4 100644 --- a/packages/java-shell/src/test/resources/literal/BinData.js +++ b/packages/java-shell/src/test/resources/literal/BinData.js @@ -1,6 +1,12 @@ +// before +db.coll.insertOne({"_id": 1, v: new BinData(16, 'MTIzNA==')}) // command checkResultClass new BinData(16, 'MTIzNA==') // command checkResultClass BinData(16, 'MTIzNA==') // command checkResultClass -new BinData(4, 'MTIzNA==') \ No newline at end of file +new BinData(4, 'MTIzNA==') +// command checkResultClass +db.coll.find().toArray()[0].v +// clear +db.coll.drop() \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/Code.expected.txt b/packages/java-shell/src/test/resources/literal/Code.expected.txt index 06fdd1ca31..0ff9fadb38 100644 --- a/packages/java-shell/src/test/resources/literal/Code.expected.txt +++ b/packages/java-shell/src/test/resources/literal/Code.expected.txt @@ -1,2 +1,3 @@ CodeWithScopeResult: {"$code": "code"} -CodeResult: {"$code": "code"} \ No newline at end of file +CodeResult: {"$code": "code"} +CodeWithScopeResult: {"$code": "code"} diff --git a/packages/java-shell/src/test/resources/literal/Code.js b/packages/java-shell/src/test/resources/literal/Code.js index 19f9b0da43..ee73f85552 100644 --- a/packages/java-shell/src/test/resources/literal/Code.js +++ b/packages/java-shell/src/test/resources/literal/Code.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: Code('code', { k: 'v' })}); // command checkResultClass Code('code', { k: 'v' }) // command checkResultClass Code('code') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); diff --git a/packages/java-shell/src/test/resources/literal/DBRef.expected.txt b/packages/java-shell/src/test/resources/literal/DBRef.expected.txt index 7b1bcc511e..d4063cdbd1 100644 --- a/packages/java-shell/src/test/resources/literal/DBRef.expected.txt +++ b/packages/java-shell/src/test/resources/literal/DBRef.expected.txt @@ -1 +1,2 @@ -DBRefResult: { "$ref" : "namespace", "$id" : "oid" } \ No newline at end of file +DBRefResult: { "$ref" : "namespace", "$id" : "oid" } +DBRefResult: { "$ref" : "namespace", "$id" : "oid" } diff --git a/packages/java-shell/src/test/resources/literal/DBRef.js b/packages/java-shell/src/test/resources/literal/DBRef.js index 2def87c99b..4a61b02180 100644 --- a/packages/java-shell/src/test/resources/literal/DBRef.js +++ b/packages/java-shell/src/test/resources/literal/DBRef.js @@ -1,2 +1,8 @@ +// before +db.coll.insertOne({"_id": 1, v: new DBRef('namespace', 'oid')}); // command checkResultClass -new DBRef('namespace', 'oid') \ No newline at end of file +new DBRef('namespace', 'oid') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/Date.expected.txt b/packages/java-shell/src/test/resources/literal/Date.expected.txt index d0f10fb536..43cc822291 100644 --- a/packages/java-shell/src/test/resources/literal/Date.expected.txt +++ b/packages/java-shell/src/test/resources/literal/Date.expected.txt @@ -8,4 +8,5 @@ DateResult: {"$date": {"$numberLong": "1355896877171"}} DateResult: {"$date": {"$numberLong": "1355875200000"}} StringResult java.lang.IllegalArgumentException: Expected number or string. Got: {} (Document{{}}) -LongResult: 1355875200000 \ No newline at end of file +LongResult: 1355875200000 +DateResult: {"$date": {"$numberLong": "1355875200000"}} diff --git a/packages/java-shell/src/test/resources/literal/Date.js b/packages/java-shell/src/test/resources/literal/Date.js index 173b25563a..3d1e771f11 100644 --- a/packages/java-shell/src/test/resources/literal/Date.js +++ b/packages/java-shell/src/test/resources/literal/Date.js @@ -1,3 +1,5 @@ +// before +db.coll.insertOne({"_id": 1, v: new Date("2012-12-19")}); // command dontCheckValue new Date() // command dontCheckValue @@ -19,4 +21,8 @@ Date("2012-12-19") // command checkResultClass new Date({}) // command checkResultClass -new Date("2012-12-19").getTime() \ No newline at end of file +new Date("2012-12-19").getTime() +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/HexData.expected.txt b/packages/java-shell/src/test/resources/literal/HexData.expected.txt index 25cd0b2caf..a9883b976f 100644 --- a/packages/java-shell/src/test/resources/literal/HexData.expected.txt +++ b/packages/java-shell/src/test/resources/literal/HexData.expected.txt @@ -1,2 +1,3 @@ BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} -BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} \ No newline at end of file +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "10"}} diff --git a/packages/java-shell/src/test/resources/literal/HexData.js b/packages/java-shell/src/test/resources/literal/HexData.js index d97929ffc0..33cc59cf1c 100644 --- a/packages/java-shell/src/test/resources/literal/HexData.js +++ b/packages/java-shell/src/test/resources/literal/HexData.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new HexData(16, '31323334')}); // command checkResultClass new HexData(16, '31323334') // command checkResultClass HexData(16, '31323334') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); diff --git a/packages/java-shell/src/test/resources/literal/ISODate.expected.txt b/packages/java-shell/src/test/resources/literal/ISODate.expected.txt index 8ec0dbaa63..edee06ad0f 100644 --- a/packages/java-shell/src/test/resources/literal/ISODate.expected.txt +++ b/packages/java-shell/src/test/resources/literal/ISODate.expected.txt @@ -11,4 +11,5 @@ DateResult: {"$date": {"$numberLong": "1355875200000"}} DateResult: {"$date": {"$numberLong": "1355875200000"}} DateResult: {"$date": {"$numberLong": "1355925905000"}} DateResult: {"$date": {"$numberLong": "1355925905000"}} -DateResult: {"$date": {"$numberLong": "1355925905000"}} \ No newline at end of file +DateResult: {"$date": {"$numberLong": "1355925905000"}} +DateResult: {"$date": {"$numberLong": "1355925905000"}} diff --git a/packages/java-shell/src/test/resources/literal/ISODate.js b/packages/java-shell/src/test/resources/literal/ISODate.js index d3bf7cb564..2a60a1b379 100644 --- a/packages/java-shell/src/test/resources/literal/ISODate.js +++ b/packages/java-shell/src/test/resources/literal/ISODate.js @@ -1,3 +1,5 @@ +// before +db.coll.insertOne({"_id": 1, v: new ISODate('2012-12-19T140505')}); // command dontCheckValue ISODate() // command dontCheckValue @@ -25,4 +27,8 @@ ISODate('20121219T14:05:05') // command checkResultClass ISODate('20121219T140505') // command checkResultClass -ISODate('2012-12-19T140505') \ No newline at end of file +ISODate('2012-12-19T140505') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/MD5.expected.txt b/packages/java-shell/src/test/resources/literal/MD5.expected.txt index 2c67638546..4a6b33b2bd 100644 --- a/packages/java-shell/src/test/resources/literal/MD5.expected.txt +++ b/packages/java-shell/src/test/resources/literal/MD5.expected.txt @@ -1,2 +1,3 @@ BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "05"}} -BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "05"}} \ No newline at end of file +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "05"}} +BinaryResult: {"$binary": {"base64": "MTIzNA==", "subType": "05"}} diff --git a/packages/java-shell/src/test/resources/literal/MD5.js b/packages/java-shell/src/test/resources/literal/MD5.js index 89aee60b3e..a537cfe11c 100644 --- a/packages/java-shell/src/test/resources/literal/MD5.js +++ b/packages/java-shell/src/test/resources/literal/MD5.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new MD5('31323334')}); // command checkResultClass new MD5('31323334') // command checkResultClass -MD5('31323334') \ No newline at end of file +MD5('31323334') +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/MaxKey.expected.txt b/packages/java-shell/src/test/resources/literal/MaxKey.expected.txt index a8b57b52c7..cb05703249 100644 --- a/packages/java-shell/src/test/resources/literal/MaxKey.expected.txt +++ b/packages/java-shell/src/test/resources/literal/MaxKey.expected.txt @@ -1,2 +1,3 @@ MaxKeyResult: {"$maxKey": 1} -MaxKeyResult: {"$maxKey": 1} \ No newline at end of file +MaxKeyResult: {"$maxKey": 1} +MaxKeyResult: {"$maxKey": 1} diff --git a/packages/java-shell/src/test/resources/literal/MaxKey.js b/packages/java-shell/src/test/resources/literal/MaxKey.js index 56900819e6..2bc0a2a8cb 100644 --- a/packages/java-shell/src/test/resources/literal/MaxKey.js +++ b/packages/java-shell/src/test/resources/literal/MaxKey.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new MaxKey()}); // command checkResultClass new MaxKey(); // command checkResultClass -MaxKey() \ No newline at end of file +MaxKey() +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/MinKey.expected.txt b/packages/java-shell/src/test/resources/literal/MinKey.expected.txt index 88315ff42c..0847b1a951 100644 --- a/packages/java-shell/src/test/resources/literal/MinKey.expected.txt +++ b/packages/java-shell/src/test/resources/literal/MinKey.expected.txt @@ -1,2 +1,3 @@ MinKeyResult: {"$minKey": 1} -MinKeyResult: {"$minKey": 1} \ No newline at end of file +MinKeyResult: {"$minKey": 1} +MinKeyResult: {"$minKey": 1} diff --git a/packages/java-shell/src/test/resources/literal/MinKey.js b/packages/java-shell/src/test/resources/literal/MinKey.js index 155f63d327..aa0cde20c3 100644 --- a/packages/java-shell/src/test/resources/literal/MinKey.js +++ b/packages/java-shell/src/test/resources/literal/MinKey.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new MinKey()}); // command checkResultClass new MinKey(); // command checkResultClass -MinKey() \ No newline at end of file +MinKey() +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/NumberDecimal.expected.txt b/packages/java-shell/src/test/resources/literal/NumberDecimal.expected.txt index 5529d73ee5..f65fe99b35 100644 --- a/packages/java-shell/src/test/resources/literal/NumberDecimal.expected.txt +++ b/packages/java-shell/src/test/resources/literal/NumberDecimal.expected.txt @@ -1 +1,2 @@ -Decimal128Result: {"$numberDecimal": "24"} \ No newline at end of file +Decimal128Result: {"$numberDecimal": "24"} +Decimal128Result: {"$numberDecimal": "24"} diff --git a/packages/java-shell/src/test/resources/literal/NumberDecimal.js b/packages/java-shell/src/test/resources/literal/NumberDecimal.js index d243e7ecad..b39bf2a3df 100644 --- a/packages/java-shell/src/test/resources/literal/NumberDecimal.js +++ b/packages/java-shell/src/test/resources/literal/NumberDecimal.js @@ -1,2 +1,8 @@ +// before +db.coll.insertOne({"_id": 1, v: new NumberDecimal("24")}); // command checkResultClass -new NumberDecimal("24") \ No newline at end of file +new NumberDecimal("24") +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/NumberInt.expected.txt b/packages/java-shell/src/test/resources/literal/NumberInt.expected.txt index 22c568e192..e76b105aed 100644 --- a/packages/java-shell/src/test/resources/literal/NumberInt.expected.txt +++ b/packages/java-shell/src/test/resources/literal/NumberInt.expected.txt @@ -1,2 +1,3 @@ IntResult: 24 -IntResult: 24 \ No newline at end of file +IntResult: 24 +IntResult: 24 diff --git a/packages/java-shell/src/test/resources/literal/NumberInt.js b/packages/java-shell/src/test/resources/literal/NumberInt.js index 229405b3c5..85d3f6ca1f 100644 --- a/packages/java-shell/src/test/resources/literal/NumberInt.js +++ b/packages/java-shell/src/test/resources/literal/NumberInt.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new NumberInt("24")}); // command checkResultClass NumberInt("24") // command checkResultClass -new NumberInt("24") \ No newline at end of file +new NumberInt("24") +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/NumberLong.expected.txt b/packages/java-shell/src/test/resources/literal/NumberLong.expected.txt index f0aba22d49..ef02629c8f 100644 --- a/packages/java-shell/src/test/resources/literal/NumberLong.expected.txt +++ b/packages/java-shell/src/test/resources/literal/NumberLong.expected.txt @@ -1,2 +1,3 @@ LongResult: 24 -LongResult: 24 \ No newline at end of file +LongResult: 24 +LongResult: 24 diff --git a/packages/java-shell/src/test/resources/literal/NumberLong.js b/packages/java-shell/src/test/resources/literal/NumberLong.js index 37a496d0f4..d27f5596e4 100644 --- a/packages/java-shell/src/test/resources/literal/NumberLong.js +++ b/packages/java-shell/src/test/resources/literal/NumberLong.js @@ -1,4 +1,10 @@ +// before +db.coll.insertOne({"_id": 1, v: new NumberLong("24")}); // command checkResultClass NumberLong("24") // command checkResultClass -new NumberLong("24") \ No newline at end of file +new NumberLong("24") +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/ObjectId.expected.txt b/packages/java-shell/src/test/resources/literal/ObjectId.expected.txt index 4656441ebc..29bfe2371b 100644 --- a/packages/java-shell/src/test/resources/literal/ObjectId.expected.txt +++ b/packages/java-shell/src/test/resources/literal/ObjectId.expected.txt @@ -1,3 +1,4 @@ ObjectIdResult: 5ebaf064121756574a9767cf ObjectIdResult: 5ebaf064121756574a9767cf -ObjectIdResult: \ No newline at end of file +ObjectIdResult: +ObjectIdResult: 5ebaf064121756574a9767cf diff --git a/packages/java-shell/src/test/resources/literal/ObjectId.js b/packages/java-shell/src/test/resources/literal/ObjectId.js index 51dfd706b0..4ce8bdc5d1 100644 --- a/packages/java-shell/src/test/resources/literal/ObjectId.js +++ b/packages/java-shell/src/test/resources/literal/ObjectId.js @@ -1,6 +1,12 @@ +// before +db.coll.insertOne({"_id": 1, v: new ObjectId('5ebaf064121756574a9767cf')}); // command checkResultClass dontReplaceId new ObjectId('5ebaf064121756574a9767cf') // command checkResultClass dontReplaceId ObjectId('5ebaf064121756574a9767cf') // command checkResultClass -new ObjectId() \ No newline at end of file +new ObjectId() +// command checkResultClass dontReplaceId +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/Timestamp.expected.txt b/packages/java-shell/src/test/resources/literal/Timestamp.expected.txt index f3a4256bd1..e2771d9443 100644 --- a/packages/java-shell/src/test/resources/literal/Timestamp.expected.txt +++ b/packages/java-shell/src/test/resources/literal/Timestamp.expected.txt @@ -1 +1,2 @@ -BSONTimestampResult: {"$timestamp": {"t": 100, "i": 0}} \ No newline at end of file +BSONTimestampResult: {"$timestamp": {"t": 100, "i": 0}} +BSONTimestampResult: {"$timestamp": {"t": 100, "i": 0}} diff --git a/packages/java-shell/src/test/resources/literal/Timestamp.js b/packages/java-shell/src/test/resources/literal/Timestamp.js index 1c50b8e29e..0487080fec 100644 --- a/packages/java-shell/src/test/resources/literal/Timestamp.js +++ b/packages/java-shell/src/test/resources/literal/Timestamp.js @@ -1,2 +1,8 @@ +// before +db.coll.insertOne({"_id": 1, v: new Timestamp(100, 0)}); // command checkResultClass new Timestamp(100, 0) +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); diff --git a/packages/java-shell/src/test/resources/literal/UUID.expected.txt b/packages/java-shell/src/test/resources/literal/UUID.expected.txt index e0ed1ccf6d..50de327d23 100644 --- a/packages/java-shell/src/test/resources/literal/UUID.expected.txt +++ b/packages/java-shell/src/test/resources/literal/UUID.expected.txt @@ -1,3 +1,4 @@ UUIDResult: UUIDResult: -UUIDResult: \ No newline at end of file +UUIDResult: +UUIDResult: diff --git a/packages/java-shell/src/test/resources/literal/UUID.js b/packages/java-shell/src/test/resources/literal/UUID.js index a023d6de68..68e55efb65 100644 --- a/packages/java-shell/src/test/resources/literal/UUID.js +++ b/packages/java-shell/src/test/resources/literal/UUID.js @@ -1,6 +1,12 @@ +// before +db.coll.insertOne({"_id": 1, v: UUID('5220b418-8f7d-4cd9-bd27-35b6f8d990c5')}); // command checkResultClass new UUID('5220b418-8f7d-4cd9-bd27-35b6f8d990c5') // command checkResultClass UUID('5220b418-8f7d-4cd9-bd27-35b6f8d990c5') // command checkResultClass -new UUID() \ No newline at end of file +new UUID() +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); \ No newline at end of file diff --git a/packages/java-shell/src/test/resources/literal/array.expected.txt b/packages/java-shell/src/test/resources/literal/array.expected.txt index 55293d8934..87a42608ae 100644 --- a/packages/java-shell/src/test/resources/literal/array.expected.txt +++ b/packages/java-shell/src/test/resources/literal/array.expected.txt @@ -1 +1,2 @@ -ArrayResult: [ 1, 2, "hello \n world" ] \ No newline at end of file +ArrayResult: [ 1, 2, "hello \n world" ] +ArrayResult: [ 1, 2, "hello \n world" ] diff --git a/packages/java-shell/src/test/resources/literal/array.js b/packages/java-shell/src/test/resources/literal/array.js index 709bc21f2f..ad8fb7fcf8 100644 --- a/packages/java-shell/src/test/resources/literal/array.js +++ b/packages/java-shell/src/test/resources/literal/array.js @@ -1,2 +1,8 @@ +// before +db.coll.insertOne({"_id": 1, v: [1, 2, "hello \n world"]}); // command checkResultClass [1, 2, "hello \n world"] +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop(); diff --git a/packages/java-shell/src/test/resources/literal/bool.expected.txt b/packages/java-shell/src/test/resources/literal/bool.expected.txt index c952a1f9b9..da013dc615 100644 --- a/packages/java-shell/src/test/resources/literal/bool.expected.txt +++ b/packages/java-shell/src/test/resources/literal/bool.expected.txt @@ -1 +1,2 @@ -BooleanResult: true \ No newline at end of file +BooleanResult: true +BooleanResult: true diff --git a/packages/java-shell/src/test/resources/literal/bool.js b/packages/java-shell/src/test/resources/literal/bool.js index 165e5b70f2..f8b9aaacc0 100644 --- a/packages/java-shell/src/test/resources/literal/bool.js +++ b/packages/java-shell/src/test/resources/literal/bool.js @@ -1,2 +1,8 @@ +// before +db.coll.insertOne({"_id": 1, v: true}); // command checkResultClass true +// command checkResultClass +db.coll.find().toArray()[0].v; +// clear +db.coll.drop();