diff --git a/json/circe/src/test/scala/sttp/client4/circe/CirceTests.scala b/json/circe/src/test/scala/sttp/client4/circe/CirceTests.scala index bae5cf0bcb..26ca9d7dd5 100644 --- a/json/circe/src/test/scala/sttp/client4/circe/CirceTests.scala +++ b/json/circe/src/test/scala/sttp/client4/circe/CirceTests.scala @@ -107,11 +107,13 @@ class CirceTests extends AnyFlatSpec with Matchers with EitherValues { import sttp.model.Uri val jObject: JsonObject = JsonObject(("location", "hometown".asJson), ("bio", "Scala programmer".asJson)) - val result = basicRequest.get(Uri("http://example.org")).body(jObject).body.show + val request = basicRequest.get(Uri("http://example.org")).body(jObject) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } case class Inner(a: Int, b: Boolean, c: String) diff --git a/json/json4s/src/test/scala/sttp/client4/Json4sTests.scala b/json/json4s/src/test/scala/sttp/client4/Json4sTests.scala index a725c5f051..85642dd821 100644 --- a/json/json4s/src/test/scala/sttp/client4/Json4sTests.scala +++ b/json/json4s/src/test/scala/sttp/client4/Json4sTests.scala @@ -83,11 +83,13 @@ class Json4sTests extends AnyFlatSpec with Matchers with EitherValues { it should "serialize from JObject using implicit json4sBodySerializer" in { val jObject: JObject = JObject(JField("location", JString("hometown")), JField("bio", JString("Scala programmer"))) - val result = basicRequest.get(Uri("http://example.org")).body(jObject).body.show + val request = basicRequest.get(Uri("http://example.org")).body(jObject) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } def extractBody[T](request: PartialRequest[T]): String = diff --git a/json/jsoniter/src/test/scala/sttp/client4/jsoniter/JsoniterJsonTests.scala b/json/jsoniter/src/test/scala/sttp/client4/jsoniter/JsoniterJsonTests.scala index 26b037b65a..127d839cdf 100644 --- a/json/jsoniter/src/test/scala/sttp/client4/jsoniter/JsoniterJsonTests.scala +++ b/json/jsoniter/src/test/scala/sttp/client4/jsoniter/JsoniterJsonTests.scala @@ -83,11 +83,13 @@ class JsoniterJsonTests extends AnyFlatSpec with Matchers with EitherValues { it should "serialize from case class Person using implicit jsoniterBodySerializer" in { val person = Person("John") - val result = basicRequest.get(Uri("http://example.org")).body(person).body.show + val request = basicRequest.get(Uri("http://example.org")).body(person) - val expectedResult = "string: {\"name\":\"John\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } def extractBody[T](request: PartialRequest[T]): String = diff --git a/json/play-json/src/test/scala/sttp/client4/PlayJsonTests.scala b/json/play-json/src/test/scala/sttp/client4/PlayJsonTests.scala index 9a3915b1db..53d1476133 100644 --- a/json/play-json/src/test/scala/sttp/client4/PlayJsonTests.scala +++ b/json/play-json/src/test/scala/sttp/client4/PlayJsonTests.scala @@ -104,11 +104,13 @@ class PlayJsonTests extends AnyFlatSpec with Matchers with EitherValues { val fields: Seq[(String, JsValue)] = Seq[(String, JsValue)](("location", JsString("hometown")), ("bio", JsString("Scala programmer"))) val json: JsObject = JsObject(fields) - val result = basicRequest.get(Uri("http://example.org")).body(json).body.show + val request = basicRequest.get(Uri("http://example.org")).body(json) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } case class Inner(a: Int, b: Boolean, c: String) diff --git a/json/spray-json/src/test/scala/sttp/client4/SprayJsonTests.scala b/json/spray-json/src/test/scala/sttp/client4/SprayJsonTests.scala index af7ccf61a4..10caaee497 100644 --- a/json/spray-json/src/test/scala/sttp/client4/SprayJsonTests.scala +++ b/json/spray-json/src/test/scala/sttp/client4/SprayJsonTests.scala @@ -82,11 +82,13 @@ class SprayJsonTests extends AnyFlatSpec with Matchers with EitherValues { "location" -> "hometown".toJson, "bio" -> "Scala programmer".toJson ) - val result = basicRequest.get(Uri("http://example.org")).body(json).body.show + val request = basicRequest.get(Uri("http://example.org")).body(json) - val expectedResult = "string: {\"bio\":\"Scala programmer\",\"location\":\"hometown\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } def extractBody[T](request: PartialRequest[T]): String = diff --git a/json/upickle/src/test/scala/sttp/client4/upicklejson/UpickleTests.scala b/json/upickle/src/test/scala/sttp/client4/upicklejson/UpickleTests.scala index e96a12ed9f..3b55e94816 100644 --- a/json/upickle/src/test/scala/sttp/client4/upicklejson/UpickleTests.scala +++ b/json/upickle/src/test/scala/sttp/client4/upicklejson/UpickleTests.scala @@ -93,11 +93,13 @@ class UpickleTests extends AnyFlatSpec with Matchers with EitherValues { "location" -> "hometown", "bio" -> "Scala programmer" ) - val result = basicRequest.get(Uri("http://example.org")).body(json).body.show + val request = basicRequest.get(Uri("http://example.org")).body(json) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } case class Inner(a: Int, b: Boolean, c: String) diff --git a/json/zio-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala b/json/zio-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala index 2238834191..18d10bc0e7 100644 --- a/json/zio-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala +++ b/json/zio-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala @@ -94,11 +94,13 @@ class ZioJsonTests extends AnyFlatSpec with Matchers with EitherValues { it should "serialize from Json.Obj using implicit zioJsonBodySerializer" in { val fields: Chunk[(String, Json)] = Chunk(("location", Json.Str("hometown")), ("bio", Json.Str("Scala programmer"))) val jObject: Json.Obj = Json.Obj(fields) - val result = basicRequest.get(Uri("http://example.org")).body(jObject).body.show + val request = basicRequest.get(Uri("http://example.org")).body(jObject) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } def extractBody[T](request: PartialRequest[T]): String = diff --git a/json/zio1-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala b/json/zio1-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala index 2238834191..18d10bc0e7 100644 --- a/json/zio1-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala +++ b/json/zio1-json/src/test/scala/sttp/client4/ziojson/ZioJsonTests.scala @@ -94,11 +94,13 @@ class ZioJsonTests extends AnyFlatSpec with Matchers with EitherValues { it should "serialize from Json.Obj using implicit zioJsonBodySerializer" in { val fields: Chunk[(String, Json)] = Chunk(("location", Json.Str("hometown")), ("bio", Json.Str("Scala programmer"))) val jObject: Json.Obj = Json.Obj(fields) - val result = basicRequest.get(Uri("http://example.org")).body(jObject).body.show + val request = basicRequest.get(Uri("http://example.org")).body(jObject) - val expectedResult = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedBody = "string: {\"location\":\"hometown\",\"bio\":\"Scala programmer\"}" + val expectedContentType = Some("application/json; charset=utf-8") - result should be(expectedResult) + request.contentType should be(expectedContentType) + request.body.show should be(expectedBody) } def extractBody[T](request: PartialRequest[T]): String =