kikosiak

Untitled

Jun 9th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. @Test
  2. void souldRegisterNewUser() throws Exception{
  3. User u = new User();
  4. u.setUsername("user432");
  5. u.setPassword("user123123");
  6. u.setPasswordConfirm("user123123");
  7.  
  8. this.mockMvc.perform(post("/registration")
  9. .param("username",u.getUsername())
  10. .param("password",u.getPassword())
  11. .param("passwordConfirm",u.getPasswordConfirm()))
  12. .andExpect(status().isFound())
  13. .andExpect(redirectedUrl("/index"))
  14. .andExpect(flash().attribute("register", Matchers.equalTo("true")));
  15. }
  16.  
  17. @Test
  18. void souldNotRegisterNewUserBecousePasswordIsBad() throws Exception{
  19. User u = new User();
  20. u.setUsername("user432");
  21. u.setPassword("user1231231");
  22. u.setPasswordConfirm("user123123");
  23.  
  24. this.mockMvc.perform(post("/registration")
  25. .param("username",u.getUsername())
  26. .param("password",u.getPassword())
  27. .param("passwordConfirm",u.getPasswordConfirm()))
  28. .andExpect(status().isFound())
  29. .andExpect(redirectedUrl("/index"))
  30. .andExpect(flash().attribute("error",Matchers.equalTo("password")));
  31. }
Add Comment
Please, Sign In to add comment