DataFormatterAwareImpl implements DataFormatterAware { @Override public Optional<DataFormatter> getDataFormatter(String sql) { if (sql == null) { return Optional.empty(); } Optional<String> matchingDelimiter = getMatchingDelimiter(sql); return matchingDelimiter.isPresent() ? Optional.ofNullable(dataFormatters.get(matchingDelimiter.get())) : Optional.empty(); } @Autowired  DataFormatterAwareImpl(ApplicationContext applicationContext); @PostConstruct void init(); @Override Optional<DataFormatter> getDataFormatter(String sql); @Override String removeDelimiter(String sql);  }
@Test public void testGetDataFormatter() { assertThat(dataFormatterAware.getDataFormatter(null), equalTo(Optional.empty())); assertThat(dataFormatterAware.getDataFormatter("anything"), equalTo(Optional.empty())); assertThat(dataFormatterAware.getDataFormatter("anything\\X"), equalTo(Optional.empty())); assertThat(dataFormatterAware.getDataFormatter("anything\\E"), equalTo(Optional.of(enumerationFormatter))); assertThat(dataFormatterAware.getDataFormatter("anything\\L"), equalTo(Optional.of(listFormatter))); assertThat(dataFormatterAware.getDataFormatter("anything\\G"), equalTo(Optional.of(blockFormatter))); }