Reputation: 985
I want to test a method that process value of query string. I use Mockito to mock objects. I tried to mock Request object and set its query string but it seems that there's no method to set query string.
My question is how to mock query string in Request?
Edit: I use Java 8 and Play 2.3
Upvotes: 0
Views: 1366
Reputation: 11274
There's FakeRequest
for that, it allows to pass the full path or an already parsed body using withFormUrlEncodedBody
.
Check out the API documentation for more info.
Upvotes: 0
Reputation: 7247
Use the copy(...)
method of Request
to add your own query string parameters.
https://www.playframework.com/documentation/2.3.x/api/scala/index.html#play.api.mvc.Request
Upvotes: 1