@Test public void testResolveMessageNullMessageCode() { ResultMessage message = mock(ResultMessage.class); MessageSource messageSource = mock(MessageSource.class); when(message.getCode()).thenReturn(null); when(message.getText()).thenReturn("MESSAGE_TEXT"); String msg = ResultMessageUtils.resolveMessage(message, messageSource); assertThat(msg, is("MESSAGE_TEXT")); }
public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale) throws NoSuchMessageException { Assert.notNull(messageSource, "messageSource must not be null!"); Assert.notNull(message, "message must not be null!"); Assert.notNull(locale, "locale must not be null!"); String msg; String code = message.getCode(); if (code != null) { try { msg = messageSource.getMessage(code, message.getArgs(), locale); } catch (NoSuchMessageException e) { String text = message.getText(); if (text != null) { if (logger.isDebugEnabled()) { logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '" + text + "' instead", e); } msg = text; } else { throw e; } } } else { msg = message.getText(); } return msg; }
ResultMessageUtils { public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale) throws NoSuchMessageException { Assert.notNull(messageSource, "messageSource must not be null!"); Assert.notNull(message, "message must not be null!"); Assert.notNull(locale, "locale must not be null!"); String msg; String code = message.getCode(); if (code != null) { try { msg = messageSource.getMessage(code, message.getArgs(), locale); } catch (NoSuchMessageException e) { String text = message.getText(); if (text != null) { if (logger.isDebugEnabled()) { logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '" + text + "' instead", e); } msg = text; } else { throw e; } } } else { msg = message.getText(); } return msg; } }
ResultMessageUtils { public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale) throws NoSuchMessageException { Assert.notNull(messageSource, "messageSource must not be null!"); Assert.notNull(message, "message must not be null!"); Assert.notNull(locale, "locale must not be null!"); String msg; String code = message.getCode(); if (code != null) { try { msg = messageSource.getMessage(code, message.getArgs(), locale); } catch (NoSuchMessageException e) { String text = message.getText(); if (text != null) { if (logger.isDebugEnabled()) { logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '" + text + "' instead", e); } msg = text; } else { throw e; } } } else { msg = message.getText(); } return msg; } private  ResultMessageUtils(); }
ResultMessageUtils { public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale) throws NoSuchMessageException { Assert.notNull(messageSource, "messageSource must not be null!"); Assert.notNull(message, "message must not be null!"); Assert.notNull(locale, "locale must not be null!"); String msg; String code = message.getCode(); if (code != null) { try { msg = messageSource.getMessage(code, message.getArgs(), locale); } catch (NoSuchMessageException e) { String text = message.getText(); if (text != null) { if (logger.isDebugEnabled()) { logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '" + text + "' instead", e); } msg = text; } else { throw e; } } } else { msg = message.getText(); } return msg; } private  ResultMessageUtils(); static String resolveMessage(ResultMessage message,
            MessageSource messageSource,
            Locale locale); static String resolveMessage(ResultMessage message,
            MessageSource messageSource); }
ResultMessageUtils { public static String resolveMessage(ResultMessage message, MessageSource messageSource, Locale locale) throws NoSuchMessageException { Assert.notNull(messageSource, "messageSource must not be null!"); Assert.notNull(message, "message must not be null!"); Assert.notNull(locale, "locale must not be null!"); String msg; String code = message.getCode(); if (code != null) { try { msg = messageSource.getMessage(code, message.getArgs(), locale); } catch (NoSuchMessageException e) { String text = message.getText(); if (text != null) { if (logger.isDebugEnabled()) { logger.debug("messege is not found under code '" + code + "' for '" + locale + "'. use '" + text + "' instead", e); } msg = text; } else { throw e; } } } else { msg = message.getText(); } return msg; } private  ResultMessageUtils(); static String resolveMessage(ResultMessage message,
            MessageSource messageSource,
            Locale locale); static String resolveMessage(ResultMessage message,
            MessageSource messageSource);  }