Skip to content
This repository has been archived by the owner on Jan 15, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into 0.0.8_2.9.0-1
Browse files Browse the repository at this point in the history
  • Loading branch information
rktoomey committed Jun 12, 2012
2 parents ee40e79 + 2e9c2b9 commit ccdb4c5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package com.novus.salat.test.json

import org.joda.time.DateTime
import org.bson.types.ObjectId
import com.novus.salat.annotations._

// A Adam
// B Bertil
Expand Down Expand Up @@ -70,11 +71,13 @@ case class David(m: Map[String, Int])
case class Erik(e: String)
case class Filip(m: Map[String, Erik])
case class Gustav(o: Option[String] = None)
@Salat
trait Helge {
val s: String
}
case class Ivar(s: String) extends Helge
case class Johan(s: String, d: Double) extends Helge
@Salat
abstract class Kalle(s: String)
case class Ludvig(s: String) extends Kalle(s)
case class Martin(s: String, d: Double) extends Kalle(s)
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,26 @@ class JsonSpec extends Specification with Logging {
}
}
"class hierarchies" in {
// TODO: sort out type hinting when concrete grater is accessed via proxy grater without @Salat annotation
"with a top-level trait" in {
val i = Ivar(s = "Hello")
val i_* = grater[Helge].toPrettyJSON(i)
println(i_*)
// i_* must /("_t" -> "com.novus.salat.test.json.Ivar")
i_* must /("_t" -> "com.novus.salat.test.json.Ivar")
i_* must /("s" -> "Hello")
val j = Johan(s = "Hello", d = 3.14)
val j_* = grater[Helge].toPrettyJSON(j)
// j_* must /("_t" -> "com.novus.salat.test.json.Johan")
j_* must /("_t" -> "com.novus.salat.test.json.Johan")
j_* must /("s" -> "Hello")
j_* must /("d" -> 3.14)
}
"with an abstract superclass" in {
val l = Ludvig(s = "Hello")
val l_* = grater[Kalle].toPrettyJSON(l)
// l_* must /("_t" -> "com.novus.salat.test.json.Ludvig")
l_* must /("_t" -> "com.novus.salat.test.json.Ludvig")
l_* must /("s" -> "Hello")
val m = Martin(s = "Hello", d = 3.14)
val m_* = grater[Kalle].toPrettyJSON(m)
// m_* must /("_t" -> "com.novus.salat.test.json.Martin")
m_* must /("_t" -> "com.novus.salat.test.json.Martin")
m_* must /("s" -> "Hello")
m_* must /("d" -> 3.14)
}
Expand All @@ -175,7 +175,7 @@ class JsonSpec extends Specification with Logging {
JField("b", JInt(99)) ::
JField("c", JDouble(3.14)) ::
JField("d", JBool(false)) ::
JField("e", JString(TestDateFormatter.print(testDate))) ::
JField("e", JString("2011-12-28T19:37:56.008Z")) ::
JField("u", JString(testURL.toString)) ::
JField("o", JObject(JField("$oid", JString("4fd0bead4ceab231e6f3220b")) :: Nil)) ::
Nil)
Expand Down Expand Up @@ -234,7 +234,7 @@ class JsonSpec extends Specification with Logging {
}
"strings" in {
"a string that can be parsed to JSON" in {
val adam = """{"a":"string","b":99,"c":3.14,"d":false,"e":"2011-12-28T14:37:56.008-05:00","u":"http://www.typesafe.com","o":{"$oid":"4fd0bead4ceab231e6f3220b"}}"""
val adam = """{"a":"string","b":99,"c":3.14,"d":false,"e":"2011-12-28T19:37:56.008Z","u":"http://www.typesafe.com","o":{"$oid":"4fd0bead4ceab231e6f3220b"}}"""
grater[Adam].fromJSON(adam) must_== a
grater[Bertil].fromJSON("""{"ints":[1,2,3],"strings":["a","b","c"]}""") must_== b
}
Expand Down

0 comments on commit ccdb4c5

Please sign in to comment.