scala - Mockito mocking AhcWSClient -


i'm trying mock rest client(ahcwsclient) in spec using mockito. however, returning null pointer exception. have:

import org.specs2.matcher.scope import org.specs2.mutable.specification import org.specs2.mock.mockito  class myrestclientspec(implicit ev: executionenv) extends specification mockito {  trait context extends scope myrestclient {   val mockwsclient: wsclient = mock[ahcwsclient]   val mockwsresponse: wsresponse = mock[wsresponse]   override def wsclient = mockwsclient }  "findresponse" should {   "give me response" in new context {     val response = "hello"     when(mockwsresponse.body).thenreturn(response)     when(wsclient.url("dummyurl.com").get).thenreturn(future(mockwsresponse)) //***     val result = findresult("request")   } } 

and then:

trait myrestclient {   def wsclient: wsclient = ahcwsclient() } 

the npe thrown on line marked *** , happens when wsclient.url("dummyurl.com") called. doing wrong?


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -