test_class.declarator: project = new MavenProject()
test_class.modifier: private
test_class.original_string: private MavenProject project = new MavenProject();
test_class.type: MavenProject
test_class.var_name: project
test_class.declarator: targetTfRootModule
test_class.modifier: private
test_class.original_string: private Path targetTfRootModule;
test_class.type: Path
test_class.var_name: targetTfRootModule
test_class.declarator: terraformPackage
test_class.modifier: private
test_class.original_string: private TerraformPackage terraformPackage;
test_class.type: TerraformPackage
test_class.var_name: terraformPackage
test_class.declarator: tfModules
test_class.modifier: private
test_class.original_string: private Path tfModules;
test_class.type: Path
test_class.var_name: tfModules
test_class.declarator: tfRoot
test_class.modifier: private
test_class.original_string: private Path tfRoot;
test_class.type: Path
test_class.var_name: tfRoot
test_class.declarator: tfVarFiles
test_class.modifier: private
test_class.original_string: private List<Path> tfVarFiles;
test_class.type: List<Path>
test_class.var_name: tfVarFiles
test_class.declarator: properties
test_class.modifier: private
test_class.original_string: private Properties properties;
test_class.type: Properties
test_class.var_name: properties
test_class.file: tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/maven/terraform/TerraformPackageTest.java
test_class.identifier: TerraformPackageTest
test_case.body: @Test
    public void packageWithFatTarPackagesTfModulesInsideTfRootInTheTargetDir() throws IOException, TerraformException {
      properties.put(TerraformPackageParams.fatTar.toString(), true);
      String response = this.terraformPackage.execute(properties);
      Path tarFilePath = Paths.get(TerraformPackage.targetDir)
          .resolve(String.format("%1$s-%2$s.tar.gz", project.getArtifactId(), project.getVersion()));
  
      Assert.assertEquals(response, String.format("Created fatTar gzipped tar file '%1$s'", tarFilePath.toString()));
      Assert.assertEquals(5, this.targetTfRootModule.toFile().listFiles().length);
      Assert.assertEquals("dev1.auto.tfvars,dev2.auto.tfvars,main.tf",
          Files.walk(this.targetTfRootModule, 1)
          .filter(path -> !path.toFile().isDirectory())
          .map(path -> path.getFileName().toString())
            .sorted()
          .collect(Collectors.joining(",")));
      Assert.assertEquals(2, Files.walk(this.targetTfRootModule.resolve(tfModules.getFileName().toString()).resolve("test-module"), 1)
          .filter(path -> path.getFileName().toString().equals("main.tf")
          || path.getFileName().toString().equals("variables.tf"))
          .count());
  
      //validate that the path got changed in the Terraform source
      Path targetMainTf = Paths.get(TerraformPackage.targetDir, TerraformPackage.targetTfRootDir, "main.tf");
      try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(targetMainTf)))) {
        String tfModulesString = Paths.get(tfModules.getFileName().toString()).toString();
        int count = 0;
        while (reader.ready()) {
          String line = reader.readLine();
          if (line.trim().startsWith("source") && line.contains(String.format("\"%1$s/", tfModulesString))) count++;
        }
        Assert.assertEquals(1, count);
      }
  
      try (TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(tarFilePath.toString())))) {
        int count = 0;
        TarArchiveEntry entry;
        Set<String> tarEntryNames = new HashSet<>();
        while ((entry = tarArchiveInputStream.getNextTarEntry()) != null) {
          count++;
          tarEntryNames.add(entry.getName());
        }
  
        Assert.assertEquals(10, count);
        Assert.assertTrue(tarEntryNames.contains("main.tf"));
        Assert.assertTrue(tarEntryNames.contains("dev1.auto.tfvars"));
        Assert.assertTrue(tarEntryNames.contains("dev2.auto.tfvars"));
        Assert.assertTrue(tarEntryNames.contains("tfmodules/test-module/main.tf"));
        Assert.assertTrue(tarEntryNames.contains("tfmodules/test-module/variables.tf"));
      }
    }
test_case.class_method_signature: TerraformPackageTest.packageWithFatTarPackagesTfModulesInsideTfRootInTheTargetDir()
test_case.full_signature: @Test public void packageWithFatTarPackagesTfModulesInsideTfRootInTheTargetDir()
test_case.identifier: packageWithFatTarPackagesTfModulesInsideTfRootInTheTargetDir
test_case.invocations: put toString execute resolve get format getArtifactId getVersion assertEquals format toString assertEquals listFiles toFile assertEquals collect sorted map filter walk isDirectory toFile toString getFileName joining assertEquals count filter walk resolve resolve toString getFileName equals toString getFileName equals toString getFileName get newInputStream toString get toString getFileName ready readLine startsWith trim contains format assertEquals toString getNextTarEntry add getName assertEquals assertTrue contains assertTrue contains assertTrue contains assertTrue contains assertTrue contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void packageWithFatTarPackagesTfModulesInsideTfRootInTheTargetDir()
focal_class.declarator: targetDir = "target"
focal_class.modifier: static final
focal_class.original_string: static final String targetDir = "target";
focal_class.type: String
focal_class.var_name: targetDir
focal_class.declarator: targetTfRootDir = "tf-root-module"
focal_class.modifier: static final
focal_class.original_string: static final String targetTfRootDir = "tf-root-module";
focal_class.type: String
focal_class.var_name: targetTfRootDir
focal_class.declarator: excludedFiles = Arrays.asList(new String[] {".terraform", "terraform.tfstate", "terraform.tfstate.backup", ".terraform.tfstate.lock.info"})
focal_class.modifier: static final
focal_class.original_string: static final List<String> excludedFiles = Arrays.asList(new String[] {".terraform", "terraform.tfstate", "terraform.tfstate.backup", ".terraform.tfstate.lock.info"});
focal_class.type: List<String>
focal_class.var_name: excludedFiles
focal_class.declarator: logger
focal_class.modifier: private
focal_class.original_string: private Logger logger;
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: project
focal_class.modifier: private
focal_class.original_string: private MavenProject project;
focal_class.type: MavenProject
focal_class.var_name: project
focal_class.file: tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/terraform/TerraformPackage.java
focal_class.identifier: TerraformPackage
focal_class.interfaces: implements TerraformOperation<String>
focal_class.class_method_signature: TerraformPackage.TerraformPackage(MavenProject project, Logger logger)
focal_class.full_signature: public  TerraformPackage(MavenProject project, Logger logger)
focal_class.identifier: TerraformPackage
focal_class.modifiers: public
focal_class.parameters: (MavenProject project, Logger logger)
focal_class.signature:  TerraformPackage(MavenProject project, Logger logger)
focal_class.class_method_signature: TerraformPackage.TerraformPackage(MavenProject project, Log log)
focal_class.full_signature: public  TerraformPackage(MavenProject project, Log log)
focal_class.identifier: TerraformPackage
focal_class.modifiers: public
focal_class.parameters: (MavenProject project, Log log)
focal_class.signature:  TerraformPackage(MavenProject project, Log log)
focal_class.class_method_signature: TerraformPackage.TerraformPackage(MavenProject project)
focal_class.full_signature: public  TerraformPackage(MavenProject project)
focal_class.identifier: TerraformPackage
focal_class.modifiers: public
focal_class.parameters: (MavenProject project)
focal_class.signature:  TerraformPackage(MavenProject project)
focal_class.class_method_signature: TerraformPackage.execute(Properties properties)
focal_class.full_signature: @Override public String execute(Properties properties)
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: (Properties properties)
focal_class.return: String
focal_class.signature: String execute(Properties properties)
focal_class.class_method_signature: TerraformPackage.updateDependenciesInTfRoot(Path targetTfRootPath, Path tfModulesPath, Path tfRootPath)
focal_class.full_signature: private void updateDependenciesInTfRoot(Path targetTfRootPath, Path tfModulesPath, Path tfRootPath)
focal_class.identifier: updateDependenciesInTfRoot
focal_class.modifiers: private
focal_class.parameters: (Path targetTfRootPath, Path tfModulesPath, Path tfRootPath)
focal_class.return: void
focal_class.signature: void updateDependenciesInTfRoot(Path targetTfRootPath, Path tfModulesPath, Path tfRootPath)
focal_class.class_method_signature: TerraformPackage.createZip(Path targetDir, Path targetTfRootPath)
focal_class.full_signature: private String createZip(Path targetDir, Path targetTfRootPath)
focal_class.identifier: createZip
focal_class.modifiers: private
focal_class.parameters: (Path targetDir, Path targetTfRootPath)
focal_class.return: String
focal_class.signature: String createZip(Path targetDir, Path targetTfRootPath)
focal_class.class_method_signature: TerraformPackage.createGZippedTar(Path targetDir, Path targetTfRootPath)
focal_class.full_signature: private String createGZippedTar(Path targetDir, Path targetTfRootPath)
focal_class.identifier: createGZippedTar
focal_class.modifiers: private
focal_class.parameters: (Path targetDir, Path targetTfRootPath)
focal_class.return: String
focal_class.signature: String createGZippedTar(Path targetDir, Path targetTfRootPath)
focal_method.body: @Override
    public String execute(Properties properties) throws TerraformException {
      try {
        Path targetPath = Paths.get(targetDir);
        Path targetTfRootPath = targetPath.resolve(targetTfRootDir);
        String tfModulesDir = properties.getProperty(TerraformPackageParams.tfModulesDir.toString());
        String tfRootDir = properties.getProperty(TerraformPackageParams.tfRootDir.toString());
        String tfVarFiles = properties.getProperty(TerraformPackageParams.tfVarFiles.toString());
  
        Object isFatTarObj = properties.getOrDefault(TerraformPackageParams.fatTar.toString(), false);
        boolean isFatTar = isFatTarObj instanceof Boolean ? (Boolean)isFatTarObj : Boolean.valueOf(isFatTarObj.toString());
  
        Path tfModulesPath = !StringUtils.isEmpty(tfModulesDir)
            ? Paths.get(tfModulesDir)
            : TerraformUtils.getDefaultTfModulesDir();
        logger.debug(String.format("tfModulesPath is %1$s", tfModulesPath.toAbsolutePath().toString()));
  
        File tfSourceFile = Paths.get("src", "main", "tf").toFile();
        Path tfRootPath = !StringUtils.isEmpty(tfRootDir)
            ? TerraformUtils.getTerraformRootModuleDir(tfRootDir)
            : (tfSourceFile.exists() && tfSourceFile.isDirectory() && tfSourceFile.listFiles().length > 1
                ? tfSourceFile.toPath()
                : TerraformUtils.getDefaultTerraformRootModuleDir());
        logger.debug(String.format("tfRootPath is %1$s", tfRootPath.toAbsolutePath().toString()));
  
        List<Path> tfVarFilePaths = StringUtils.isEmpty(tfVarFiles)
            ? new ArrayList<>()
            : Arrays.stream(tfVarFiles.split(","))
            .map(x -> tfRootPath.resolve(x.trim()))
            .collect(Collectors.toList());
        logger.debug(String.format("tfVarFiles is %1$s", tfVarFilePaths));
  
        //copy tfRoot directory to target
        if (targetTfRootPath.toFile().exists()) FileUtils.forceDelete(targetTfRootPath.toFile());
  
        FileUtils.forceMkdir(targetTfRootPath.toFile());
        List<Path> tfRootDirFiles = Files.walk(tfRootPath, 1)
            .filter(path -> !path.equals(tfRootPath))
            .collect(Collectors.toList());
  
        for (Path file : tfRootDirFiles.stream().filter(f -> !excludedFiles.contains(f.getFileName().toString())).collect(Collectors.toList())) {
          if (file.toFile().isDirectory()) {
            FileUtils.copyDirectory(file.toFile(), targetTfRootPath.resolve(file.getFileName().toString()).toFile(), new FileFilter() {
              @Override
              public boolean accept(File pathname) {
                return excludedFiles.stream().noneMatch(excludedFile -> pathname.getName().endsWith(excludedFile));
              }
            });
          } else {
            Files.copy(file, targetTfRootPath.resolve(file.getFileName().toString()));
          }
        }
  
        for (Path tfVarFilePath : tfVarFilePaths) {
          Files.copy(tfVarFilePath, targetTfRootPath.resolve(tfVarFilePath.getFileName().toString().replaceAll(".tfvars", "").concat(".auto.tfvars")));
        }
  
        if (isFatTar) {
          updateDependenciesInTfRoot(targetTfRootPath, tfModulesPath, tfRootPath);
          //copy tfmodules directory into tfRoot directory; i.e. {targetTfRootDir}/{tfModulesDir} if it exists
          if (tfModulesPath.toFile().exists() && tfModulesPath.toFile().isDirectory()) {
            FileUtils.copyDirectory(tfModulesPath.toFile(), targetTfRootPath.resolve(tfModulesPath.getFileName().toString()).toFile());
          }
          return String.format("Created fatTar gzipped tar file '%1$s'", createGZippedTar(targetPath, targetTfRootPath));
        }
        return String.format("Created zip file '%1$s'", createZip(targetPath, targetTfRootPath));
      } catch (IOException e) {
        throw new TerraformException(e.getMessage(), e);
      }
    }
focal_method.class_method_signature: TerraformPackage.execute(Properties properties)
focal_method.full_signature: @Override public String execute(Properties properties)
focal_method.identifier: execute
focal_method.invocations: get resolve getProperty toString getProperty toString getProperty toString getOrDefault toString valueOf toString isEmpty get getDefaultTfModulesDir debug format toString toAbsolutePath toFile get isEmpty getTerraformRootModuleDir exists isDirectory listFiles toPath getDefaultTerraformRootModuleDir debug format toString toAbsolutePath isEmpty collect map stream split resolve trim toList debug format exists toFile forceDelete toFile forceMkdir toFile collect filter walk equals toList collect filter stream contains toString getFileName toList isDirectory toFile copyDirectory toFile toFile resolve toString getFileName noneMatch stream endsWith getName copy resolve toString getFileName copy resolve concat replaceAll toString getFileName updateDependenciesInTfRoot exists toFile isDirectory toFile copyDirectory toFile toFile resolve toString getFileName format createGZippedTar format createZip getMessage
focal_method.modifiers: @Override public
focal_method.parameters: (Properties properties)
focal_method.return: String
focal_method.signature: String execute(Properties properties)