### Question:
Locale { public String message(String s, Object... objects) { return messageSource.getMessage(s, objects, nativeLocale); } @Autowired  Locale(@Value("#{localeCodeSource.code}") String code, MessageSource messageSource); String message(String s, Object... objects); String message(String s);  }### Answer:
@Test public void expectedMessageCall() { String testedString = "Some string {change}"; MessageSource mock = mock(MessageSource.class); Locale locale = new Locale("en", mock); Object[] replaceArgs = {"replace"}; locale.message(testedString, replaceArgs); verify(mock, times(1)).getMessage(eq(testedString), eq(replaceArgs), eq(java.util.Locale.ENGLISH)); }
@Test public void shortMessageCall() { String testedString = "Some string {change}"; MessageSource mock = mock(MessageSource.class); Locale locale = new Locale("ru", mock); locale.message(testedString); verify(mock, times(1)).getMessage(eq(testedString), eq(new Object[0]), any()); }