mirror of
https://github.com/google/nomulus
synced 2026-09-26 09:54:28 +00:00
Add clientId and time parameters to pricing methods
This is a broken-out refactoring from [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=121603352
This commit is contained in:
@@ -179,9 +179,10 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
|
||||
.setReason(Reason.CREATE)
|
||||
.setTargetId(getUniqueIdFromCommand())
|
||||
.setClientId("TheRegistrar")
|
||||
.setCost(Registry.get(domainTld).isPremiumName(getUniqueIdFromCommand())
|
||||
? Money.of(USD, 200)
|
||||
: Money.of(USD, 26))
|
||||
.setCost(Registry.get(domainTld)
|
||||
.isPremiumName(getUniqueIdFromCommand(), clock.nowUtc(), "TheRegistrar")
|
||||
? Money.of(USD, 200)
|
||||
: Money.of(USD, 26))
|
||||
.setPeriodYears(2)
|
||||
.setEventTime(clock.nowUtc())
|
||||
.setBillingTime(billingTime)
|
||||
|
||||
@@ -185,6 +185,7 @@ public class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
|
||||
return createBillingEventForTransfer(
|
||||
domain,
|
||||
historyEntry,
|
||||
"NewRegistrar",
|
||||
TRANSFER_REQUEST_TIME,
|
||||
TRANSFER_EXPIRATION_TIME,
|
||||
EXTENDED_REGISTRATION_YEARS);
|
||||
|
||||
@@ -311,9 +311,9 @@ public class RegistryTest extends EntityTestCase {
|
||||
public void testIsPremiumDomain() throws Exception {
|
||||
createTld("example");
|
||||
Registry registry = Registry.get("example");
|
||||
assertThat(registry.isPremiumName("poor.example")).isFalse();
|
||||
assertThat(registry.isPremiumName("rich.example")).isTrue();
|
||||
assertThat(registry.isPremiumName("richer.example")).isTrue();
|
||||
assertThat(registry.isPremiumName("poor.example", clock.nowUtc(), "TheRegistrar")).isFalse();
|
||||
assertThat(registry.isPremiumName("rich.example", clock.nowUtc(), "TheRegistrar")).isTrue();
|
||||
assertThat(registry.isPremiumName("richer.example", clock.nowUtc(), "TheRegistrar")).isTrue();
|
||||
}
|
||||
|
||||
public void testGetDomainCreateCost() throws Exception {
|
||||
@@ -321,10 +321,14 @@ public class RegistryTest extends EntityTestCase {
|
||||
createTld("example");
|
||||
Registry registry = Registry.get("example");
|
||||
// The default value of 17 is set in createTld().
|
||||
assertThat(registry.getDomainCreateCost("poor.example", 1)).isEqualTo(Money.of(USD, 13));
|
||||
assertThat(registry.getDomainCreateCost("poor.example", 2)).isEqualTo(Money.of(USD, 26));
|
||||
assertThat(registry.getDomainCreateCost("rich.example", 1)).isEqualTo(Money.of(USD, 100));
|
||||
assertThat(registry.getDomainCreateCost("rich.example", 2)).isEqualTo(Money.of(USD, 200));
|
||||
assertThat(registry.getDomainCreateCost("poor.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 13));
|
||||
assertThat(registry.getDomainCreateCost("poor.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 26));
|
||||
assertThat(registry.getDomainCreateCost("rich.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 100));
|
||||
assertThat(registry.getDomainCreateCost("rich.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 200));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -336,21 +340,21 @@ public class RegistryTest extends EntityTestCase {
|
||||
START_OF_TIME, Money.of(USD, 8),
|
||||
clock.nowUtc(), Money.of(USD, 10)))
|
||||
.build();
|
||||
assertThat(registry.getDomainRenewCost("poor.example", 1, START_OF_TIME))
|
||||
assertThat(registry.getDomainRenewCost("poor.example", START_OF_TIME, "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 8));
|
||||
assertThat(registry.getDomainRenewCost("poor.example", 2, START_OF_TIME))
|
||||
assertThat(registry.getDomainRenewCost("poor.example", START_OF_TIME, "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 16));
|
||||
assertThat(registry.getDomainRenewCost("poor.example", 1, clock.nowUtc()))
|
||||
assertThat(registry.getDomainRenewCost("poor.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 10));
|
||||
assertThat(registry.getDomainRenewCost("poor.example", 2, clock.nowUtc()))
|
||||
assertThat(registry.getDomainRenewCost("poor.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 20));
|
||||
assertThat(registry.getDomainRenewCost("rich.example", 1, START_OF_TIME))
|
||||
assertThat(registry.getDomainRenewCost("rich.example", START_OF_TIME, "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 100));
|
||||
assertThat(registry.getDomainRenewCost("rich.example", 2, START_OF_TIME))
|
||||
assertThat(registry.getDomainRenewCost("rich.example", START_OF_TIME, "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 200));
|
||||
assertThat(registry.getDomainRenewCost("rich.example", 1, clock.nowUtc()))
|
||||
assertThat(registry.getDomainRenewCost("rich.example", clock.nowUtc(), "TheRegistrar", 1))
|
||||
.isEqualTo(Money.of(USD, 100));
|
||||
assertThat(registry.getDomainRenewCost("rich.example", 2, clock.nowUtc()))
|
||||
assertThat(registry.getDomainRenewCost("rich.example", clock.nowUtc(), "TheRegistrar", 2))
|
||||
.isEqualTo(Money.of(USD, 200));
|
||||
}
|
||||
|
||||
@@ -454,39 +458,41 @@ public class RegistryTest extends EntityTestCase {
|
||||
@Test
|
||||
public void testFailure_isPremiumNameForSldNotUnderTld() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("tld").isPremiumName("test.example");
|
||||
Registry.get("tld").isPremiumName("test.example", clock.nowUtc(), "TheRegistrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_isPremiumNameForSldSubdomain() throws Exception {
|
||||
createTld("example");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("example").isPremiumName("rich.sld.example");
|
||||
Registry.get("example").isPremiumName("rich.sld.example", clock.nowUtc(), "TheRegistrar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_getCreateCostForSldNotUnderTld() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("tld").getDomainCreateCost("test.example", 1);
|
||||
Registry.get("tld").getDomainCreateCost("test.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_getCreateCostForSldSubdomain() throws Exception {
|
||||
createTld("example");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("example").getDomainCreateCost("rich.sld.example", 1);
|
||||
Registry.get("example")
|
||||
.getDomainCreateCost("rich.sld.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_getRenewCostForSldNotUnderTld() {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("tld").getDomainRenewCost("test.example", 1, clock.nowUtc());
|
||||
Registry.get("tld").getDomainRenewCost("test.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_getRenewCostForSldSubdomain() throws Exception {
|
||||
createTld("example");
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
Registry.get("example").getDomainRenewCost("rich.sld.example", 1, clock.nowUtc());
|
||||
Registry.get("example")
|
||||
.getDomainRenewCost("rich.sld.example", clock.nowUtc(), "TheRegistrar", 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,6 +424,7 @@ public class DatastoreHelper {
|
||||
public static BillingEvent.OneTime createBillingEventForTransfer(
|
||||
DomainResource domain,
|
||||
HistoryEntry historyEntry,
|
||||
String gainingClientId,
|
||||
DateTime costLookupTime,
|
||||
DateTime eventTime,
|
||||
Integer extendedRegistrationYears) {
|
||||
@@ -437,8 +438,9 @@ public class DatastoreHelper {
|
||||
.setPeriodYears(extendedRegistrationYears)
|
||||
.setCost(Registry.get(domain.getTld()).getDomainRenewCost(
|
||||
domain.getFullyQualifiedDomainName(),
|
||||
extendedRegistrationYears,
|
||||
costLookupTime))
|
||||
costLookupTime,
|
||||
gainingClientId,
|
||||
extendedRegistrationYears))
|
||||
.setParent(historyEntry)
|
||||
.build();
|
||||
}
|
||||
@@ -499,6 +501,7 @@ public class DatastoreHelper {
|
||||
BillingEvent.OneTime transferBillingEvent = persistResource(createBillingEventForTransfer(
|
||||
domain,
|
||||
historyEntryDomainTransfer,
|
||||
"NewRegistrar",
|
||||
requestTime,
|
||||
expirationTime,
|
||||
extendedRegistrationYears));
|
||||
|
||||
Reference in New Issue
Block a user