use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestCurrentUserProfileAction method testValidateProfile.
public void testValidateProfile() throws Throwable {
this.setUserOnSession("editorCustomers");
this.initAction("/do/currentuser/profile", "edit");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
this.initAction("/do/currentuser/profile", "save");
this.addParameter("Monotext:fullname", "");
this.addParameter("Monotext:email", "");
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(2, action.getFieldErrors().size());
this.initAction("/do/currentuser/profile", "save");
this.addParameter("Monotext:fullname", "Ronald Rossi");
this.addParameter("Monotext:email", "");
this.addParameter("Date:birthdate", "25/09/1972");
this.addParameter("Monotext:language", "it");
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, ((List<String>) action.getFieldErrors().get("Monotext:email")).size());
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
assertNotNull(currentUserProfile);
assertEquals("editorCustomers", currentUserProfile.getUsername());
assertEquals("Ronald Rossi", currentUserProfile.getValue("fullname"));
}
use of com.opensymphony.xwork2.ActionSupport in project entando-core by entando.
the class TestUserProfileAction method testValidateProfile.
public void testValidateProfile() throws Throwable {
this.setUserOnSession("admin");
this.initAction("/do/userprofile", "edit");
this.addParameter("username", "editorCustomers");
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
this.initAction("/do/userprofile", "save");
this.addParameter("Monotext:fullname", "");
result = this.executeAction();
assertEquals(Action.INPUT, result);
ActionSupport action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
this.initAction("/do/userprofile", "save");
this.addParameter("Monotext:fullname", "Ronald Rossi");
this.addParameter("Monotext:email", "");
this.addParameter("Date:birthdate", "25/09/1972");
this.addParameter("Monotext:language", "it");
result = this.executeAction();
assertEquals(Action.INPUT, result);
action = this.getAction();
assertEquals(1, action.getFieldErrors().size());
assertEquals(1, ((List<String>) action.getFieldErrors().get("Monotext:email")).size());
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
assertNotNull(currentUserProfile);
assertEquals("editorCustomers", currentUserProfile.getUsername());
assertEquals("Ronald Rossi", currentUserProfile.getValue("fullname"));
}
Aggregations