0

I'm wondering how I can test my implemented UserService (MyUserService) methods directly. I've imported MyUserService but it doesn't seem to recognize it.

The error is:

not found: value MyUserService

Thanks for any help you can give. Here's my test case for the find method.

Here's my test case...

"retrieve a user by UserId" in new WithApplication  {

  val user : Option[User]  = MyUserService.find(UserId("johnnyboy", "userpass"))

  val getUser = user.get

  getUser.uid must equalTo(Some(1))
  getUser.id.id must equalTo ("johnnyboy")
  getUser.id.providerId must equalTo("userpass")
  getUser.userType must equalTo(Some("admin"))
  getUser.firstName must equalTo("John")
  getUser.lastName must equalTo("Smith")
  getUser.fullName must equalTo("John Smith)
  getUser.email must equalTo(Some("johnsmith@gmail.com"))
  getUser.avatarUrl must equalTo(None)
  getUser.authMethod must equalTo(AuthenticationMethod("userPassword"))
  getUser.oAuth1Info must equalTo(None)
  getUser.oAuth2Info must equalTo(None)
  getUser.passwordInfo.get.hasher must equalTo(PasswordHasher.BCryptHasher)
  getUser.passwordInfo.get.password must      equalTo("$2a$10$eYPUTBSjprjKKmUf4m4XRuwurSxKKwbw13eP6WyDNk/LdpKgBytda")
  getUser.passwordInfo.get.salt must equalTo(None)
}

Thanks again.

4

1 回答 1

0

您应该MyUserService从播放应用程序中检索插件实例并在检索到的MyUserService实例上调用 find 方法。你如何做(如上所示)find必须在一个MyUserService对象中定义。

更新:插件MyUserService可以这样检索:

"retrieve a user by UserId" in new WithApplication  {
  val userService = implicitApp.plugin(classOf[MyUserService]).get
  ...
}
于 2013-07-29T18:16:58.873 回答