UserFormBean extends BaseActionBean { @DontValidate @DefaultHandler public Resolution view() { if (id != null) { try { user = userManager.getUser(id); } catch (ObjectRetrievalFailureException e) { e.printStackTrace(); getContext().getMessages().add(new LocalizableMessage("user.missing")); return showList(); } } else { user = new User(); } return showForm(); }  void setId(String id); User getUser(); @ValidateNestedProperties({ @Validate(field = "username", required = true, minlength = 2, maxlength = 50), @Validate(field = "password", required = true, minlength = 2, maxlength = 50), @Validate(field = "email", required = true, minlength = 4, maxlength = 50) }) void setUser(User user); @DontValidate @DefaultHandler Resolution view(); @HandlesEvent("save") Resolution save(); @DontValidate @HandlesEvent("delete") Resolution delete(); @DontValidate @HandlesEvent("cancel") Resolution cancel();  }
@Test public void testView() throws Exception { servletContext = new StripesTestFixture().getServletContext(); MockRoundtrip trip = new MockRoundtrip(servletContext, UserFormBean.class); String userId = "-1"; trip.addParameter("id", userId); trip.execute(); UserFormBean bean = trip.getActionBean(UserFormBean.class); assertNotNull(bean.getUser()); }