aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/ImplicitDerivedFormatTests.scala
blob: 9723cb043cbcee14725177bd5cc935a5fbfcb98e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package xyz.driver.json

import spray.json._

import org.scalatest._

class ImplicitDerivedFormatTests
    extends FlatSpec
    with FormatTests
    with ImplicitDerivedFormats
    with DefaultJsonProtocol {

  case class B(x: Int, b: String, mp: Map[String, Int])
  case class C(b: B)

  "Simple parameter product" should behave like checkRoundtrip(
    B(42, "Hello World", Map("a" -> 1, "b" -> -1024)),
    """{ "x": 42, "b": "Hello World", "mp": { "a": 1, "b": -1024 } }"""
  )

  "Nested parameter product with custom child format" should behave like checkRoundtrip(
    C(B(42, "Hello World", Map("a" -> 1, "b" -> -1024))),
    """{"b" :{ "x": 42, "b": "Hello World", "mp": { "a": 1, "b": -1024 } } }"""
  )

}