Path { public Path getParentPath() { ArrayList<String> parentElements = new ArrayList<>(); if (elements.size() > 1) { for (int i = 0; i < elements.size() - 1; i++) { parentElements.add(elements.get(i)); } } return new Path(parentElements, delimiter); } private  Path(String delimiter); private  Path(Path path); private  Path(List<String> elements, String delimiter); boolean isChildOf(Path parent); Path append(String path); Path append(Path path); String getName(); String getRelative(); Path getParentPath(); Path getChildPath(); String last(); Path withLast(String element); String getAbsolute(); boolean isRoot(); Iterator<String> iterator(); List<String> elements(); @Override String toString(); static Path fromString(String path); static Path fromString(String path, String delimiter); static Path createRoot(); static Path createRoot(String delimiter); File toFile(); @Override int hashCode(); @Override boolean equals(Object other);  }
@Test public void testGetParentPath() { assertThat(getAbsolutePath().getParentPath().getRelative(), is("foo/bar")); assertThat(getRelativePath().getParentPath().getRelative(), is("foo/bar")); assertThat(getWithSlashes().getParentPath().getRelative(), is("foo/bar")); assertThat(getAppended().getParentPath().getRelative(), is("foo/bar")); assertThat(getOne().getParentPath().getRelative(), is("")); }