diff options
Diffstat (limited to 'src/test/scala/cc/spray/json')
6 files changed, 35 insertions, 35 deletions
diff --git a/src/test/scala/cc/spray/json/AdditionalFormatsSpec.scala b/src/test/scala/cc/spray/json/AdditionalFormatsSpec.scala index 7368128..0db3d5a 100644 --- a/src/test/scala/cc/spray/json/AdditionalFormatsSpec.scala +++ b/src/test/scala/cc/spray/json/AdditionalFormatsSpec.scala @@ -35,7 +35,7 @@ class AdditionalFormatsSpec extends Specification { "properly read a Container[Container[List[Int]]] from JSON" in { import ReaderProtocol._ - JsonParser("""{"content":{"content":[1,2,3]}}""").fromJson[Container[Container[List[Int]]]] mustEqual obj + JsonParser("""{"content":{"content":[1,2,3]}}""").convertTo[Container[Container[List[Int]]]] mustEqual obj } } }
\ No newline at end of file diff --git a/src/test/scala/cc/spray/json/BasicFormatsSpec.scala b/src/test/scala/cc/spray/json/BasicFormatsSpec.scala index 11576a4..6a8ecd3 100644 --- a/src/test/scala/cc/spray/json/BasicFormatsSpec.scala +++ b/src/test/scala/cc/spray/json/BasicFormatsSpec.scala @@ -9,7 +9,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 42.toJson mustEqual JsNumber(42) } "convert a JsNumber to an Int" in { - JsNumber(42).fromJson[Int] mustEqual 42 + JsNumber(42).convertTo[Int] mustEqual 42 } } @@ -18,7 +18,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 42L.toJson mustEqual JsNumber(42L) } "convert a JsNumber to a Long" in { - JsNumber(42L).fromJson[Long] mustEqual 42L + JsNumber(42L).convertTo[Long] mustEqual 42L } } @@ -36,7 +36,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { Float.NegativeInfinity.toJson mustEqual JsNull } "convert a JsNumber to a Float" in { - JsNumber(4.2f).fromJson[Float] mustEqual 4.2f + JsNumber(4.2f).convertTo[Float] mustEqual 4.2f } "convert a JsNull to a Float" in { JsNull.fromJson[Float].isNaN mustEqual Float.NaN.isNaN @@ -57,7 +57,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { Double.NegativeInfinity.toJson mustEqual JsNull } "convert a JsNumber to a Double" in { - JsNumber(4.2).fromJson[Double] mustEqual 4.2 + JsNumber(4.2).convertTo[Double] mustEqual 4.2 } "convert a JsNull to a Double" in { JsNull.fromJson[Double].isNaN mustEqual Double.NaN.isNaN @@ -69,7 +69,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 42.asInstanceOf[Byte].toJson mustEqual JsNumber(42) } "convert a JsNumber to a Byte" in { - JsNumber(42).fromJson[Byte] mustEqual 42 + JsNumber(42).convertTo[Byte] mustEqual 42 } } @@ -78,7 +78,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 42.asInstanceOf[Short].toJson mustEqual JsNumber(42) } "convert a JsNumber to a Short" in { - JsNumber(42).fromJson[Short] mustEqual 42 + JsNumber(42).convertTo[Short] mustEqual 42 } } @@ -87,7 +87,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { BigDecimal(42).toJson mustEqual JsNumber(42) } "convert a JsNumber to a BigDecimal" in { - JsNumber(42).fromJson[BigDecimal] mustEqual BigDecimal(42) + JsNumber(42).convertTo[BigDecimal] mustEqual BigDecimal(42) } } @@ -96,7 +96,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { BigInt(42).toJson mustEqual JsNumber(42) } "convert a JsNumber to a BigInt" in { - JsNumber(42).fromJson[BigInt] mustEqual BigInt(42) + JsNumber(42).convertTo[BigInt] mustEqual BigInt(42) } } @@ -105,15 +105,15 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { ().toJson mustEqual JsNumber(1) } "convert a JsNumber to Unit" in { - JsNumber(1).fromJson[Unit] mustEqual () + JsNumber(1).convertTo[Unit] mustEqual () } } "The BooleanJsonFormat" should { "convert true to a JsTrue" in { true.toJson mustEqual JsTrue } "convert false to a JsFalse" in { false.toJson mustEqual JsFalse } - "convert a JsTrue to true" in { JsTrue.fromJson[Boolean] mustEqual true } - "convert a JsFalse to false" in { JsFalse.fromJson[Boolean] mustEqual false } + "convert a JsTrue to true" in { JsTrue.convertTo[Boolean] mustEqual true } + "convert a JsFalse to false" in { JsFalse.convertTo[Boolean] mustEqual false } } "The CharJsonFormat" should { @@ -121,7 +121,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 'c'.toJson mustEqual JsString("c") } "convert a JsString to a Char" in { - JsString("c").fromJson[Char] mustEqual 'c' + JsString("c").convertTo[Char] mustEqual 'c' } } @@ -130,7 +130,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { "Hello".toJson mustEqual JsString("Hello") } "convert a JsString to a String" in { - JsString("Hello").fromJson[String] mustEqual "Hello" + JsString("Hello").convertTo[String] mustEqual "Hello" } } @@ -139,7 +139,7 @@ class BasicFormatsSpec extends Specification with DefaultJsonProtocol { 'Hello.toJson mustEqual JsString("Hello") } "convert a JsString to a Symbol" in { - JsString("Hello").fromJson[Symbol] mustEqual 'Hello + JsString("Hello").convertTo[Symbol] mustEqual 'Hello } } diff --git a/src/test/scala/cc/spray/json/CollectionFormatsSpec.scala b/src/test/scala/cc/spray/json/CollectionFormatsSpec.scala index d0cb509..009d2e2 100644 --- a/src/test/scala/cc/spray/json/CollectionFormatsSpec.scala +++ b/src/test/scala/cc/spray/json/CollectionFormatsSpec.scala @@ -12,7 +12,7 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { list.toJson mustEqual json } "convert a JsArray of JsNumbers to a List[Int]" in { - json.fromJson[List[Int]] mustEqual list + json.convertTo[List[Int]] mustEqual list } } @@ -23,7 +23,7 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { array.toJson mustEqual json } "convert a JsArray of JsNumbers to an Array[Int]" in { - Arrays.equals(json.fromJson[Array[Int]], array) must beTrue + Arrays.equals(json.convertTo[Array[Int]], array) must beTrue } } @@ -34,7 +34,7 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { map.toJson mustEqual json } "be able to convert a JsObject to a Map[String, Long]" in { - json.fromJson[Map[String, Long]] mustEqual map + json.convertTo[Map[String, Long]] mustEqual map } "throw an Exception when trying to serialize a map whose key are not serialized to JsStrings" in { Map(1 -> "a").toJson must throwA(new SerializationException("Map key must be formatted as JsString, not '1'")) @@ -48,7 +48,7 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { set.toJson mustEqual json } "convert a JsArray of JsNumbers to a Set[Int]" in { - json.fromJson[Set[Int]] mustEqual set + json.convertTo[Set[Int]] mustEqual set } } @@ -59,7 +59,7 @@ class CollectionFormatsSpec extends Specification with DefaultJsonProtocol { seq.toJson mustEqual json } "convert a JsArray of JsNumbers to a IndexedSeq[Int]" in { - json.fromJson[collection.IndexedSeq[Int]] mustEqual seq + json.convertTo[collection.IndexedSeq[Int]] mustEqual seq } } diff --git a/src/test/scala/cc/spray/json/ProductFormatsSpec.scala b/src/test/scala/cc/spray/json/ProductFormatsSpec.scala index 9a692ec..7c643e9 100644 --- a/src/test/scala/cc/spray/json/ProductFormatsSpec.scala +++ b/src/test/scala/cc/spray/json/ProductFormatsSpec.scala @@ -23,26 +23,26 @@ class ProductFormatsSpec extends Specification { obj.toJson mustEqual json } "convert a JsObject to the respective case class instance" in { - json.fromJson[Test2] mustEqual obj + json.convertTo[Test2] mustEqual obj } "throw a DeserializationException if the JsObject does not all required members" in ( - JsObject(JsField("b", 4.2)).fromJson[Test2] must + JsObject(JsField("b", 4.2)).convertTo[Test2] must throwA(new DeserializationException("Object is missing required member 'a'")) ) "not require the presence of optional fields for deserialization" in { - JsObject(JsField("a", 42)).fromJson[Test2] mustEqual Test2(42, None) + JsObject(JsField("a", 42)).convertTo[Test2] mustEqual Test2(42, None) } "not render `None` members during serialization" in { Test2(42, None).toJson mustEqual JsObject(JsField("a", 42)) } "ignore additional members during deserialization" in { - JsObject(JsField("a", 42), JsField("b", 4.2), JsField("c", 'no)).fromJson[Test2] mustEqual obj + JsObject(JsField("a", 42), JsField("b", 4.2), JsField("c", 'no)).convertTo[Test2] mustEqual obj } "not depend on any specific member order for deserialization" in { - JsObject(JsField("b", 4.2), JsField("a", 42)).fromJson[Test2] mustEqual obj + JsObject(JsField("b", 4.2), JsField("a", 42)).convertTo[Test2] mustEqual obj } "throw a DeserializationException if the JsValue is not a JsObject" in ( - JsNull.fromJson[Test2] must throwA(new DeserializationException("Object expected")) + JsNull.convertTo[Test2] must throwA(new DeserializationException("Object expected")) ) } @@ -64,7 +64,7 @@ class ProductFormatsSpec extends Specification { obj.toJson mustEqual json } "convert a JsObject to the respective case class instance" in { - json.fromJson[Test3[Int, String]] mustEqual obj + json.convertTo[Test3[Int, String]] mustEqual obj } } diff --git a/src/test/scala/cc/spray/json/ReadmeSpec.scala b/src/test/scala/cc/spray/json/ReadmeSpec.scala index 843d1fc..1a30d39 100644 --- a/src/test/scala/cc/spray/json/ReadmeSpec.scala +++ b/src/test/scala/cc/spray/json/ReadmeSpec.scala @@ -33,7 +33,7 @@ class ReadmeSpec extends Specification { import MyJsonProtocol._ val json = Color("CadetBlue", 95, 158, 160).toJson - val color = json.fromJson[Color] + val color = json.convertTo[Color] color mustEqual Color("CadetBlue", 95, 158, 160) } @@ -57,7 +57,7 @@ class ReadmeSpec extends Specification { import MyJsonProtocol._ val json = Color("CadetBlue", 95, 158, 160).toJson - val color = json.fromJson[Color] + val color = json.convertTo[Color] color mustEqual Color("CadetBlue", 95, 158, 160) } diff --git a/src/test/scala/cc/spray/json/StandardFormatsSpec.scala b/src/test/scala/cc/spray/json/StandardFormatsSpec.scala index ad9485c..f1aa5a5 100644 --- a/src/test/scala/cc/spray/json/StandardFormatsSpec.scala +++ b/src/test/scala/cc/spray/json/StandardFormatsSpec.scala @@ -10,13 +10,13 @@ class StandardFormatsSpec extends Specification with DefaultJsonProtocol { None.asInstanceOf[Option[Int]].toJson mustEqual JsNull } "convert JsNull to None" in { - JsNull.fromJson[Option[Int]] mustEqual None + JsNull.convertTo[Option[Int]] mustEqual None } "convert Some(Hello) to JsString(Hello)" in { Some("Hello").asInstanceOf[Option[String]].toJson mustEqual JsString("Hello") } "convert JsString(Hello) to Some(Hello)" in { - JsString("Hello").fromJson[Option[String]] mustEqual Some("Hello") + JsString("Hello").convertTo[Option[String]] mustEqual Some("Hello") } } @@ -31,10 +31,10 @@ class StandardFormatsSpec extends Specification with DefaultJsonProtocol { b.toJson mustEqual JsString("Hello") } "convert the left side of an Either value from Json" in { - JsNumber(42).fromJson[Either[Int, String]] mustEqual Left(42) + JsNumber(42).convertTo[Either[Int, String]] mustEqual Left(42) } "convert the right side of an Either value from Json" in { - JsString("Hello").fromJson[Either[Int, String]] mustEqual Right("Hello") + JsString("Hello").convertTo[Either[Int, String]] mustEqual Right("Hello") } } @@ -43,7 +43,7 @@ class StandardFormatsSpec extends Specification with DefaultJsonProtocol { Tuple1(42).toJson mustEqual JsNumber(42) } "be able to convert a JsNumber to a Tuple1[Int]" in { - JsNumber(42).fromJson[Tuple1[Int]] mustEqual Tuple1(42) + JsNumber(42).convertTo[Tuple1[Int]] mustEqual Tuple1(42) } } @@ -53,7 +53,7 @@ class StandardFormatsSpec extends Specification with DefaultJsonProtocol { (42, 4.2).toJson mustEqual json } "be able to convert a JsArray to a (Int, Double)]" in { - json.fromJson[(Int, Double)] mustEqual (42, 4.2) + json.convertTo[(Int, Double)] mustEqual (42, 4.2) } } |