Search in sources :

Example 41 with IUserProfile

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

Example 42 with IUserProfile

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

Aggregations

IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)42 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)5 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)3 AbstractUser (com.agiletec.aps.system.services.user.AbstractUser)3 Date (java.util.Date)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 CacheableInfo (org.entando.entando.aps.system.services.cache.CacheableInfo)3 CachePut (org.springframework.cache.annotation.CachePut)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)2 ActionSupport (com.opensymphony.xwork2.ActionSupport)2 ArrayList (java.util.ArrayList)2 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 Test (org.junit.Test)2 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)1 BaseFilterUtils (com.agiletec.aps.system.common.entity.helper.BaseFilterUtils)1 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)1