### Question:
GlusterPath implements Path { @Override public int compareTo(Path path) { if (!getClass().equals(path.getClass())) { throw new ClassCastException(); } if (!fileSystem.equals(path.getFileSystem())) { throw new IllegalArgumentException("Can not compare other path because it's on a different filesystem"); } GlusterPath other = (GlusterPath) path; String[] otherParts = other.getParts(); for (int i = 0; i < Math.min(parts.length, otherParts.length); i++) { int c = parts[i].compareTo(otherParts[i]); if (c != 0) { return c; } } return parts.length - otherParts.length; } 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(expected = ClassCastException.class) public void testCompareTo_differentProvider() { Path path = new GlusterPath(mockFileSystem, ""); Path zipfile = Paths.get("/codeSamples/zipfs/zipfstest.zip"); path.compareTo(zipfile); }
@Test public void testCompareTo() { Path p = new GlusterPath(mockFileSystem, "/foo"); Path other = new GlusterPath(mockFileSystem, "/bar"); assertTrue(p.compareTo(other) > 0); p = new GlusterPath(mockFileSystem, "/bar"); other = new GlusterPath(mockFileSystem, "/foo"); assertTrue(p.compareTo(other) < 0); p = new GlusterPath(mockFileSystem, "/foo"); other = new GlusterPath(mockFileSystem, "/foo"); assertEquals(0, p.compareTo(other)); p = new GlusterPath(mockFileSystem, "/"); other = new GlusterPath(mockFileSystem, "/foo"); assertTrue(p.compareTo(other) < 0); p = new GlusterPath(mockFileSystem, "/foo"); other = new GlusterPath(mockFileSystem, "/"); assertTrue(p.compareTo(other) > 0); }