diff options
author | Johannes Rudolph <johannes.rudolph@gmail.com> | 2013-05-29 12:22:48 +0200 |
---|---|---|
committer | Johannes Rudolph <johannes.rudolph@gmail.com> | 2013-05-29 12:22:48 +0200 |
commit | 94ab29ee4bf5fb7d9ba83a533dd8c02082bbd3e6 (patch) | |
tree | e64f426f1b244ca178a2047d1cd40664c127cdba /src/test/scala | |
parent | f12d95eda2783340c22441faf1dc86eb8e0fb3b2 (diff) | |
download | spray-json-94ab29ee4bf5fb7d9ba83a533dd8c02082bbd3e6.tar.gz spray-json-94ab29ee4bf5fb7d9ba83a533dd8c02082bbd3e6.tar.bz2 spray-json-94ab29ee4bf5fb7d9ba83a533dd8c02082bbd3e6.zip |
use sbt-boilerplate for generating stubs
(cherry picked from commit b4b2208d045fd7ee1549f56c2b9d897c5caceb48)
This allows to have jsonFormat for more than 15 case class parameters. Fixes #48
Conflicts:
build.sbt
project/plugins.sbt
src/main/boilerplate/cc/spray/json/ProductFormatsInstances.scala.template
Diffstat (limited to 'src/test/scala')
-rw-r--r-- | src/test/scala/spray/json/ProductFormatsSpec.scala | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/scala/spray/json/ProductFormatsSpec.scala b/src/test/scala/spray/json/ProductFormatsSpec.scala index 5a07b4f..af04505 100644 --- a/src/test/scala/spray/json/ProductFormatsSpec.scala +++ b/src/test/scala/spray/json/ProductFormatsSpec.scala @@ -87,6 +87,42 @@ class ProductFormatsSpec extends Specification { json.convertTo[Test3[Int, String]] mustEqual obj } } + "A JsonFormat for a case class with 18 parameters and created with `jsonFormat`" should { + object Test18Protocol extends DefaultJsonProtocol { + implicit val test18Format = jsonFormat18(Test18) + } + case class Test18( + a1: String, + a2: String, + a3: String, + a4: String, + a5: Int, + a6: String, + a7: String, + a8: String, + a9: String, + a10: String, + a11: String, + a12: Double, + a13: String, + a14: String, + a15: String, + a16: String, + a17: String, + a18: String) + + import Test18Protocol._ + val obj = Test18("a1", "a2", "a3", "a4", 5, "a6", "a7", "a8", "a9", + "a10", "a11", 12d, "a13", "a14", "a15", "a16", "a17", "a18") + + val json = JsonParser("""{"a1":"a1","a2":"a2","a3":"a3","a4":"a4","a5":5,"a6":"a6","a7":"a7","a8":"a8","a9":"a9","a10":"a10","a11":"a11","a12":12.0,"a13":"a13","a14":"a14","a15":"a15","a16":"a16","a17":"a17","a18":"a18"}""") + "convert to a respective JsObject" in { + obj.toJson mustEqual json + } + "convert a JsObject to the respective case class instance" in { + json.convertTo[Test18] mustEqual obj + } + } "A JsonFormat for a generic case class with an explicitly provided type parameter" should { "support the jsonFormat1 syntax" in { |