@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); }
@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); } }
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); } } }
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); } }  }
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); }
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);  }