### Question:
PathUtils { public static Path getCommonPath(Path path1, Path path2){ Path commonPath = Paths.get(""); if(path1 == null || path2 == null){ return commonPath; } Iterator<Path> iterPath1 = path1.iterator(); Iterator<Path> iterPath2 = path2.iterator(); while(iterPath1.hasNext() && iterPath2.hasNext()){ Path next1 = iterPath1.next(); if(next1.equals(iterPath2.next())){ commonPath = commonPath.resolve(next1); } else { break; } } return commonPath; }  static String computeFileContentHash(Path path); static String base64Encode(byte[] bytes); static byte[] base64Decode(String data); static boolean isFileHidden(Path file); static Path getCommonPath(Path path1, Path path2);  }### Answer:
@Test public void getCommonPathTest(){ Path emptyPath = Paths.get(""); Path dir1file1 = Paths.get("dir1/file1"); Path dir1dir2file1 = Paths.get("dir1/dir2/file1"); Path dir1dir2file2 = Paths.get("dir1/dir2/file2"); Path dir1dir3 = Paths.get("dir1/dir3"); Path result = PathUtils.getCommonPath(null, dir1file1); assertEquals(result.toString(), ""); result = PathUtils.getCommonPath(emptyPath, dir1file1); assertEquals(result.toString(), ""); result = PathUtils.getCommonPath(dir1file1, dir1dir2file1); assertEquals(result.toString(), "dir1"); result = PathUtils.getCommonPath(dir1file1, dir1dir3); assertEquals(result.toString(), "dir1"); result = PathUtils.getCommonPath(dir1dir2file1, dir1dir2file2); assertEquals(result, Paths.get("dir1", "dir2")); }