### Question:
CustomTranslationResolverImpl implements CustomTranslationResolver { @Override public String getCustomTranslation(final String key, final Locale locale, final String[] args) { String translation = customTranslationCacheService.getCustomTranslation(key, locale.getLanguage()); if (translation == null) { return null; } else { translation = translation.replace("'", "''"); Object[] argsToUse = args; if (!ObjectUtils.isEmpty(argsToUse)) { argsToUse = ArrayUtils.EMPTY_OBJECT_ARRAY; } MessageFormat messageFormat = new MessageFormat(translation); return messageFormat.format(argsToUse); } }  @Override boolean isCustomTranslationActive(final String key, final Locale locale); @Override String getCustomTranslation(final String key, final Locale locale, final String[] args);  }### Answer:
@Test public void shouldRetrunNullWhenGetCustomTranslationIfCustomTranslationIsNull() { String key = "key"; Locale locale = new Locale("pl"); given(customTranslationCacheService.getCustomTranslation(key, locale.getLanguage())).willReturn(null); String translation = customTranslationResolver.getCustomTranslation(key, locale, null); assertEquals(null, translation); }
@Test public void shouldRetrunTranslationWhenGetCustomTranslationIfCustomTranslationIsntNullAndArgsAreNull() { String key = "key"; Locale locale = new Locale("pl"); String[] args = null; String translation = "translation"; given(customTranslationCacheService.getCustomTranslation(key, locale.getLanguage())).willReturn(translation); MessageFormat messageFormat = new MessageFormat(translation); Object[] argsToUse = args; translation = messageFormat.format(argsToUse); String result = customTranslationResolver.getCustomTranslation(key, locale, args); assertEquals(translation, result); }
@Test public void shouldRetrunTranslationWhenGetCustomTranslationIfCustomTranslationIsntNullArgsArentNull() { String key = "key"; Locale locale = new Locale("pl"); String[] args = { "args" }; String translation = "translation"; given(customTranslationCacheService.getCustomTranslation(key, locale.getLanguage())).willReturn(translation); MessageFormat messageFormat = new MessageFormat(translation); Object[] argsToUse = args; translation = messageFormat.format(argsToUse); String result = customTranslationResolver.getCustomTranslation(key, locale, args); assertEquals(translation, result); }