I'm writing a BSONDocumentReader and would like to create a BSONDocument from a JSON string in my test to verify whether it correctly builds the CC.
So far I haven't found an easy way to do so, can anyone provide an example?
I'm writing a BSONDocumentReader and would like to create a BSONDocument from a JSON string in my test to verify whether it correctly builds the CC.
So far I haven't found an easy way to do so, can anyone provide an example?
Eventually I found the solution on SO, see this answer
import reactivemongo.play.json._
import play.modules.reactivemongo.json.collection._
val googleJs: JsObject = Json.parse(google).as[JsObject]
val googleBson: BSONDocument = BSONFormats.toBSON(googleJs).get.asInstanceOf[BSONDocument]
val maybeAddress = AddressReader read googleBson
maybeAddress shouldBe defined
// ... and so on...
Just make sure you have the play2-reactivemongo dependency