mirror of
https://github.com/google/nomulus
synced 2026-07-31 20:36:09 +00:00
Add discount price param to GenerateAllocationTokens command (#2578)
* Add discount price param to GenerateAlloCationTokens command * add discount price param to UpdateAllocationTokens command
This commit is contained in:
@@ -164,6 +164,48 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_promotionToken_withDiscountPrice() throws Exception {
|
||||
DateTime promoStart = DateTime.now(UTC);
|
||||
DateTime promoEnd = promoStart.plusMonths(1);
|
||||
runCommand(
|
||||
"--number",
|
||||
"1",
|
||||
"--prefix",
|
||||
"promo",
|
||||
"--type",
|
||||
"UNLIMITED_USE",
|
||||
"--allowed_client_ids",
|
||||
"TheRegistrar,NewRegistrar",
|
||||
"--allowed_tlds",
|
||||
"tld,example",
|
||||
"--allowed_epp_actions",
|
||||
"CREATE,RENEW",
|
||||
"--discount_price",
|
||||
"USD 3",
|
||||
"--discount_years",
|
||||
"6",
|
||||
"--token_status_transitions",
|
||||
String.format("%s=NOT_STARTED,%s=VALID,%s=ENDED", START_OF_TIME, promoStart, promoEnd));
|
||||
assertAllocationTokens(
|
||||
new AllocationToken.Builder()
|
||||
.setToken("promo123456789ABCDEFG")
|
||||
.setTokenType(UNLIMITED_USE)
|
||||
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar", "NewRegistrar"))
|
||||
.setAllowedTlds(ImmutableSet.of("tld", "example"))
|
||||
.setAllowedEppActions(ImmutableSet.of(CommandName.CREATE, CommandName.RENEW))
|
||||
.setDiscountPrice(Money.of(CurrencyUnit.USD, 3))
|
||||
.setDiscountPremiums(false)
|
||||
.setDiscountYears(6)
|
||||
.setTokenStatusTransitions(
|
||||
ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
|
||||
.put(START_OF_TIME, TokenStatus.NOT_STARTED)
|
||||
.put(promoStart, TokenStatus.VALID)
|
||||
.put(promoEnd, TokenStatus.ENDED)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_specifyTokens() throws Exception {
|
||||
runCommand("--tokens", "foobar,foobaz");
|
||||
|
||||
@@ -141,6 +141,16 @@ class UpdateAllocationTokensCommandTest extends CommandTestCase<UpdateAllocation
|
||||
assertThat(reloadResource(token).getDiscountFraction()).isEqualTo(0.15);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateDiscountPrice() throws Exception {
|
||||
AllocationToken token =
|
||||
persistResource(
|
||||
builderWithPromo().setDiscountPrice(Money.of(CurrencyUnit.USD, 10)).build());
|
||||
runCommandForced("--prefix", "token", "--discount_price", "USD 2.15");
|
||||
assertThat(reloadResource(token).getDiscountPrice().get())
|
||||
.isEqualTo(Money.of(CurrencyUnit.USD, 2.15));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdateDiscountPremiums() throws Exception {
|
||||
AllocationToken token =
|
||||
|
||||
Reference in New Issue
Block a user