### Question:
GlusterPath implements Path { @Override public URI toUri() { try { GlusterFileSystem fs = getFileSystem(); String authority = fs.getHost() + ":" + fs.getVolname(); return new URI(fs.provider().getScheme(), authority, toString(), null, null); } catch (URISyntaxException e) { throw new IllegalStateException(e); } } 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 testToUri() throws URISyntaxException { GlusterFileSystemProvider mockProvider = mock(GlusterFileSystemProvider.class); String scheme = GlusterFileSystemProvider.GLUSTER; doReturn(scheme).when(mockProvider).getScheme(); doReturn(mockProvider).when(mockFileSystem).provider(); String host = "localhost"; doReturn(host).when(mockFileSystem).getHost(); String volname = "foo"; doReturn(volname).when(mockFileSystem).getVolname(); String path = "/foo/bar"; GlusterPath p = spy(new GlusterPath(mockFileSystem, path)); doReturn(mockFileSystem).when(p).getFileSystem(); doReturn(path).when(p).toString(); String authority = host + ":" + volname; URI expected = new URI(scheme, authority, path, null, null); assertEquals(expected, p.toUri()); }