@@ -10,15 +10,16 @@ import org.apache.lucene.search.MatchAllDocsQuery
10
10
class DocumentIncludesSuite extends FunSuite with DocumentIncludes {
11
11
12
12
test(" mapToBson should convert Map to Bson" ) {
13
- val map = Map (" key" -> " value" )
13
+ val map = Map (" key" -> " value" )
14
14
val bson = mapToBson(map)
15
15
assert(bson.isInstanceOf [Document ])
16
+ assertEquals(bson.toBsonDocument.toJson(), " {\" key\" :\" value\" }" )
16
17
assertEquals(bson.asInstanceOf [Document ].getString(" key" ), " value" )
17
18
}
18
19
19
20
test(" luceneQueryBson should convert Lucene Query to Bson" ) {
20
21
val query = new MatchAllDocsQuery ()
21
- val bson = luceneQueryBson(query)
22
+ val bson = luceneQueryBson(query)
22
23
assert(bson.isInstanceOf [Document ])
23
24
}
24
25
@@ -27,55 +28,59 @@ class DocumentIncludesSuite extends FunSuite with DocumentIncludes {
27
28
javaMap.put(" key" , " value" )
28
29
val document = documentFromJavaMap(javaMap)
29
30
assert(document.isInstanceOf [Document ])
31
+ assertEquals(document.toBsonDocument.toJson(), " {\" key\" :\" value\" }" )
30
32
assertEquals(document.getString(" key" ), " value" )
31
33
}
32
34
33
35
test(" documentFromMutableMap should convert mutable.Map to Document" ) {
34
36
val mutableMap : collection.mutable.Map [String , Any ] = collection.mutable.Map (" key" -> " value" )
35
- val document = documentFromMutableMap(mutableMap)
37
+ val document = documentFromMutableMap(mutableMap)
36
38
assert(document.isInstanceOf [Document ])
39
+ assertEquals(document.toBsonDocument.toJson(), " {\" key\" :\" value\" }" )
37
40
assertEquals(document.getString(" key" ), " value" )
38
41
}
39
42
40
43
test(" documentFromScalaMap should convert Map to Document" ) {
41
- val map = Map (" key" -> " value" )
44
+ val map = Map (" key" -> " value" )
42
45
val document = documentFromScalaMap(map)
43
46
assert(document.isInstanceOf [Document ])
47
+ assertEquals(document.toBsonDocument.toJson(), " {\" key\" :\" value\" }" )
44
48
assertEquals(document.getString(" key" ), " value" )
45
49
}
46
50
47
51
test(" documentFromDocument should convert org.bson.Document to Document" ) {
48
- val bsonDoc = new org.bson.Document (" key" , " value" )
52
+ val bsonDoc = new org.bson.Document (" key" , " value" )
49
53
val document = documentFromDocument(bsonDoc)
50
54
assert(document.isInstanceOf [Document ])
55
+ assertEquals(document.toBsonDocument.toJson(), " {\" key\" :\" value\" }" )
51
56
assertEquals(document.getString(" key" ), " value" )
52
57
}
53
58
54
59
test(" mapFromDocument should convert Document to Map" ) {
55
60
val document = Document (" key" -> " value" )
56
- val map = mapFromDocument(document)
61
+ val map = mapFromDocument(document)
57
62
assert(map.isInstanceOf [Map [_, _]])
58
63
assertEquals(map(" key" ), " value" )
59
64
}
60
65
61
66
test(" mapListFromDocuments should convert List of Documents to List of Maps" ) {
62
67
val documents = List (Document (" key" -> " value" ))
63
- val mapList = mapListFromDocuments(documents)
68
+ val mapList = mapListFromDocuments(documents)
64
69
assert(mapList.isInstanceOf [List [_]])
65
70
assertEquals(mapList.head(" key" ), " value" )
66
71
}
67
72
68
73
test(" stringToObjectId should convert String to ObjectId" ) {
69
- val str = " 507f1f77bcf86cd799439011"
74
+ val str = " 507f1f77bcf86cd799439011"
70
75
val objectId = stringToObjectId(str)
71
76
assert(objectId.isInstanceOf [ObjectId ])
72
77
assertEquals(objectId.toHexString, str)
73
78
}
74
79
75
80
test(" documentToObjectId should extract ObjectId from Document" ) {
76
- val objectId = new ObjectId ()
77
- val document = Document (DatabaseProvider .ObjectIdKey -> objectId)
81
+ val objectId = new ObjectId ()
82
+ val document = Document (DatabaseProvider .ObjectIdKey -> objectId)
78
83
val extractedObjectId = documentToObjectId(document)
79
84
assertEquals(extractedObjectId, objectId)
80
85
}
81
- }
86
+ }
0 commit comments