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.
You should retrieve the MyUserService
plugin instance from the play application and invoke the find method on the retrieved MyUserService
instance.
How you're doing it (as shown above) find
would have to be defined in a MyUserService
object.
Update: The MyUserService
plugin can be retrieved like this:
"retrieve a user by UserId" in new WithApplication {
val userService = implicitApp.plugin(classOf[MyUserService]).get
...
}