I just wrote some unit tests to verify if I configured the JsonSerializerRegistry
correctly but I surprisingly get the following error messages with the code shown below:
Vector(class scala.collection.immutable.Map$Map1 is not serializable, Missing play-json serializer for [scala.collection.immutable.Map$Map1], class scala.collection.immutable.Map$EmptyMap$ is not serializable, Missing play-json serializer for [scala.collection.immutable.Map$EmptyMap$]) had size 2 instead of expected size 0
Vector(class scala.collection.immutable.Nil$ is not serializable, Missing play-json serializer for [scala.collection.immutable.Nil$]) had size 1 instead of expected size 0
// json serializers for UserId and CartId case classes not shown
case object GetAllMapping extends MappingCommand[Map[UserId, CartId]] {
implicit val format: Format[GetAllMapping.type] = Json.format
implicit val mapFormat: Format[Map[UserId, CartId]] = new MapFormat[UserId, CartId]()
}
case object GetExpiredCarts extends MappingCommand[Iterable[CartId]] {
implicit val format: Format[GetExpiredCarts.type] = Json.format
}
object MappingSerializerRegistry extends JsonSerializerRegistry {
import eventworld.cart.api.JsonCartDtoSerializers._
override def serializers: immutable.Seq[JsonSerializer[_]] = immutable.Seq(
JsonSerializer[cmd.GetAllMapping.type],
JsonSerializer[Map[UserId, CartId]](cmd.GetAllMapping.mapFormat),
JsonSerializer[cmd.GetExpiredCarts.type],
JsonSerializer[Iterable[CartId]]
)
}
edit: The test code is very simple, it just sends the Commands and receives either empty replies or replies with just one item in the Iterable or Map.
I expected that lagom or play already comes with serializers for this standard library types.
How am I supposed to configure those?