Skip to content

Commit

Permalink
chore: Suppressing Warnings (#337)
Browse files Browse the repository at this point in the history
* chore: remove deprecated methods from system test

* chore: use �uniformBucketLevelAccessLockedTime

* chore: suppressing warnings from the tests clases

* chore: used the getUniformBucketLevelAccessLockedTime instead of getBucketPolicyOnlyLockedTime
  • Loading branch information
athakor committed Jun 8, 2020
1 parent ad5182f commit 1a0cefc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
Expand Up @@ -59,8 +59,11 @@ public class BucketInfoTest {
private static final List<Cors> CORS = Collections.singletonList(Cors.newBuilder().build());
private static final List<Acl> DEFAULT_ACL =
Collections.singletonList(Acl.of(User.ofAllAuthenticatedUsers(), Role.WRITER));

@SuppressWarnings({"unchecked", "deprecation"})
private static final List<? extends DeleteRule> DELETE_RULES =
Collections.singletonList(new AgeDeleteRule(5));

private static final List<? extends BucketInfo.LifecycleRule> LIFECYCLE_RULES =
Collections.singletonList(
new BucketInfo.LifecycleRule(
Expand Down Expand Up @@ -102,6 +105,8 @@ public class BucketInfoTest {
private static final List<String> LOCATION_TYPES =
ImmutableList.of("multi-region", "region", "dual-region");
private static final String LOCATION_TYPE = "multi-region";

@SuppressWarnings({"unchecked", "deprecation"})
private static final BucketInfo BUCKET_INFO =
BucketInfo.newBuilder("b")
.setAcl(ACL)
Expand Down Expand Up @@ -131,6 +136,8 @@ public class BucketInfoTest {
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
.setLogging(LOGGING)
.build();

@SuppressWarnings({"unchecked", "deprecation"})
private static final BucketInfo BUCKET_INFO_ARCHIVE =
BucketInfo.newBuilder("b")
.setAcl(ACL)
Expand Down Expand Up @@ -185,6 +192,7 @@ public void testOf() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testBuilder() {
assertEquals("b", BUCKET_INFO.getName());
assertEquals(ACL, BUCKET_INFO.getAcl());
Expand Down Expand Up @@ -221,6 +229,7 @@ public void testToPbAndFromPb() {
compareBuckets(bucketInfo, BucketInfo.fromPb(bucketInfo.toPb()));
}

@SuppressWarnings({"unchecked", "deprecation"})
private void compareBuckets(BucketInfo expected, BucketInfo value) {
assertEquals(expected, value);
assertEquals(expected.getName(), value.getName());
Expand Down Expand Up @@ -252,6 +261,7 @@ private void compareBuckets(BucketInfo expected, BucketInfo value) {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testDeleteRules() {
AgeDeleteRule ageRule = new AgeDeleteRule(10);
assertEquals(10, ageRule.getDaysToLive());
Expand Down
Expand Up @@ -71,8 +71,11 @@ public class BucketTest {
private static final List<Cors> CORS = Collections.singletonList(Cors.newBuilder().build());
private static final List<Acl> DEFAULT_ACL =
Collections.singletonList(Acl.of(User.ofAllAuthenticatedUsers(), WRITER));

@SuppressWarnings({"unchecked", "deprecation"})
private static final List<? extends DeleteRule> DELETE_RULES =
Collections.singletonList(new AgeDeleteRule(5));

private static final List<? extends BucketInfo.LifecycleRule> LIFECYCLE_RULES =
Collections.singletonList(
new LifecycleRule(
Expand All @@ -95,6 +98,8 @@ public class BucketTest {
private static final List<String> LOCATION_TYPES =
ImmutableList.of("multi-region", "region", "dual-region");
private static final String LOCATION_TYPE = "multi-region";

@SuppressWarnings({"unchecked", "deprecation"})
private static final BucketInfo FULL_BUCKET_INFO =
BucketInfo.newBuilder("b")
.setAcl(ACLS)
Expand All @@ -121,6 +126,7 @@ public class BucketTest {
.setRetentionPeriod(RETENTION_PERIOD)
.setRetentionPolicyIsLocked(RETENTION_POLICY_IS_LOCKED)
.build();

private static final BucketInfo BUCKET_INFO =
BucketInfo.newBuilder("b").setMetageneration(42L).build();
private static final String CONTENT_TYPE = "text/plain";
Expand Down Expand Up @@ -478,6 +484,7 @@ public void testCreateWithWrongMetagenerationOptions() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateFromStream() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").setContentType(CONTENT_TYPE).build();
Expand All @@ -493,6 +500,7 @@ public void testCreateFromStream() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateFromStreamNoContentType() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder("b", "n").build();
Expand All @@ -508,6 +516,7 @@ public void testCreateFromStreamNoContentType() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateFromStreamWithOptions() throws Exception {
initializeExpectedBucket(5);
BlobInfo info =
Expand Down Expand Up @@ -552,6 +561,7 @@ public void testCreateFromStreamWithOptions() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateFromStreamWithEncryptionKey() throws Exception {
initializeExpectedBucket(5);
BlobInfo info = BlobInfo.newBuilder(BlobId.of("b", "n")).setContentType(CONTENT_TYPE).build();
Expand All @@ -569,6 +579,7 @@ public void testCreateFromStreamWithEncryptionKey() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateFromStreamNotExists() throws Exception {
initializeExpectedBucket(5);
BlobInfo info =
Expand Down Expand Up @@ -763,6 +774,7 @@ public void testLockRetention() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testToBuilder() {
expect(storage.getOptions()).andReturn(mockOptions).times(4);
replay(storage);
Expand All @@ -773,6 +785,7 @@ public void testToBuilder() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testBuilder() {
initializeExpectedBucket(4);
expect(storage.getOptions()).andReturn(mockOptions).times(4);
Expand Down
Expand Up @@ -684,6 +684,7 @@ public void testCreateBlobWithKmsKeyName() throws IOException {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobFromStream() throws IOException {
Capture<ByteArrayInputStream> capturedStream = Capture.newInstance();

Expand Down Expand Up @@ -711,6 +712,7 @@ public void testCreateBlobFromStream() throws IOException {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobFromStreamDisableGzipContent() throws IOException {
Capture<ByteArrayInputStream> capturedStream = Capture.newInstance();

Expand Down Expand Up @@ -738,6 +740,7 @@ public void testCreateBlobFromStreamDisableGzipContent() throws IOException {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobFromStreamWithEncryptionKey() throws IOException {
ByteArrayInputStream fileStream = new ByteArrayInputStream(BLOB_CONTENT);
BlobInfo.Builder infoBuilder = BLOB_INFO1.toBuilder();
Expand All @@ -757,6 +760,7 @@ public void testCreateBlobFromStreamWithEncryptionKey() throws IOException {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobFromStreamRetryableException() throws IOException {
Capture<ByteArrayInputStream> capturedStream = Capture.newInstance();
ByteArrayInputStream fileStream = new ByteArrayInputStream(BLOB_CONTENT);
Expand Down
Expand Up @@ -236,6 +236,7 @@ public static void afterClass() throws ExecutionException, InterruptedException

private static class CustomHttpTransportFactory implements HttpTransportFactory {
@Override
@SuppressWarnings({"unchecked", "deprecation"})
public HttpTransport create() {
PoolingHttpClientConnectionManager manager = new PoolingHttpClientConnectionManager();
manager.setMaxTotal(1);
Expand Down Expand Up @@ -616,6 +617,7 @@ public void testCreateEmptyBlob() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobStream() {
String blobName = "test-create-blob-stream";
BlobInfo blob = BlobInfo.newBuilder(BUCKET, blobName).setContentType(CONTENT_TYPE).build();
Expand All @@ -630,6 +632,7 @@ public void testCreateBlobStream() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobStreamDisableGzipContent() {
String blobName = "test-create-blob-stream-disable-gzip-compression";
BlobInfo blob = BlobInfo.newBuilder(BUCKET, blobName).setContentType(CONTENT_TYPE).build();
Expand Down Expand Up @@ -660,6 +663,7 @@ public void testCreateBlobFail() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testCreateBlobMd5Fail() {
String blobName = "test-create-blob-md5-fail";
BlobInfo blob =
Expand Down Expand Up @@ -2952,6 +2956,7 @@ public void testGetServiceAccount() {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testBucketWithBucketPolicyOnlyEnabled() throws Exception {
String bucket = RemoteStorageHelper.generateBucketName();
try {
Expand Down Expand Up @@ -3002,7 +3007,7 @@ public void testBucketWithUniformBucketLevelAccessEnabled() throws Exception {
storage.get(bucket, Storage.BucketGetOption.fields(BucketField.IAMCONFIGURATION));

assertTrue(remoteBucket.getIamConfiguration().isUniformBucketLevelAccessEnabled());
assertNotNull(remoteBucket.getIamConfiguration().getBucketPolicyOnlyLockedTime());
assertNotNull(remoteBucket.getIamConfiguration().getUniformBucketLevelAccessLockedTime());
try {
remoteBucket.listAcls();
fail("StorageException was expected.");
Expand All @@ -3021,6 +3026,7 @@ public void testBucketWithUniformBucketLevelAccessEnabled() throws Exception {
}

@Test
@SuppressWarnings({"unchecked", "deprecation"})
public void testEnableAndDisableBucketPolicyOnlyOnExistingBucket() throws Exception {
String bpoBucket = RemoteStorageHelper.generateBucketName();
try {
Expand Down

0 comments on commit 1a0cefc

Please sign in to comment.