Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- void souldRegisterNewUser() throws Exception{
- User u = new User();
- u.setUsername("user432");
- u.setPassword("user123123");
- u.setPasswordConfirm("user123123");
- this.mockMvc.perform(post("/registration")
- .param("username",u.getUsername())
- .param("password",u.getPassword())
- .param("passwordConfirm",u.getPasswordConfirm()))
- .andExpect(status().isFound())
- .andExpect(redirectedUrl("/index"))
- .andExpect(flash().attribute("register", Matchers.equalTo("true")));
- }
- @Test
- void souldNotRegisterNewUserBecousePasswordIsBad() throws Exception{
- User u = new User();
- u.setUsername("user432");
- u.setPassword("user1231231");
- u.setPasswordConfirm("user123123");
- this.mockMvc.perform(post("/registration")
- .param("username",u.getUsername())
- .param("password",u.getPassword())
- .param("passwordConfirm",u.getPasswordConfirm()))
- .andExpect(status().isFound())
- .andExpect(redirectedUrl("/index"))
- .andExpect(flash().attribute("error",Matchers.equalTo("password")));
- }
Add Comment
Please, Sign In to add comment