UserForm extends BasePage { public String save() { if (user.getId() != null && user.getId() == 0) { user.setId(null); } if (user.getId() == null) { user.setVersion(null); } try { userManager.saveUser(user); } catch (UserExistsException uex) { addError("user.exists"); return "error"; } addMessage("user.saved", user.getFullName()); return "success"; }  @Autowired void setUserManager(UserManager userManager); String getId(); void setId(String id); User getUser(); void setUser(User user); String edit(); String save(); String delete(); public User user; transient UserManager userManager; }
@Test public void testSave() throws Exception { bean.setId("-1"); bean.edit(); assertNotNull(bean.getUser()); bean.getUser().setFirstName("Jack"); assertEquals(bean.save(), "success"); assertNotNull(bean.getUser()); }