I have a user class like such:
class User { transient springSecurityService String displayName String password protected void encode
I've done that like this:
protected void encodePassword() { // SpringSecutiryService is not injected in tests. if (springSecurityService) password = springSecurityService.encodePassword(formPassword) }