DataFormatterAwareImpl implements DataFormatterAware { @Override public String removeDelimiter(String sql) { if (sql == null) { return ""; } Optional<String> matchingDelimiter = getMatchingDelimiter(sql); return matchingDelimiter.isPresent() ? sql.substring(0, sql.length() - matchingDelimiter.get().length()) : sql; } @Autowired  DataFormatterAwareImpl(ApplicationContext applicationContext); @PostConstruct void init(); @Override Optional<DataFormatter> getDataFormatter(String sql); @Override String removeDelimiter(String sql);  }
@Test public void testRemoveDelimiter() { assertThat(dataFormatterAware.removeDelimiter(null), equalTo("")); assertThat(dataFormatterAware.removeDelimiter("anything"), equalTo("anything")); assertThat(dataFormatterAware.removeDelimiter("anything\\X"), equalTo("anything\\X")); assertThat(dataFormatterAware.removeDelimiter("anything\\E"), equalTo("anything")); assertThat(dataFormatterAware.removeDelimiter("\\Eanything"), equalTo("\\Eanything")); assertThat(dataFormatterAware.removeDelimiter("anything\\L"), equalTo("anything")); assertThat(dataFormatterAware.removeDelimiter("anything\\G"), equalTo("anything")); }