TreeDispatcher implements Dispatcher<E> { @Override public List<E> findPrefixMatches(String path) { return tree.getMatches(delimiter.split(path)); }  void setDelimiter(String delimiter); @Override void addEndpoint(String path, E endpoint); @Override E removeEndpoint(String path); @Override E findExactMatch(String path); @Override List<E> findPrefixMatches(String path);  }
@Test public void testFindPrefixMatches() { TreeDispatcher<String> dispatcher = setupDispatcher(); List<String> matches = dispatcher.findPrefixMatches("/one/two/three/four/five/six/seven/eight"); assertNotNull(matches); assertEquals(matches.size(), 3); assertEquals(matches.get(0), "/one/two/three/four/five/six"); assertEquals(matches.get(1), "/one/two/three/four"); assertEquals(matches.get(2), "/one/two"); matches = dispatcher.findPrefixMatches(" assertEquals(matches.size(), 3); assertEquals(matches.get(0), "/one/two/three/four/five/six"); assertEquals(matches.get(1), "/one/two/three/four"); assertEquals(matches.get(2), "/one/two"); matches = dispatcher.findPrefixMatches(" assertEquals(matches.size(), 1); assertEquals(matches.get(0), "/one/two"); matches = dispatcher.findPrefixMatches("/one/two"); assertEquals(matches.size(), 1); assertEquals(matches.get(0), "/one/two"); matches = dispatcher.findPrefixMatches("/one/three/three"); assertNotNull(matches); assertTrue(matches.isEmpty()); assertTrue(dispatcher.findPrefixMatches("/*").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/.*").isEmpty()); assertTrue(dispatcher.findPrefixMatches("one").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/one/tw").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/one/twoo").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/one/two*").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/one/two.*").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/on/two").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/onee/two").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/onetwo").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/oneetwo").isEmpty()); assertTrue(dispatcher.findPrefixMatches("/one\\two").isEmpty()); }