### Question:
TerraformPlanFileUtils { protected void backendS3operations(String action, String s3Key, Properties properties ) throws IOException { try { String bucketName = s3Key.split("/")[2]; String fileName = s3Key.substring(s3Key.lastIndexOf("/")).replaceAll("/", ""); if (action.equals("GET")) { executable.execute(String.format("aws s3api get-object --bucket %1$s --key %2$s %3$s", bucketName, fileName, fileName)); } else if (action.equals("PUT")) { if (properties.containsKey("kmsKeyId")) { LOGGER.debug("uploading plan files to Amazon S3 with kms encryption"); executable.execute(String.format("aws s3 cp %1$s %2$s --sse aws:kms --sse-kms-key-id %3$s", fileName, s3Key, properties.getProperty("kmsKeyId"))); } else { LOGGER.debug("uploading plan files to Amazon S3 with default encryption (SSE:256)"); executable.execute(String.format("aws s3 cp %1$s %2$s", fileName, s3Key)); } } } catch (InterruptedException e) { e.printStackTrace(); } } TerraformPlanFileUtils(String tfRootDir, Logger logger);  TerraformPlanFileUtils(Executable executable, Logger logger); String executePlanFileOperation(Properties properties);  }### Answer:
@Test public void backendS3operationsWhenGetActionSpecified() throws IOException, InterruptedException { TerraformPlanFileUtils planFileUtils = new TerraformPlanFileUtils(executable, logger); String s3BucketKey = "s3: properties.put("planOutputFile", s3BucketKey); planFileUtils.backendS3operations("GET", s3BucketKey, properties); Mockito.verify(executable, Mockito.times(1)).execute("aws s3api get-object --bucket terraform-maven-state --key test.json test.json"); }
@Test public void backendS3operationsWhenPutActionSpecified() throws IOException, InterruptedException { TerraformPlanFileUtils planFileUtils = new TerraformPlanFileUtils(executable, logger); String s3BucketKey = "s3: properties.put("planOutputFile", s3BucketKey); planFileUtils.backendS3operations("PUT", s3BucketKey, properties); Mockito.verify(executable, Mockito.times(1)).execute("aws s3 cp test.json s3: }
@Test public void backendS3operationsWhenPutActionWithKmsKeySpecified() 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.backendS3operations("PUT", s3BucketKey, properties); Mockito.verify(executable, Mockito.times(1)).execute("aws s3 cp test.json s3: }