You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by jr...@apache.org on 2022/11/03 11:24:11 UTC
[incubator-pekko-http] 41/47: http: simplify some tests
This is an automated email from the ASF dual-hosted git repository.
jrudolph pushed a commit to branch scala-3
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-http.git
commit f4d6b264b69b06a82f9f1945ff1066296026c601
Author: Johannes Rudolph <jo...@gmail.com>
AuthorDate: Thu May 5 16:09:47 2022 +0200
http: simplify some tests
---
.../src/test/scala/akka/http/scaladsl/server/BasicRouteSpecs.scala | 6 +++---
.../http/scaladsl/server/directives/ParameterDirectivesSpec.scala | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/BasicRouteSpecs.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/BasicRouteSpecs.scala
index 609a88d3b..b340fee1e 100644
--- a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/BasicRouteSpecs.scala
+++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/BasicRouteSpecs.scala
@@ -149,7 +149,7 @@ class BasicRouteSpecs extends RoutingSpec {
"extract one argument" in {
case class MyNumber(i: Int)
- val abcPath = path("abc" / IntNumber).as(ConstructFromTuple.instance1(MyNumber))(echoComplete)
+ val abcPath = path("abc" / IntNumber).as(MyNumber.apply _)(echoComplete)
Get("/abc/5") ~> abcPath ~> check {
responseAs[String] shouldEqual "MyNumber(5)"
@@ -158,7 +158,7 @@ class BasicRouteSpecs extends RoutingSpec {
"extract two arguments" in {
case class Person(name: String, age: Int)
- val personPath = path("person" / Segment / IntNumber).as(ConstructFromTuple.instance2(Person))(echoComplete)
+ val personPath = path("person" / Segment / IntNumber).as(Person.apply _)(echoComplete)
Get("/person/john/38") ~> personPath ~> check {
responseAs[String] shouldEqual "Person(john,38)"
@@ -169,7 +169,7 @@ class BasicRouteSpecs extends RoutingSpec {
require(i > 10)
}
- val abcPath = path("abc" / IntNumber).as(ConstructFromTuple.instance1(MyValidNumber))(echoComplete)
+ val abcPath = path("abc" / IntNumber).as(MyValidNumber.apply _)(echoComplete)
Get("/abc/5") ~> abcPath ~> check {
rejection shouldBe a[ValidationRejection]
diff --git a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/ParameterDirectivesSpec.scala b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/ParameterDirectivesSpec.scala
index 7439cfc6d..0a997d198 100644
--- a/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/ParameterDirectivesSpec.scala
+++ b/akka-http-tests/src/test/scala/akka/http/scaladsl/server/directives/ParameterDirectivesSpec.scala
@@ -274,7 +274,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I
"extract a parameter value as Case Class" in {
case class Color(red: Int, green: Int, blue: Int)
Get("/?red=90&green=50&blue=0") ~> {
- parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(ConstructFromTuple.instance3(Color)) { color =>
+ parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(Color.apply _) { color =>
complete(s"${color.red} ${color.green} ${color.blue}")
}
} ~> check { responseAs[String] shouldEqual "90 50 0" }
@@ -286,7 +286,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I
require(0 <= blue && blue <= 255)
}
Get("/?red=500&green=0&blue=0") ~> {
- parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(ConstructFromTuple.instance3(Color)) { color =>
+ parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(Color.apply _) { color =>
complete(s"${color.red} ${color.green} ${color.blue}")
}
} ~> check {
@@ -300,7 +300,7 @@ class ParameterDirectivesSpec extends AnyFreeSpec with GenericRoutingSpec with I
require(0 <= blue && blue <= 255)
}
Get("/?red=0&green=0&blue=0") ~> {
- parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(ConstructFromTuple.instance3(Color)) { _ =>
+ parameters("red".as[Int], "green".as[Int], "blue".as[Int]).as(Color.apply _) { _ =>
throw new IllegalArgumentException
}
} ~> check {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org