I\'m trying to test a controller method that attempts to parse JSON sent in the request:
def addRoomToProfileForTime = Action.async(parse.json[AddRoomToPro
Another reason can be not setting Content-Length in Postman application. By mistake I had disabled it, and forgot to enable it. .
The short answer is: on your FakeRequest in your controller test use the withBody method instead of withJsonBody.
I had this issue as well, and I embarrassingly spent hours on it until I figured it out. The long answer is that FakeRequest's withJsonBody returns a FakeRequest[AnyContentAsJson], and since your controller is expecting a JsValue (not an AnyContentAsJson), when you call apply() on your action it fails to match this apply method, which is the one you want:
def apply(request: Request[A]): Future[Result]
and instead hits this apply method:
def apply(rh: RequestHeader): Accumulator[ByteString, Result]
and thus since you're not then passing any Bytes to the Accumulator, you get the unexpected end-of-input error message you're getting.