public void testEditProfile() throws Throwable {
   this.setUserOnSession(USERNAME_FOR_TEST);
   this.initAction("/do/jpuserprofile/MyProfile", "edit");
   String result = this.executeAction();
   assertEquals(Action.SUCCESS, result);
   IUserProfile currentUserProfile =
       (IUserProfile)
           this.getRequest()
               .getSession()
               .getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
   assertNotNull(currentUserProfile);
   assertEquals(USERNAME_FOR_TEST, currentUserProfile.getUsername());
 }
  public void testValidateProfile() throws Throwable {
    this.setUserOnSession(USERNAME_FOR_TEST);
    this.initAction("/do/jpuserprofile/MyProfile", "new");
    this.addParameter("profileTypeCode", "PFL");
    String result = this.executeAction();
    assertEquals(Action.SUCCESS, result);

    this.initAction("/do/jpuserprofile/MyProfile", "save");
    result = this.executeAction();
    assertEquals(Action.INPUT, result);

    ActionSupport action = this.getAction();
    assertEquals(5, action.getFieldErrors().size());

    this.initAction("/do/jpuserprofile/MyProfile", "save");
    this.addParameter("Name", "Eugenio");
    this.addParameter("Surname", "Santoboni");
    this.addParameter("email", "");
    this.addParameter("birthdate", "25/09/1972");
    this.addParameter("language", "it");
    result = this.executeAction();
    assertEquals(Action.INPUT, result);

    action = this.getAction();
    assertEquals(1, action.getFieldErrors().size());
    assertEquals(1, ((List<String>) action.getFieldErrors().get("email")).size());

    IUserProfile currentUserProfile =
        (IUserProfile)
            this.getRequest()
                .getSession()
                .getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
    assertNotNull(currentUserProfile);
    assertEquals(USERNAME_FOR_TEST, currentUserProfile.getUsername());
    assertEquals("Eugenio", currentUserProfile.getValue("Name"));
    assertEquals("Santoboni", currentUserProfile.getValue("Surname"));
  }