@Test void deleteObjectsEmptyRequest() { AmazonS3 amazonS3 = Mockito.mock(AmazonS3.class); S3Client s3Client = new S3Client(amazonS3, false); List<String> result = s3Client.deleteObjects(bucket, Collections.emptyList()); assertThat(result.size()).isEqualTo(0); verifyNoMoreInteractions(amazonS3); }
List<String> deleteObjects(String bucket, List<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } if (!dryRunEnabled) { keys.forEach(key -> log.info("Deleting: \"{}/{}\"", bucket, key)); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket) .withKeys(keys.toArray(new String[]{})); DeleteObjectsResult deleteObjectsResult = amazonS3.deleteObjects(deleteObjectsRequest); return deleteObjectsResult.getDeletedObjects() .stream() .map(DeleteObjectsResult.DeletedObject::getKey) .collect(Collectors.toList()); } else { return keys.stream() .peek(key -> log.info("Dry run - deleting: \"{}/{}\"", bucket, key)) .collect(Collectors.toList()); } }
S3Client { List<String> deleteObjects(String bucket, List<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } if (!dryRunEnabled) { keys.forEach(key -> log.info("Deleting: \"{}/{}\"", bucket, key)); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket) .withKeys(keys.toArray(new String[]{})); DeleteObjectsResult deleteObjectsResult = amazonS3.deleteObjects(deleteObjectsRequest); return deleteObjectsResult.getDeletedObjects() .stream() .map(DeleteObjectsResult.DeletedObject::getKey) .collect(Collectors.toList()); } else { return keys.stream() .peek(key -> log.info("Dry run - deleting: \"{}/{}\"", bucket, key)) .collect(Collectors.toList()); } } }
S3Client { List<String> deleteObjects(String bucket, List<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } if (!dryRunEnabled) { keys.forEach(key -> log.info("Deleting: \"{}/{}\"", bucket, key)); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket) .withKeys(keys.toArray(new String[]{})); DeleteObjectsResult deleteObjectsResult = amazonS3.deleteObjects(deleteObjectsRequest); return deleteObjectsResult.getDeletedObjects() .stream() .map(DeleteObjectsResult.DeletedObject::getKey) .collect(Collectors.toList()); } else { return keys.stream() .peek(key -> log.info("Dry run - deleting: \"{}/{}\"", bucket, key)) .collect(Collectors.toList()); } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled); }
S3Client { List<String> deleteObjects(String bucket, List<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } if (!dryRunEnabled) { keys.forEach(key -> log.info("Deleting: \"{}/{}\"", bucket, key)); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket) .withKeys(keys.toArray(new String[]{})); DeleteObjectsResult deleteObjectsResult = amazonS3.deleteObjects(deleteObjectsRequest); return deleteObjectsResult.getDeletedObjects() .stream() .map(DeleteObjectsResult.DeletedObject::getKey) .collect(Collectors.toList()); } else { return keys.stream() .peek(key -> log.info("Dry run - deleting: \"{}/{}\"", bucket, key)) .collect(Collectors.toList()); } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);  }
S3Client { List<String> deleteObjects(String bucket, List<String> keys) { if (keys.isEmpty()) { return Collections.emptyList(); } if (!dryRunEnabled) { keys.forEach(key -> log.info("Deleting: \"{}/{}\"", bucket, key)); DeleteObjectsRequest deleteObjectsRequest = new DeleteObjectsRequest(bucket) .withKeys(keys.toArray(new String[]{})); DeleteObjectsResult deleteObjectsResult = amazonS3.deleteObjects(deleteObjectsRequest); return deleteObjectsResult.getDeletedObjects() .stream() .map(DeleteObjectsResult.DeletedObject::getKey) .collect(Collectors.toList()); } else { return keys.stream() .peek(key -> log.info("Dry run - deleting: \"{}/{}\"", bucket, key)) .collect(Collectors.toList()); } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);   }