diff --git a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java index e05d9747c..6a2ca2316 100644 --- a/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java +++ b/google-cloud-storage/src/test/java/com/google/cloud/storage/BucketInfoTest.java @@ -328,12 +328,31 @@ public void testLifecycleRules() { Rule deleteLifecycleRule = new LifecycleRule( LifecycleAction.newDeleteAction(), - LifecycleCondition.newBuilder().setAge(10).build()) + LifecycleCondition.newBuilder() + .setAge(10) + .setMatchesPrefix(Arrays.asList("abc", "ijk")) + .setMatchesSuffix(Arrays.asList("xyz")) + .build()) .toPb(); assertEquals( LifecycleRule.DeleteLifecycleAction.TYPE, deleteLifecycleRule.getAction().getType()); assertEquals(10, deleteLifecycleRule.getCondition().getAge().intValue()); + assertEquals(2, deleteLifecycleRule.getCondition().getMatchesPrefix().size()); + assertEquals("abc", (String) deleteLifecycleRule.getCondition().getMatchesPrefix().get(0)); + assertEquals("ijk", (String) deleteLifecycleRule.getCondition().getMatchesPrefix().get(1)); + assertEquals(1, deleteLifecycleRule.getCondition().getMatchesSuffix().size()); + assertEquals("xyz", deleteLifecycleRule.getCondition().getMatchesSuffix().get(0)); + + LifecycleRule lcr = LifecycleRule.fromPb(deleteLifecycleRule); + assertEquals(LifecycleRule.DeleteLifecycleAction.TYPE, lcr.getAction().getActionType()); + assertEquals(10, lcr.getCondition().getAge().intValue()); + assertEquals(2, lcr.getCondition().getMatchesPrefix().size()); + assertEquals("abc", (String) lcr.getCondition().getMatchesPrefix().get(0)); + assertEquals("ijk", (String) lcr.getCondition().getMatchesPrefix().get(1)); + assertEquals(1, lcr.getCondition().getMatchesSuffix().size()); + assertEquals("xyz", lcr.getCondition().getMatchesSuffix().get(0)); + assertTrue( LifecycleRule.fromPb(deleteLifecycleRule).getAction() instanceof DeleteLifecycleAction);