I am writing rest test cases in akk-http, I am getting this error in statement when(mockedRepository.getAllFromModule).thenReturn(x)
.My Class is as below:
class GetModulesRestTest extends WordSpec with Matchers with ScalatestRouteTest with MockitoSugar {
val mockedRepository = mock[ImplModuleRepository]
val dummyRoutes = new GetModulesRest().routes
val inputData = Modules(1L,Some("ModuleName"), Some("SomeDescription"), false)
val dataJson = """[{"id": 1,"name": "HR","description": "This is about HR module","isRemoved": false}]"""
"Check Software Test" should {
"check for java and zookeeper installation" in {
val x = Future(Seq(inputData))
when(mockedRepository.getAllFromModule).thenReturn(x)
Get("/getmodules") ~> dummyRoutes ~> check {
responseAs[String] shouldBe dataJson
}
}
}
}
Here ImplModuleRepository
is an abstract class which is returning list of all modules from postgres database, the program is showing error as stated above, actually statement theReturn(x) is not compiling and is showing this error on compiling:
Error:(32, 47) overloaded method value thenReturn with alternatives:
(x$1: scala.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]],x$2: scala.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]]*)org.mockito.stubbing.OngoingStubbing[scala.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]]] <and>
(x$1: scala.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]])org.mockito.stubbing.OngoingStubbing[scala.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]]]
cannot be applied to (scalaz.concurrent.Future[Seq[com.reactore.launchpad.entity.Modules]])
when(mockedRepository.getAllFromModule).thenReturn(x)
I don't know what is wrong.