diff options
author | Aleksandr <ognelisar@gmail.com> | 2018-03-12 17:32:25 +0700 |
---|---|---|
committer | Aleksandr <ognelisar@gmail.com> | 2018-03-12 17:32:25 +0700 |
commit | 04a21e9a5ab46f885cb51626d274d570fefe4a29 (patch) | |
tree | 862c9b8702c4f9f9410b85d09107cc73d5355c5a /src/test/scala/xyz | |
parent | 1ea8a5c1298edae003f5d4d8c4b9e8581d834b04 (diff) | |
parent | 96aa1fbf7608e3b9cd1ba06c57ab1f356409733d (diff) | |
download | driver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.tar.gz driver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.tar.bz2 driver-core-04a21e9a5ab46f885cb51626d274d570fefe4a29.zip |
Merge branch 'master' into TM-1431
Diffstat (limited to 'src/test/scala/xyz')
-rw-r--r-- | src/test/scala/xyz/driver/core/rest/RestTest.scala | 23 |
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]) + } + } + } } |