runValidationTests(ExtendOverloadSetterAgainActionBean.class);
}
protected void runValidationTests(Class<? extends BaseActionBean<User>> type) throws Exception {
// Trigger the validation errors
MockRoundtrip trip = new MockRoundtrip(StripesTestFixture.getServletContext(), type);
trip.execute("login");
ValidationErrors errors = trip.getValidationErrors();
Assert.assertNotNull(errors, "Expected validation errors but got none");
Assert.assertFalse(errors.isEmpty(), "Expected validation errors but got none");
Assert.assertEquals(errors.size(), 2, "Expected two validation errors but got " + errors.size());
// Now add the required parameters and make sure the validation errors don't happen
trip.addParameter("model.username", "Scooby");
trip.addParameter("model.password", "Shaggy");
trip.execute("login");
errors = trip.getValidationErrors();
Assert.assertTrue(errors == null || errors.isEmpty(), "Got unexpected validation errors");
BaseActionBean<User> bean = trip.getActionBean(type);
Assert.assertNotNull(bean);
Assert.assertNotNull(bean.getModel());
Assert.assertEquals(bean.getModel().getUsername(), "Scooby");
Assert.assertEquals(bean.getModel().getPassword(), "Shaggy");
}