### Question:
ExtractUtil { static void moveJavaHomeToTarget(final Path searchRoot, final Path targetDir) { if (Files.isDirectory(searchRoot)) { try { Files.find(searchRoot, 5, JdkFinder::isJavaHome) .map(Path::toAbsolutePath) .map(Path::normalize) .min(Comparator.comparingInt(Path::getNameCount)) .map(ExtractUtil::listFiles) .ifPresent(javaHomeContent -> javaHomeContent.forEach(file -> moveToDirAndReplace(targetDir, file))); } catch (final IOException e) { throw new RuntimeException("Error while searching for local JVMs at '" + searchRoot + "'", e); } } }  static void unZip(final InputStream inputStream, final Path baseDir); static void unTar(final InputStream inputStream, final Path baseDir); static void unTarGzip(final InputStream inputStream, final Path baseDir);  }### Answer:
@Test void unwrapFromNoSubDir(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); createJvmFilesIn(extractDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }
@Test void unwrapFromSingleSubDir(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); final File subDir = createDir(extractDir, "v1.8_242"); createJvmFilesIn(subDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }
@Test void unwrapFromTwoSubDir(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); final File subDir = createDir(createDir(extractDir, "azul"), "v1.8_242"); createJvmFilesIn(subDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }
@Test void unwrapFromOddlyNamedSingleSubDir(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); final File subDir = createDir(extractDir, "bin"); createJvmFilesIn(subDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }
@Test void unwrapFromSubDirWithReadme(@TempDir final File cacheDir) throws IOException { final File extractDir = createDir(cacheDir, UUID.randomUUID().toString()); final File subDir = createDir(extractDir, "v1.8_242"); createFile(extractDir, "README.txt"); createJvmFilesIn(subDir); ExtractUtil.moveJavaHomeToTarget(extractDir.toPath(), cacheDir.toPath()); assertJvmFilesIn(cacheDir); }