@Test void isEmptyDryRunForCommonFolderName() { String otherPartition = "table/test/test/partition10"; String folder1 = "table"; String folder2 = "table/test"; String folder3 = "table/test/test"; String folder4 = "table/test/test/partition1"; String filePath = "table/test/test/partition1/test"; String sentinel1 = "table_$folder$"; String sentinel2 = "table/test_$folder$"; String sentinel3 = "table/test/test_$folder$"; String sentinel4 = "table/test/test/partition1_$folder$"; amazonS3.putObject(bucket, filePath, content); amazonS3.putObject(bucket, sentinel1, ""); amazonS3.putObject(bucket, sentinel2, ""); amazonS3.putObject(bucket, sentinel3, ""); amazonS3.putObject(bucket, sentinel4, ""); assertThat(s3ClientDryRun.isEmpty(bucket, folder3, folder4)).isTrue(); assertThat(s3ClientDryRun.isEmpty(bucket, folder3, otherPartition)).isFalse(); assertThat(s3ClientDryRun.isEmpty(bucket, folder2, folder3)).isTrue(); assertThat(s3ClientDryRun.isEmpty(bucket, folder1, folder2)).isTrue(); }
boolean isEmpty(String bucket, String key, String leafKey) { List<S3ObjectSummary> objectsLeftAtPath = amazonS3.listObjectsV2(bucket, key + "/").getObjectSummaries(); if (!dryRunEnabled) { return objectsLeftAtPath.size() == 0; } else { String leafKeySentinel = leafKey + S3SentinelFilesCleaner.SENTINEL_SUFFIX; for (S3ObjectSummary s3ObjectSummary : objectsLeftAtPath) { String currentKey = s3ObjectSummary.getKey(); if (!currentKey.startsWith(leafKey + "/") && !currentKey.equals(leafKeySentinel)) { return false; } } return true; } }
S3Client { boolean isEmpty(String bucket, String key, String leafKey) { List<S3ObjectSummary> objectsLeftAtPath = amazonS3.listObjectsV2(bucket, key + "/").getObjectSummaries(); if (!dryRunEnabled) { return objectsLeftAtPath.size() == 0; } else { String leafKeySentinel = leafKey + S3SentinelFilesCleaner.SENTINEL_SUFFIX; for (S3ObjectSummary s3ObjectSummary : objectsLeftAtPath) { String currentKey = s3ObjectSummary.getKey(); if (!currentKey.startsWith(leafKey + "/") && !currentKey.equals(leafKeySentinel)) { return false; } } return true; } } }
S3Client { boolean isEmpty(String bucket, String key, String leafKey) { List<S3ObjectSummary> objectsLeftAtPath = amazonS3.listObjectsV2(bucket, key + "/").getObjectSummaries(); if (!dryRunEnabled) { return objectsLeftAtPath.size() == 0; } else { String leafKeySentinel = leafKey + S3SentinelFilesCleaner.SENTINEL_SUFFIX; for (S3ObjectSummary s3ObjectSummary : objectsLeftAtPath) { String currentKey = s3ObjectSummary.getKey(); if (!currentKey.startsWith(leafKey + "/") && !currentKey.equals(leafKeySentinel)) { return false; } } return true; } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled); }
S3Client { boolean isEmpty(String bucket, String key, String leafKey) { List<S3ObjectSummary> objectsLeftAtPath = amazonS3.listObjectsV2(bucket, key + "/").getObjectSummaries(); if (!dryRunEnabled) { return objectsLeftAtPath.size() == 0; } else { String leafKeySentinel = leafKey + S3SentinelFilesCleaner.SENTINEL_SUFFIX; for (S3ObjectSummary s3ObjectSummary : objectsLeftAtPath) { String currentKey = s3ObjectSummary.getKey(); if (!currentKey.startsWith(leafKey + "/") && !currentKey.equals(leafKeySentinel)) { return false; } } return true; } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);  }
S3Client { boolean isEmpty(String bucket, String key, String leafKey) { List<S3ObjectSummary> objectsLeftAtPath = amazonS3.listObjectsV2(bucket, key + "/").getObjectSummaries(); if (!dryRunEnabled) { return objectsLeftAtPath.size() == 0; } else { String leafKeySentinel = leafKey + S3SentinelFilesCleaner.SENTINEL_SUFFIX; for (S3ObjectSummary s3ObjectSummary : objectsLeftAtPath) { String currentKey = s3ObjectSummary.getKey(); if (!currentKey.startsWith(leafKey + "/") && !currentKey.equals(leafKeySentinel)) { return false; } } return true; } } S3Client(AmazonS3 amazonS3, boolean dryRunEnabled);   }