@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()); }