private Message getMessageFromForm(MessageForm messageForm, User sender) {
   Message message = new Message();
   User receiver = userDao.findByEmailLike(messageForm.getReceiver());
   if (receiver == null)
     throw new InvalidUserException("The user you want to send a message does not exist");
   message.setSender(sender);
   message.setReceiver(receiver);
   message.setMessageSubject(messageForm.getMessageSubject());
   message.setMessageText(messageForm.getMessageText());
   return message;
 }
 @Before
 public void setupUser() {
   user = new User();
   user.setId((long) 1);
   user.setFirstName("Maria");
   user.setLastName("Magdalena");
   user.setEmail("*****@*****.**");
   user.setBiography("Oh why, oh why. My biography is gonna change..");
   user.setPassword("654321");
   user.setEnabled(false);
   when(userDao.save(any(User.class))).then(returnsFirstArg());
 }
  @RequestMapping(value = "/userId={id}", method = RequestMethod.GET)
  public ModelAndView showUser(@PathVariable("id") Long id) {
    ModelAndView model = new ModelAndView("profile");
    User user = null;
    if (id != null) { // Do null check for id
      user = userRepository.findOne(id);
      // Do null check for user
    }
    if (user != null) {
      model.addObject("user", user);
    }
    model.addObject("signupForm", new SignupForm());

    return model;
  }
 @RequestMapping(value = "/profile", method = RequestMethod.GET)
 public ModelAndView profile(@RequestParam(value = "userId", required = true) long userId) {
   ModelAndView model = new ModelAndView("profile");
   model.addObject("User", userDao.findOne(userId));
   return model;
 }
 public String getMessageReceiverFirstName(String mail) {
   User receiver = userDao.findByEmailLike(mail);
   if (receiver != null) return receiver.getFirstName();
   return null;
 }