test_class.declarator: log
test_class.original_string: Log log;
test_class.type: Log
test_class.var_name: log
test_class.declarator: wrapper
test_class.original_string: Wrapper wrapper;
test_class.type: Wrapper
test_class.var_name: wrapper
test_class.file: tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/maven/terraform/mojo/WrapperTest.java
test_class.identifier: WrapperTest
test_case.body: @Test
    public void theFilesAreCreatedAndPutInsideTheTfDirectoryWithDefaults() throws MojoFailureException, MojoExecutionException, IOException {
      Path tfPath = Paths.get(".tf");
      String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"};
      File tfDir = tfPath.toFile();
  
      try {
        if (tfDir.exists()) {
          FileUtils.forceDelete(tfDir);
        }
  
        wrapper.execute();
  
        Mockito.verify(log, Mockito.times(1)).info("Directory .tf is created");
        Assert.assertTrue(tfDir.exists());
        for (String tfwFileName : tfwFileNames) {
          Assert.assertTrue(tfPath.resolve(tfwFileName).toFile().exists());
        }
  
        Properties props = new Properties();
        try (InputStream fis = new FileInputStream(tfPath.resolve(tfwFileNames[3]).toFile())) {
          props.load(fis);
          Assert.assertEquals(props.getProperty("distributionSite"), "https://releases.hashicorp.com");
          Assert.assertEquals(props.getProperty("releaseDir"), "terraform");
          Assert.assertEquals(props.getProperty("releaseName"), "terraform");
          Assert.assertEquals(props.getProperty("releaseVer"), "0.12.25");
          Assert.assertEquals(props.getProperty("releaseOS"), System.getProperty("os.name").contains("indow") ? "windows" : "linux");
          Assert.assertEquals(props.getProperty("releaseSuffix"), "amd64.zip");
        }
  
      } finally {
        if (tfDir.exists()) {
          FileUtils.forceDelete(tfDir);
        }
      }
  
      wrapper.execute();
  
      Assert.assertTrue(tfDir.exists());
      for (String tfwFileName : tfwFileNames) {
        Assert.assertTrue(tfPath.resolve(tfwFileName).toFile().exists());
      }
  
      Properties props = new Properties();
      try (InputStream fis = new FileInputStream(tfPath.resolve(tfwFileNames[3]).toFile())) {
        props.load(fis);
        Assert.assertEquals(props.getProperty("distributionSite"), "https://releases.hashicorp.com");
        Assert.assertEquals(props.getProperty("releaseDir"), "terraform");
        Assert.assertEquals(props.getProperty("releaseName"), "terraform");
        Assert.assertEquals(props.getProperty("releaseVer"), "0.12.25");
        Assert.assertEquals(props.getProperty("releaseOS"), System.getProperty("os.name").contains("indow") ? "windows" : "linux");
        Assert.assertEquals(props.getProperty("releaseSuffix"), "amd64.zip");
      }
      if (tfDir.exists()) {
        try {
          String[]entries = tfDir.list();
          if (entries != null) {
            for (String s: entries) {
              File currentFile = new File(tfDir.getPath(), s);
              try {
                currentFile.delete();
              } catch (Exception e) {
                System.out.printf("Unable to delete %s\n", currentFile);
              }
            }
          }
          tfDir.delete();
        } catch (Exception e) {
          System.out.printf("Unable to delete .tf directory\n");
        }
      }
    }
test_case.class_method_signature: WrapperTest.theFilesAreCreatedAndPutInsideTheTfDirectoryWithDefaults()
test_case.full_signature: @Test public void theFilesAreCreatedAndPutInsideTheTfDirectoryWithDefaults()
test_case.identifier: theFilesAreCreatedAndPutInsideTheTfDirectoryWithDefaults
test_case.invocations: get toFile exists forceDelete execute info verify times assertTrue exists assertTrue exists toFile resolve toFile resolve load assertEquals getProperty assertEquals getProperty assertEquals getProperty assertEquals getProperty assertEquals getProperty contains getProperty assertEquals getProperty exists forceDelete execute assertTrue exists assertTrue exists toFile resolve toFile resolve load assertEquals getProperty assertEquals getProperty assertEquals getProperty assertEquals getProperty assertEquals getProperty contains getProperty assertEquals getProperty exists list getPath delete printf delete printf
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void theFilesAreCreatedAndPutInsideTheTfDirectoryWithDefaults()
focal_class.declarator: indistributionSite
focal_class.modifier: @Parameter( property = "distributionSite")
focal_class.original_string: @Parameter( property = "distributionSite")
    String indistributionSite;
focal_class.type: String
focal_class.var_name: indistributionSite
focal_class.declarator: inreleaseDir
focal_class.modifier: @Parameter(property = "releaseDir")
focal_class.original_string: @Parameter(property = "releaseDir")
    String inreleaseDir;
focal_class.type: String
focal_class.var_name: inreleaseDir
focal_class.declarator: inreleaseName
focal_class.modifier: @Parameter(property = "releaseName")
focal_class.original_string: @Parameter(property = "releaseName")
    String inreleaseName;
focal_class.type: String
focal_class.var_name: inreleaseName
focal_class.declarator: inreleaseVer
focal_class.modifier: @Parameter(property = "releaseVer")
focal_class.original_string: @Parameter(property = "releaseVer")
    String inreleaseVer;
focal_class.type: String
focal_class.var_name: inreleaseVer
focal_class.declarator: inreleaseOS
focal_class.modifier: @Parameter(property = "releaseOS")
focal_class.original_string: @Parameter(property = "releaseOS")
    String inreleaseOS;
focal_class.type: String
focal_class.var_name: inreleaseOS
focal_class.declarator: inreleaseSuffix
focal_class.modifier: @Parameter(property = "releaseSuffix")
focal_class.original_string: @Parameter(property = "releaseSuffix")
    String inreleaseSuffix;
focal_class.type: String
focal_class.var_name: inreleaseSuffix
focal_class.file: tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/terraform/mojo/Wrapper.java
focal_class.identifier: Wrapper
focal_class.class_method_signature: Wrapper.execute()
focal_class.full_signature: @Override public void execute()
focal_class.identifier: execute
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void execute()
focal_class.superclass: extends TerraformMojo<String>
focal_method.body: @Override
  
    public void execute() throws MojoExecutionException, MojoFailureException {
      /*
       * Here we determine the OS in order to add that to the prop file
       */
      final String os_name = System.getProperty("os.name");
      int windowsIndex = os_name.indexOf("indow");
      if (inreleaseOS == null) {
        if (windowsIndex != -1) {
          inreleaseOS = "windows";
        } else {
          inreleaseOS = "linux";
        }
      }
  
      /*
       * Here we create the .tf directory if it doesn't already exist
       */
      final File tf_dir = new File(".tf");
      if (!tf_dir.exists()) {
        if (tf_dir.mkdir()) {
          getLog().info("Directory .tf is created");
        } else {
          getLog().info("Failed to create directory .tf");
        }
      }
  
      /*
       * Here we copy the scripts and properties file (if it doesn't already exist)
       * from the jar file to the .tf directory
       */
      String[] tfwFileNames = {"tfw", "tfw.cmd", "tfw.ps1", "terraform-maven.properties"};
      Path tfWrapperPath = Paths.get(".tf");
      for (String tfwFileName : tfwFileNames) {
        File tfwFile = tfWrapperPath.resolve(tfwFileName).toFile();
        if (!(tfwFileName.endsWith(".properties") && tfwFile.exists())) {
          try {
            FileUtils.copyURLToFile(this.getClass().getClassLoader().getResource("tf/" + tfwFileName), tfWrapperPath.resolve(tfwFileName).toFile());
          } catch (IOException e) {
            throw new MojoExecutionException(String.format("Unable to create %s!", tfwFileName), e);
          }
          tfwFile.setExecutable(true);
        }
      }
  
  
      /*
       * Here we check for command line arguments (if any) and update the properties file
       */
  
      // Read from properties file
      File propFile = new File(String.format(".tf%sterraform-maven.properties", File.separator));
      Properties prop = new Properties();
      prop.setProperty("releaseDir", ".tf");
      try (InputStream fis = new FileInputStream(propFile)) {
        prop.load(fis);
      } catch (IOException e) {
        throw new MojoExecutionException(String.format("Unable to load properties from %s!", propFile.getName()), e);
      }
      // Update properties from command line args if supplied
      if (indistributionSite != null) {
        prop.setProperty("distributionSite", indistributionSite);
      }
      if (inreleaseDir != null) {
        prop.setProperty("releaseDir", inreleaseDir);
      }
      if (inreleaseName != null) {
        prop.setProperty("releaseName", inreleaseName);
      }
      if (inreleaseVer != null) {
        prop.setProperty("releaseVer", inreleaseVer);
      }
      if (inreleaseOS != null) {
        prop.setProperty("releaseOS", inreleaseOS);
      }
      if (inreleaseSuffix != null) {
        prop.setProperty("releaseSuffix", inreleaseSuffix);
      }
  
      // Write to properties file
      try (BufferedWriter propOut = new BufferedWriter(new FileWriter(propFile))) {
        Set<String> keys = prop.stringPropertyNames();
        for (String key : keys) {
          propOut.write(key + "=" + prop.getProperty(key) + "\n");
        }
        propOut.flush();
      } catch (IOException e) {
        throw new MojoExecutionException(String.format("Unable to write properties to %s!", propFile.getName()), e);
      }
    }
focal_method.class_method_signature: Wrapper.execute()
focal_method.full_signature: @Override public void execute()
focal_method.identifier: execute
focal_method.invocations: getProperty indexOf exists mkdir info getLog info getLog get toFile resolve endsWith exists copyURLToFile getResource getClassLoader getClass toFile resolve format setExecutable format setProperty load format getName setProperty setProperty setProperty setProperty setProperty setProperty stringPropertyNames write getProperty flush format getName
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void execute()