AmazonS3Downloader { public static boolean isGZipped(@Nullable final S3Object object) { if (object == null) { return false; } final String encoding = Strings.nullToEmpty(object.getObjectMetadata().getContentEncoding()); if (GZIP_ENCODING.equalsIgnoreCase(encoding.trim())) { return true; } final String key = Strings.nullToEmpty(object.getKey()); return key.trim().toLowerCase().endsWith(GZIP_EXTENSION); } AmazonS3Downloader(@Nonnull final AmazonS3 s3); S3Object fetch(@Nonnull final S3EventNotificationRecord record); static boolean isGZipped(@Nullable final S3Object object);  }
@Test public void testIsGzipped() { assertThat(AmazonS3Downloader.isGZipped(null)).isFalse(); final S3Object object = new S3Object(); assertThat(AmazonS3Downloader.isGZipped(object)).isFalse(); final ObjectMetadata metadata = object.getObjectMetadata(); metadata.setContentEncoding("gzip"); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); metadata.setContentEncoding("GZIP"); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); metadata.setContentEncoding(" GzIP "); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); metadata.setContentEncoding(null); object.setKey("test"); assertThat(AmazonS3Downloader.isGZipped(object)).isFalse(); object.setKey("test.gz"); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); object.setKey("test.gz "); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); object.setKey("test.GZ "); assertThat(AmazonS3Downloader.isGZipped(object)).isTrue(); }