use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile 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"));
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestUserProfileAction method testSaveNewEmptyProfile.
public void testSaveNewEmptyProfile() throws Throwable {
this.setUserOnSession("admin");
try {
this.initAction("/do/userprofile", "saveEmpty");
this.addParameter("username", USERNAME_FOR_TEST);
this.addParameter("profileTypeCode", SystemConstants.DEFAULT_PROFILE_TYPE_CODE);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
assertNull(currentUserProfile);
assertNotNull(this._profileManager.getProfile(USERNAME_FOR_TEST));
} catch (Throwable t) {
throw t;
} finally {
this._profileManager.deleteProfile(USERNAME_FOR_TEST);
}
}
Aggregations