Search in sources :

Example 56 with ActionSupport

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"));
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Example 57 with ActionSupport

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"));
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ActionSupport(com.opensymphony.xwork2.ActionSupport)

Aggregations

ActionSupport (com.opensymphony.xwork2.ActionSupport)56 List (java.util.List)28 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)14 Widget (com.agiletec.aps.system.services.page.Widget)4 ApsProperties (com.agiletec.aps.util.ApsProperties)4 HashMap (java.util.HashMap)4 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)4 IPage (com.agiletec.aps.system.services.page.IPage)3 ArrayList (java.util.ArrayList)3 IManager (com.agiletec.aps.system.common.IManager)2 IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)2 BooleanAttribute (com.agiletec.aps.system.common.entity.model.attribute.BooleanAttribute)1 MonoListAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoListAttribute)1 Lang (com.agiletec.aps.system.services.lang.Lang)1 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)1 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)1 SymbolicLink (com.agiletec.plugins.jacms.aps.system.services.content.model.SymbolicLink)1 LinkAttribute (com.agiletec.plugins.jacms.aps.system.services.content.model.extraAttribute.LinkAttribute)1 ActionProxyFactory (com.opensymphony.xwork2.ActionProxyFactory)1