@Test public void shouldGetMessageForKeyWithArgs() { String key = "key"; Object[] args = {"arg1", "arg2"}; String expectedMessage = "message"; when(messageSource.getMessage(key, args, key, usLocale)).thenReturn(expectedMessage); String message = messageService.message(key, args); verify(messageSource).getMessage(key, args, key, usLocale); assertThat(message, is(expectedMessage)); }
public String message(String key) { return message(key, currentLocale, (Object) null); }
MessageService { public String message(String key) { return message(key, currentLocale, (Object) null); } }
MessageService { public String message(String key) { return message(key, currentLocale, (Object) null); } @Autowired  MessageService(ExposedMessageSource messageSource, @Value("${locales.supported}") String locales); }
MessageService { public String message(String key) { return message(key, currentLocale, (Object) null); } @Autowired  MessageService(ExposedMessageSource messageSource, @Value("${locales.supported}") String locales); @Scope(SCOPE_REQUEST) static MessageService getRequestInstance(); String message(String key); String message(OpenLmisMessage openLmisMessage); @SuppressWarnings("non-varargs") String message(String key, Object... args); Set<String> getLocales(); Map<String, String> allMessages(); Map<String, String> allMessages(Locale locale); }
MessageService { public String message(String key) { return message(key, currentLocale, (Object) null); } @Autowired  MessageService(ExposedMessageSource messageSource, @Value("${locales.supported}") String locales); @Scope(SCOPE_REQUEST) static MessageService getRequestInstance(); String message(String key); String message(OpenLmisMessage openLmisMessage); @SuppressWarnings("non-varargs") String message(String key, Object... args); Set<String> getLocales(); Map<String, String> allMessages(); Map<String, String> allMessages(Locale locale);  }