diff --git a/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java b/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java index d3362a02b..e6f82aecf 100644 --- a/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateAllocationTokensCommand.java @@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.collect.Sets.difference; import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.DEFAULT; +import static google.registry.model.domain.token.AllocationToken.TokenType.DEFAULT_PROMO; import static google.registry.model.domain.token.AllocationToken.TokenType.PACKAGE; import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE; import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE; @@ -259,6 +260,10 @@ class GenerateAllocationTokensCommand implements Command { !(UNLIMITED_USE.equals(tokenType) && CollectionUtils.isNullOrEmpty(tokenStatusTransitions)), "For UNLIMITED_USE tokens, must specify --token_status_transitions"); + checkArgument( + !(DEFAULT_PROMO.equals(tokenType) && CollectionUtils.isNullOrEmpty(tokenStatusTransitions)), + "For DEFAULT_PROMO tokens, must specify --token_status_transitions"); + // A list consisting solely of the empty string means user error when formatting parameters checkArgument( !ImmutableList.of("").equals(allowedClientIds), diff --git a/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java b/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java index df927c922..1a95de87c 100644 --- a/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateAllocationTokensCommandTest.java @@ -440,6 +440,16 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase runCommand("--number", "999", "--type", "DEFAULT_PROMO"))) + .hasMessageThat() + .isEqualTo("For DEFAULT_PROMO tokens, must specify --token_status_transitions"); + } + private AllocationToken createToken( String token, @Nullable HistoryEntryId redemptionHistoryEntryId,