### Question:
GlusterPath implements Path { @Override public Path subpath(int i, int i2) { if ((0 == i && parts.length <= 1 && parts[0].isEmpty()) || i < 0 || i2 < 0 || i >= parts.length || i2 > parts.length || i > i2) { throw new IllegalArgumentException("invalid indices"); } return new GlusterPath(fileSystem, Arrays.copyOfRange(parts, i, i2), 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(expected = IllegalArgumentException.class) public void testSubpath_negativeStart() { Path p = new GlusterPath(mockFileSystem, "/foo"); p.subpath(-1, 0); }
@Test(expected = IllegalArgumentException.class) public void testSubpath_negativeEnd() { Path p = new GlusterPath(mockFileSystem, "/foo"); p.subpath(0, -1); }
@Test(expected = IllegalArgumentException.class) public void testSubpath_excessiveStart() { Path p = new GlusterPath(mockFileSystem, "/foo"); p.subpath(4, 5); }
@Test(expected = IllegalArgumentException.class) public void testSubpath_excessiveEnd() { Path p = new GlusterPath(mockFileSystem, "/foo"); p.subpath(0, 4); }
@Test(expected = IllegalArgumentException.class) public void testSubpath_Inverted() { Path p = new GlusterPath(mockFileSystem, "/foo"); p.subpath(2, 1); }
@Test public void testSubpath() { Path p = new GlusterPath(mockFileSystem, "/foo/bar/baz"); assertEquals(new GlusterPath(mockFileSystem, new String[]{"foo"}, true), p.subpath(0, 1)); assertEquals(new GlusterPath(mockFileSystem, new String[]{"bar"}, true), p.subpath(1, 2)); assertEquals(new GlusterPath(mockFileSystem, new String[]{"bar", "baz"}, true), p.subpath(1, 3)); p = new GlusterPath(mockFileSystem, "foo/bar/baz"); assertEquals(new GlusterPath(mockFileSystem, new String[]{"foo"}, false), p.subpath(0, 1)); assertEquals(new GlusterPath(mockFileSystem, new String[]{"bar"}, false), p.subpath(1, 2)); assertEquals(new GlusterPath(mockFileSystem, new String[]{"bar", "baz"}, false), p.subpath(1, 3)); }