@Test public void backendS3operationsWhenAllPropertiesSpecified() throws IOException, InterruptedException { TerraformPlanFileUtils planFileUtils = new TerraformPlanFileUtils(executable, logger); String kmsKeyId = "4d6f7e4-b816-42f5-87b2-c5952285e53c"; String s3BucketKey = "s3: properties.put("kmsKeyId", kmsKeyId); properties.put("planOutputFile", s3BucketKey); planFileUtils.executePlanFileOperation(properties); Mockito.verify(executable, Mockito.times(1)).execute("aws s3 cp test.json s3: }
public String executePlanFileOperation(Properties properties) throws IOException { boolean isPlanFile = properties.containsKey("planOutputFile") || properties.containsKey("plan"); if (isPlanFile) { String planFile = properties.getProperty("planOutputFile") == null ? properties.getProperty("plan") : properties.getProperty("planOutputFile"); String planFileName = planFile.split("/")[planFile.split("/").length - 1]; String backendAction = properties.getProperty("planOutputFile") == null ? "GET" : "PUT"; if (!planFile.equals(planFileName)) { String backendType = planFile.split(":")[0].toLowerCase(); switch (backendType) { case "s3": backendS3operations(backendAction, planFile, properties); break; default: break; } } } return null; }
TerraformPlanFileUtils { public String executePlanFileOperation(Properties properties) throws IOException { boolean isPlanFile = properties.containsKey("planOutputFile") || properties.containsKey("plan"); if (isPlanFile) { String planFile = properties.getProperty("planOutputFile") == null ? properties.getProperty("plan") : properties.getProperty("planOutputFile"); String planFileName = planFile.split("/")[planFile.split("/").length - 1]; String backendAction = properties.getProperty("planOutputFile") == null ? "GET" : "PUT"; if (!planFile.equals(planFileName)) { String backendType = planFile.split(":")[0].toLowerCase(); switch (backendType) { case "s3": backendS3operations(backendAction, planFile, properties); break; default: break; } } } return null; } }
TerraformPlanFileUtils { public String executePlanFileOperation(Properties properties) throws IOException { boolean isPlanFile = properties.containsKey("planOutputFile") || properties.containsKey("plan"); if (isPlanFile) { String planFile = properties.getProperty("planOutputFile") == null ? properties.getProperty("plan") : properties.getProperty("planOutputFile"); String planFileName = planFile.split("/")[planFile.split("/").length - 1]; String backendAction = properties.getProperty("planOutputFile") == null ? "GET" : "PUT"; if (!planFile.equals(planFileName)) { String backendType = planFile.split(":")[0].toLowerCase(); switch (backendType) { case "s3": backendS3operations(backendAction, planFile, properties); break; default: break; } } } return null; } TerraformPlanFileUtils(String tfRootDir, Logger logger);  TerraformPlanFileUtils(Executable executable, Logger logger); }
TerraformPlanFileUtils { public String executePlanFileOperation(Properties properties) throws IOException { boolean isPlanFile = properties.containsKey("planOutputFile") || properties.containsKey("plan"); if (isPlanFile) { String planFile = properties.getProperty("planOutputFile") == null ? properties.getProperty("plan") : properties.getProperty("planOutputFile"); String planFileName = planFile.split("/")[planFile.split("/").length - 1]; String backendAction = properties.getProperty("planOutputFile") == null ? "GET" : "PUT"; if (!planFile.equals(planFileName)) { String backendType = planFile.split(":")[0].toLowerCase(); switch (backendType) { case "s3": backendS3operations(backendAction, planFile, properties); break; default: break; } } } return null; } TerraformPlanFileUtils(String tfRootDir, Logger logger);  TerraformPlanFileUtils(Executable executable, Logger logger); String executePlanFileOperation(Properties properties); }
TerraformPlanFileUtils { public String executePlanFileOperation(Properties properties) throws IOException { boolean isPlanFile = properties.containsKey("planOutputFile") || properties.containsKey("plan"); if (isPlanFile) { String planFile = properties.getProperty("planOutputFile") == null ? properties.getProperty("plan") : properties.getProperty("planOutputFile"); String planFileName = planFile.split("/")[planFile.split("/").length - 1]; String backendAction = properties.getProperty("planOutputFile") == null ? "GET" : "PUT"; if (!planFile.equals(planFileName)) { String backendType = planFile.split(":")[0].toLowerCase(); switch (backendType) { case "s3": backendS3operations(backendAction, planFile, properties); break; default: break; } } } return null; } TerraformPlanFileUtils(String tfRootDir, Logger logger);  TerraformPlanFileUtils(Executable executable, Logger logger); String executePlanFileOperation(Properties properties);  }