### Question:
TerraformUtils { public static Path getTerraformRootModuleDir(String tfmodule) throws IOException, TerraformException { Path path; if (tfmodule.startsWith("tf-examples")) { path = Paths.get("src", "main", tfmodule); } else if (tfmodule.contains(File.separator)) { path = Paths.get(tfmodule); } else { path = Paths.get("src", "main", "tf", tfmodule); } if (!path.toFile().exists()) { throw new TerraformException(String.format("%1$s does not exist", tfmodule)); } return path; } private  TerraformUtils(); static Path getDefaultTerraformRootModuleDir(); static Path getTerraformRootModuleDir(String tfmodule); static Path getDefaultTfModulesDir();  }### Answer:
@Test public void getTerraformRootModuleDirReturnsTheRootModuleDirRelativeToTheSourceDir() throws IOException, TerraformException { Path testModule = Paths.get("src", "main", "tf", "test"); try { FileUtils.copyDirectory( Paths.get("src", "test", "resources", "tf_initialized", "root").toFile(), testModule.toFile() ); Path tfRootModulePath = TerraformUtils.getTerraformRootModuleDir("test"); Assert.assertEquals(Paths.get("src", "main", "tf", "test"), tfRootModulePath); } finally { List<Path> paths = Files.walk(testModule).sorted(Comparator.reverseOrder()).collect(Collectors.toList()); paths.forEach(path -> path.toFile().delete()); } }
@Test public void getTerraformExampleModuleDirReturnsTheRootModuleDirRelativeToTheTfExamplesDir() throws IOException, TerraformException { try { FileUtils.copyDirectory( Paths.get("src", "test", "resources", "tf_initialized", "root").toFile(), Paths.get("src", "main", "tf-examples", "test").toFile() ); Path tfRootModulePath = TerraformUtils.getTerraformRootModuleDir("tf-examples/test"); Assert.assertEquals(Paths.get("src", "main", "tf-examples", "test"), tfRootModulePath); } finally { FileUtils.forceDelete(Paths.get("src", "main", "tf-examples").toFile()); } }