aboutsummaryrefslogtreecommitdiff
path: root/src/test/scala/xyz
diff options
context:
space:
mode:
authorKseniya Tomskikh <ktomskih@datamonsters.co>2018-03-07 11:38:51 +0700
committerGitHub <noreply@github.com>2018-03-07 11:38:51 +0700
commitfccdf351f8530bb30f7ec9ca61273f0be4c80221 (patch)
treec7038d501e37f37d6082f2c9495592b7c8085d6a /src/test/scala/xyz
parent575872b556eeb403147df9fe96b58236e0402050 (diff)
parentcfea2749380d367f4a525c90792b66241df42273 (diff)
downloaddriver-core-fccdf351f8530bb30f7ec9ca61273f0be4c80221.tar.gz
driver-core-fccdf351f8530bb30f7ec9ca61273f0be4c80221.tar.bz2
driver-core-fccdf351f8530bb30f7ec9ca61273f0be4c80221.zip
Merge pull request #134 from drivergroup/opt-paginationv1.8.8
Created directive for optional pagination
Diffstat (limited to 'src/test/scala/xyz')
-rw-r--r--src/test/scala/xyz/driver/core/rest/RestTest.scala23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/scala/xyz/driver/core/rest/RestTest.scala b/src/test/scala/xyz/driver/core/rest/RestTest.scala
index d36e04d..68fe419 100644
--- a/src/test/scala/xyz/driver/core/rest/RestTest.scala
+++ b/src/test/scala/xyz/driver/core/rest/RestTest.scala
@@ -47,4 +47,27 @@ class RestTest extends WordSpec with Matchers with ScalatestRouteTest with Direc
}
}
}
+
+ "optional paginated directive" should {
+ val route: Route = rest.optionalPagination { paginated =>
+ complete(StatusCodes.OK -> paginated.map(p => s"${p.pageNumber},${p.pageSize}").getOrElse("no pagination"))
+ }
+ "accept a pagination" in {
+ Get("/?pageNumber=2&pageSize=42") ~> route ~> check {
+ assert(status == StatusCodes.OK)
+ assert(entityAs[String] == "2,42")
+ }
+ }
+ "without pagination" in {
+ Get("/") ~> route ~> check {
+ assert(status == StatusCodes.OK)
+ assert(entityAs[String] == "no pagination")
+ }
+ }
+ "reject an invalid pagination" in {
+ Get("/?pageNumber=1") ~> route ~> check {
+ assert(rejection.isInstanceOf[ValidationRejection])
+ }
+ }
+ }
}