CustomizedTextServiceFacadeWebTier implements CustomizedTextServiceFacade { @Override public String replaceSubstitutions(String message) { if (message == null) return message; String newMessage = message; Map<String, String> messageFilterMap = customizedTextDao.getCustomizedText(); for (Map.Entry<String, String> entry : messageFilterMap.entrySet()) { newMessage = newMessage.replace(entry.getKey(), entry.getValue()); } return newMessage; } @Autowired  CustomizedTextServiceFacadeWebTier(CustomizedTextDao customizedTextDao, MessageSource messageSource); @Override void addOrUpdateCustomizedText(String originalText, String customText); @Override void removeCustomizedText(String originalText); @Override Map<String, String> retrieveCustomizedText(); @Override String replaceSubstitutions(String message); @Override CustomizedTextDto getCustomizedTextDto(String originalText); @Override void convertMigratedLabelKeysToLocalizedText(Locale locale);  }
@Test public void shouldReplaceText() { Map<String, String> map = new LinkedHashMap<String, String>(); map.put("original", "custom"); map.put("Clients", "People"); map.put("Client", "Person"); map.put("Admin", "Administrator"); when(customizedTextDao.getCustomizedText()).thenReturn(map); String newString = customizedTextServiceFacadeWebTier.replaceSubstitutions("" + "This is the original message"); assertThat(newString, is("This is the custom message")); newString = customizedTextServiceFacadeWebTier .replaceSubstitutions("The Admin function is performed by admins, Admins and Administrators"); assertThat(newString, is("The Administrator function is performed by admins, Administrators and Administratoristrators")); newString = customizedTextServiceFacadeWebTier.replaceSubstitutions("" + "Many Clients have a Client"); assertThat(newString, is("Many People have a Person")); }