SearchPath { static Optional<SearchPath> fromString(String path) { if (path == null || path.isEmpty()) { return Optional.empty(); } if (path.indexOf(';') >= 0) { return Optional.empty(); } try { SearchPath sp = parseElement(path); if (sp.isEmpty()) { return Optional.empty(); } else { return Optional.of(sp); } } catch (NumberFormatException | InvalidSearchPathException e) { throw new InvalidSearchPathException("Invalid search path: " + path, e); } } private  SearchPath(List<NodeSelection> nodes, Integer group); static List<Node> selectNodes(String searchPath, SearchCluster cluster); @Override String toString();  }
@Test public void requreThatWildcardsAreDetected() { assertFalse(SearchPath.fromString("").isPresent()); assertFalse(SearchPath.fromString("*/*").isPresent()); assertFalse(SearchPath.fromString("/").isPresent()); assertFalse(SearchPath.fromString("/*").isPresent()); assertFalse(SearchPath.fromString(" }
@Test public void invalidRangeMustThrowException() { exception.expect(InvalidSearchPathException.class); SearchPath.fromString("[p,0>/0"); }
@Test public void invalidPartMustThrowException() { exception.expect(InvalidSearchPathException.class); SearchPath.fromString("p/0"); }
@Test public void invalidRowMustThrowException() { exception.expect(InvalidSearchPathException.class); SearchPath.fromString("1,2,3/r"); }