Skip to content

Commit

Permalink
Adding AbortMPU unit tests plus adding from Pb checks to existing lif…
Browse files Browse the repository at this point in the history
…ecycle action tests
  • Loading branch information
sydney-munro committed Apr 14, 2022
1 parent 21542a7 commit 8276600
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@
import com.google.cloud.storage.BucketInfo.IamConfiguration;
import com.google.cloud.storage.BucketInfo.IsLiveDeleteRule;
import com.google.cloud.storage.BucketInfo.LifecycleRule;
import com.google.cloud.storage.BucketInfo.LifecycleRule.AbortIncompleteMPUAction;
import com.google.cloud.storage.BucketInfo.LifecycleRule.DeleteLifecycleAction;
import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleAction;
import com.google.cloud.storage.BucketInfo.LifecycleRule.LifecycleCondition;
import com.google.cloud.storage.BucketInfo.LifecycleRule.SetStorageClassLifecycleAction;
import com.google.cloud.storage.BucketInfo.NumNewerVersionsDeleteRule;
import com.google.cloud.storage.BucketInfo.PublicAccessPrevention;
import com.google.cloud.storage.BucketInfo.RawDeleteRule;
Expand Down Expand Up @@ -331,6 +334,8 @@ public void testLifecycleRules() {
assertEquals(
LifecycleRule.DeleteLifecycleAction.TYPE, deleteLifecycleRule.getAction().getType());
assertEquals(10, deleteLifecycleRule.getCondition().getAge().intValue());
assertTrue(LifecycleRule.fromPb(deleteLifecycleRule).getAction()
instanceof DeleteLifecycleAction);

Rule setStorageClassLifecycleRule =
new LifecycleRule(
Expand All @@ -346,6 +351,8 @@ public void testLifecycleRules() {
setStorageClassLifecycleRule.getAction().getStorageClass());
assertTrue(setStorageClassLifecycleRule.getCondition().getIsLive());
assertEquals(10, setStorageClassLifecycleRule.getCondition().getNumNewerVersions().intValue());
assertTrue(LifecycleRule.fromPb(setStorageClassLifecycleRule).getAction()
instanceof SetStorageClassLifecycleAction);

Rule lifecycleRule =
new LifecycleRule(
Expand All @@ -367,6 +374,19 @@ public void testLifecycleRules() {
assertEquals(StorageClass.COLDLINE.toString(), lifecycleRule.getAction().getStorageClass());
assertEquals(30, lifecycleRule.getCondition().getDaysSinceCustomTime().intValue());
assertNotNull(lifecycleRule.getCondition().getCustomTimeBefore());
assertTrue(LifecycleRule.fromPb(lifecycleRule).getAction()
instanceof SetStorageClassLifecycleAction);

Rule abortMpuLifecycleRule =
new LifecycleRule(LifecycleAction.newAbortIncompleteMPUploadAction(),
LifecycleCondition.newBuilder()
.setAge(10)
.build())
.toPb();
assertEquals(AbortIncompleteMPUAction.TYPE, abortMpuLifecycleRule.getAction().getType());
assertEquals(10, abortMpuLifecycleRule.getCondition().getAge().intValue());
assertTrue(LifecycleRule.fromPb(abortMpuLifecycleRule).getAction()
instanceof AbortIncompleteMPUAction);

Rule unsupportedRule =
new LifecycleRule(
Expand Down

0 comments on commit 8276600

Please sign in to comment.