@Test
  @TransactionalReadWrite
  public void testInitSettingsPage() {
    User user =
        testUtils.createAuthenticatedTestUser("SettingsControllerTest@testInitSettingsPage");

    ModelMap model = new ModelMap();
    assertEquals("logged/settings", controller.initSettingsPage(model));
    assertTrue(model.containsAttribute("settingsform"));
    SettingsForm settingsForm = (SettingsForm) model.get("settingsform");
    assertEquals(user.getEmail(), settingsForm.getEmail());
    assertEquals(user.getEmail(), settingsForm.getCurrentEmail());
    assertEquals("no", settingsForm.getEditPassword());
    assertEquals(user.getLanguage().getCode(), settingsForm.getLang());
  }
  @Test
  @TransactionalReadWrite
  public void testUpdateAccountWithErrors() {
    testUtils.createAuthenticatedTestUser("SettingsControllerTest@testUpdateAccountWithErrors");

    // Create request and session
    MockHttpServletRequest request = new MockHttpServletRequest("post", "/settings");
    MockHttpSession session = new MockHttpSession();
    request.setSession(session);
    assertNull(session.getAttribute("settings_ko"));

    // Create settings
    SettingsForm settingsForm = new SettingsForm();
    settingsForm.setEditPassword("no");
    settingsForm.setEmail("OTHER_EMAIL");
    ModelAndView modelAndView = getModelAndViewSettingsPage(null, settingsForm, request);

    assertNotNull(session.getAttribute("settings_ko"));
    assertEquals("logged/settings", modelAndView.getViewName());
  }
  @Test
  @TransactionalReadWrite
  public void testUpdateAccount() {
    User user = testUtils.createAuthenticatedTestUser("SettingsControllerTest@testUpdateAccount");

    // Create request and session
    MockHttpServletRequest request = new MockHttpServletRequest("post", "/settings");
    MockHttpSession session = new MockHttpSession();
    request.setSession(session);
    assertNull(session.getAttribute("settings_ok"));

    // Create settings
    SettingsForm settingsForm = new SettingsForm();
    settingsForm.setEditPassword("no");
    settingsForm.setEmail(user.getEmail());
    settingsForm.setLang(testUtils.LOCALE_US);
    ModelAndView modelAndView = getModelAndViewSettingsPage(null, settingsForm, request);

    assertNotNull(session.getAttribute("settings_ok"));
    assertEquals("redirectWithoutModel:settings", modelAndView.getViewName());
  }