@Test public void addErrorMessage() { RedirectAttributes model = new RedirectAttributesModelMap(); Object[] params = new Object[0]; when(messageSourceMock.getMessage(eq(ERROR_MESSAGE_CODE), eq(params), any(Locale.class))).thenReturn(ERROR_MESSAGE); controller.addErrorMessage(model, ERROR_MESSAGE_CODE, params); verify(messageSourceMock, times(1)).getMessage(eq(ERROR_MESSAGE_CODE), eq(params), any(Locale.class)); verifyNoMoreInteractions(messageSourceMock); String errorMessage = (String) model.getFlashAttributes().get(FLASH_ERROR_MESSAGE); assertEquals(ERROR_MESSAGE, errorMessage); }
protected void addErrorMessage(RedirectAttributes model, String code, Object... params) { LOGGER.debug("adding error message with code: " + code + " and params: " + params); Locale current = LocaleContextHolder.getLocale(); LOGGER.debug("Current locale is " + current); String localizedErrorMessage = messageSource.getMessage(code, params, current); LOGGER.debug("Localized message is: " + localizedErrorMessage); model.addFlashAttribute(FLASH_ERROR_MESSAGE, localizedErrorMessage); }
AbstractController { protected void addErrorMessage(RedirectAttributes model, String code, Object... params) { LOGGER.debug("adding error message with code: " + code + " and params: " + params); Locale current = LocaleContextHolder.getLocale(); LOGGER.debug("Current locale is " + current); String localizedErrorMessage = messageSource.getMessage(code, params, current); LOGGER.debug("Localized message is: " + localizedErrorMessage); model.addFlashAttribute(FLASH_ERROR_MESSAGE, localizedErrorMessage); } }
AbstractController { protected void addErrorMessage(RedirectAttributes model, String code, Object... params) { LOGGER.debug("adding error message with code: " + code + " and params: " + params); Locale current = LocaleContextHolder.getLocale(); LOGGER.debug("Current locale is " + current); String localizedErrorMessage = messageSource.getMessage(code, params, current); LOGGER.debug("Localized message is: " + localizedErrorMessage); model.addFlashAttribute(FLASH_ERROR_MESSAGE, localizedErrorMessage); }  }
AbstractController { protected void addErrorMessage(RedirectAttributes model, String code, Object... params) { LOGGER.debug("adding error message with code: " + code + " and params: " + params); Locale current = LocaleContextHolder.getLocale(); LOGGER.debug("Current locale is " + current); String localizedErrorMessage = messageSource.getMessage(code, params, current); LOGGER.debug("Localized message is: " + localizedErrorMessage); model.addFlashAttribute(FLASH_ERROR_MESSAGE, localizedErrorMessage); }   }
AbstractController { protected void addErrorMessage(RedirectAttributes model, String code, Object... params) { LOGGER.debug("adding error message with code: " + code + " and params: " + params); Locale current = LocaleContextHolder.getLocale(); LOGGER.debug("Current locale is " + current); String localizedErrorMessage = messageSource.getMessage(code, params, current); LOGGER.debug("Localized message is: " + localizedErrorMessage); model.addFlashAttribute(FLASH_ERROR_MESSAGE, localizedErrorMessage); }    }