DictionaryServiceImpl implements DictionaryService, ManagedService { @Override public Textual cleanUpText(String text) { logger.debug("Text input: “{}”", text); LinkedList<String> words = new LinkedList<String>(); Matcher matcher = compilesPattern.matcher(text); while (matcher.find()) { words.add(matcher.group()); } String result = org.apache.commons.lang3.StringUtils.join(words, " "); logger.debug("Resulting text: “{}”", result); if ("".equals(result)) { return null; } return new TextualImpl(result); }  void setPattern(String p); String getPattern(); @Override synchronized void updated(Dictionary<String, ?> properties); @Override Textual cleanUpText(String text); static final String PATTERN_CONFIG_KEY; }
@Test public void testEmpty() throws Exception { DictionaryServiceImpl service = new DictionaryServiceImpl(); Assert.assertEquals(null, service.cleanUpText("")); }
@Test public void testCleanUp() throws Exception { DictionaryServiceImpl service = new DictionaryServiceImpl(); String in = "This is a test sentence."; String out = "This is a test sentence"; Assert.assertEquals(out, service.cleanUpText(in).getText()); }