title: I can't mock property of class
body: <p>I've just started using spock and I am facing one issue..</p>
  
  <pre><code>    public class UserAuthentication {
          private UserDAO userDao;
  
          public boolean authenticateUser(String email, String password){
              User user = userDao.findUserByEmail(email);
  
              if(password.equals(user.getDecodedPassword())){
                  return true;
              }
              return false;
          }
  }
  
  
  public interface UserDAO {
  
      User findUserByEmail(String login);
  
      void saveUser(User user);
  }
  
  public class User {
  
      private String email;
      private String decodedPassword;
  
      public User(String email, String decodedPassword) {
          this.email = email;
          this.decodedPassword = decodedPassword;
      }(...)
  </code></pre>
  
  <p>Unfortunately my test throw NullPointerException:</p>
  
  <pre><code>import java.text.SimpleDateFormat
  import spock.lang.Specification
  
  class UserAuthenticationTest extends Specification {
  
      def "Authenticating correct user" () {
          setup:
          def email = "email@email.com"
          def password = "qwerty1234"
  
          def userDao = Mock(UserDAO)
          userDao.findUserByEmail(email) &gt;&gt; new User(email, password)
  
          def userAuthenticator = new UserAuthentication()
          userAuthenticator.setUserDao(userDao)
  
          when:
          def result = userAuthenticator.authenticateUser(email, password)
  
          then:
          1 * userDao.findUserByEmail(email)
          result == true
      }
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gdPfn.png" alt="enter image description here"></p>
  
  <p>I got the exception because mock doesn't work when is invoked (userDao.findUserByEmail(email); in UserAuthentication class).</p>
  
  <p>Anyone have some idea why?</p>