### Question:
GlusterPath implements Path { @Override public Path getParent() { if (parts.length <= 1 || parts[0].isEmpty()) { if (absolute) { return getRoot(); } else { return null; } } else { return new GlusterPath(fileSystem, Arrays.copyOfRange(parts, 0, parts.length - 1), absolute); } } GlusterPath(GlusterFileSystem fileSystem, String path);   GlusterPath(GlusterFileSystem fileSystem, String[] parts, boolean absolute); @Override boolean isAbsolute(); @Override Path getRoot(); @Override Path getFileName(); @Override Path getParent(); @Override int getNameCount(); @Override Path getName(int i); @Override Path subpath(int i, int i2); @Override boolean startsWith(Path path); @Override boolean startsWith(String s); @Override boolean endsWith(Path path); @Override boolean endsWith(String s); @Override Path normalize(); @Override Path resolve(Path path); @Override Path resolve(String s); @Override Path resolveSibling(Path path); @Override Path resolveSibling(String s); @Override Path relativize(Path path); @Override URI toUri(); @Override Path toAbsolutePath(); @Override Path toRealPath(LinkOption... linkOptions); @Override File toFile(); @Override WatchKey register(WatchService watchService, WatchEvent.Kind<?>[] kinds, WatchEvent.Modifier... modifiers); @Override WatchKey register(WatchService watchService, WatchEvent.Kind<?>... kinds); @Override Iterator<Path> iterator(); @Override int compareTo(Path path); String toString(); String getString();  }### Answer:
@Test public void testGetParent() { List<Path> roots = new LinkedList<Path>(); roots.add(mockGlusterPath); doReturn(roots).when(mockFileSystem).getRootDirectories(); Path p = new GlusterPath(mockFileSystem, "/"); assertEquals(mockGlusterPath, p.getParent()); p = new GlusterPath(mockFileSystem, "/bar"); assertEquals(mockGlusterPath, p.getParent()); p = new GlusterPath(mockFileSystem, "/bar/baz"); assertEquals(new GlusterPath(mockFileSystem, "/bar"), p.getParent()); p = new GlusterPath(mockFileSystem, "foo/bar"); assertEquals(new GlusterPath(mockFileSystem, "foo"), p.getParent()); p = new GlusterPath(mockFileSystem, "bar"); assertEquals(null, p.getParent()); verify(mockFileSystem, times(2)).getRootDirectories(); }