Skip to content

Commit

Permalink
test: add tests to cover the MatchesPrefix and MatchesSuffix in LifeC…
Browse files Browse the repository at this point in the history
…yleRules (#1724)
  • Loading branch information
sundarrajanraman committed Oct 20, 2022
1 parent 631b98d commit ddf01ab
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ddf01ab

Please sign in to comment.