### Question:
TemplateEngineRythmI18nMessageResolver implements II18nMessageResolver { @Override public String getMessage(ITemplate template, String key, Object... args) { Locale locale = null; if (args.length > 0) { Object arg0 = args[0]; if (arg0 instanceof Locale) { locale = (Locale) arg0; Object[] args0 = new Object[args.length - 1]; System.arraycopy(args, 1, args0, 0, args.length - 1); args = args0; } } if (locale == null && template != null) { locale = (template == null) ? RythmEngine.get().renderSettings.locale() : template.__curLocale(); } Optional<String> lang = Optional.absent(); if (locale != null) { lang = Optional.of(locale.toString().replace('_', '-')); } Optional<String> i18nMessage = Optional.absent(); i18nMessage = messages.get(key, lang, args); return i18nMessage.or(""); } TemplateEngineRythmI18nMessageResolver(Messages messages); @Override String getMessage(ITemplate template, String key, Object... args);  }### Answer:
@Test public void testGetMessage() { TemplateEngineRythmI18nMessageResolver resolver = new TemplateEngineRythmI18nMessageResolver( messages); Optional<String> lang = Optional.absent(); when(messages.get(Mockito.eq("key"), Mockito.eq(lang), Mockito.eq("arg1"))).thenReturn( Optional.of("i18n-Message")); Assert.assertEquals("i18n-Message", resolver.getMessage(template, "key", "arg1")); lang = Optional.of("de"); when(messages.get(Mockito.eq("key"), Mockito.eq(lang), Mockito.eq("arg1"))).thenReturn( Optional.of("i18n-Nachricht")); Assert.assertEquals("i18n-Nachricht", resolver.getMessage(template, "key", new Locale("de"), "arg1")); }