@Test public void testValidationErrors() throws Exception { ResetViewData expected = getResetViewData(false, false, asList(ERROR), getResetForm(TOKEN, null, null)); when(resetFormValidator.validate(any(ResetForm.class))).thenReturn(asList(ERROR)); controller.perform(post("/forgotreset") .locale(Locale.ENGLISH) .body(new ObjectMapper().writeValueAsBytes(getResetForm(TOKEN, null, null))) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().string(new ObjectMapper().writeValueAsString(expected))); }
@RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody public ResetViewData getResetViewData(final HttpServletRequest request) { ResetViewData viewData = new ResetViewData(); ResetForm form = new ResetForm(); String token = request.getParameter("token"); if (recoveryService.validateToken(token)) { form.setToken(token); viewData.setInvalidToken(false); } else { viewData.setInvalidToken(true); } viewData.setResetForm(form); viewData.setResetSucceed(false); viewData.setPageLang(cookieLocaleResolver.resolveLocale(request)); return viewData; }
ResetController { @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody public ResetViewData getResetViewData(final HttpServletRequest request) { ResetViewData viewData = new ResetViewData(); ResetForm form = new ResetForm(); String token = request.getParameter("token"); if (recoveryService.validateToken(token)) { form.setToken(token); viewData.setInvalidToken(false); } else { viewData.setInvalidToken(true); } viewData.setResetForm(form); viewData.setResetSucceed(false); viewData.setPageLang(cookieLocaleResolver.resolveLocale(request)); return viewData; } }
ResetController { @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody public ResetViewData getResetViewData(final HttpServletRequest request) { ResetViewData viewData = new ResetViewData(); ResetForm form = new ResetForm(); String token = request.getParameter("token"); if (recoveryService.validateToken(token)) { form.setToken(token); viewData.setInvalidToken(false); } else { viewData.setInvalidToken(true); } viewData.setResetForm(form); viewData.setResetSucceed(false); viewData.setPageLang(cookieLocaleResolver.resolveLocale(request)); return viewData; }  }
ResetController { @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody public ResetViewData getResetViewData(final HttpServletRequest request) { ResetViewData viewData = new ResetViewData(); ResetForm form = new ResetForm(); String token = request.getParameter("token"); if (recoveryService.validateToken(token)) { form.setToken(token); viewData.setInvalidToken(false); } else { viewData.setInvalidToken(true); } viewData.setResetForm(form); viewData.setResetSucceed(false); viewData.setPageLang(cookieLocaleResolver.resolveLocale(request)); return viewData; }  @RequestMapping(value = "/changepassword", method = RequestMethod.GET) ModelAndView changePasswordView(HttpServletRequest request); @RequestMapping(value = "/changepassword", method = RequestMethod.POST) @ResponseBody ChangePasswordViewData changePassword(@RequestBody ChangePasswordForm form); @RequestMapping(value = "/forgotreset", method = RequestMethod.GET) ModelAndView resetView(HttpServletRequest request); @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody ResetViewData getResetViewData(final HttpServletRequest request); @RequestMapping(value = "/forgotreset", method = RequestMethod.POST) @ResponseBody ResetViewData reset(@RequestBody ResetForm form, final HttpServletRequest request); }
ResetController { @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody public ResetViewData getResetViewData(final HttpServletRequest request) { ResetViewData viewData = new ResetViewData(); ResetForm form = new ResetForm(); String token = request.getParameter("token"); if (recoveryService.validateToken(token)) { form.setToken(token); viewData.setInvalidToken(false); } else { viewData.setInvalidToken(true); } viewData.setResetForm(form); viewData.setResetSucceed(false); viewData.setPageLang(cookieLocaleResolver.resolveLocale(request)); return viewData; }  @RequestMapping(value = "/changepassword", method = RequestMethod.GET) ModelAndView changePasswordView(HttpServletRequest request); @RequestMapping(value = "/changepassword", method = RequestMethod.POST) @ResponseBody ChangePasswordViewData changePassword(@RequestBody ChangePasswordForm form); @RequestMapping(value = "/forgotreset", method = RequestMethod.GET) ModelAndView resetView(HttpServletRequest request); @RequestMapping(value = "/forgotresetviewdata", method = RequestMethod.GET) @ResponseBody ResetViewData getResetViewData(final HttpServletRequest request); @RequestMapping(value = "/forgotreset", method = RequestMethod.POST) @ResponseBody ResetViewData reset(@RequestBody ResetForm form, final HttpServletRequest request);  }