mirror of
https://github.com/google/nomulus.git
synced 2025-07-23 19:20:44 +02:00
Add type conversion to TimedTransitionProperty<Money> deserializer to handle JPY currency (#2258)
* Add BigInt conversion to TimedTransitionProperty<Money> deserializer to handle JPY currency * Remove unnecessary lines in test * Add eap schedule check * Don't use raw LinkedHashMap type * add timezone
This commit is contained in:
parent
08285f5de7
commit
20b5b43501
3 changed files with 72 additions and 4 deletions
|
@ -349,7 +349,7 @@ public class EntityYamlUtils {
|
|||
@Override
|
||||
public TimedTransitionProperty<Money> deserialize(JsonParser jp, DeserializationContext context)
|
||||
throws IOException {
|
||||
SortedMap<String, LinkedHashMap> valueMap = jp.readValueAs(SortedMap.class);
|
||||
SortedMap<String, LinkedHashMap<String, Object>> valueMap = jp.readValueAs(SortedMap.class);
|
||||
return TimedTransitionProperty.fromValueMap(
|
||||
valueMap.keySet().stream()
|
||||
.collect(
|
||||
|
@ -359,7 +359,7 @@ public class EntityYamlUtils {
|
|||
key ->
|
||||
Money.of(
|
||||
CurrencyUnit.of(valueMap.get(key).get("currency").toString()),
|
||||
(double) valueMap.get(key).get("amount")))));
|
||||
new BigDecimal(String.valueOf(valueMap.get(key).get("amount")))))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
|||
import static java.util.logging.Level.INFO;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
@ -46,11 +47,11 @@ import google.registry.model.tld.Tld.TldNotFoundException;
|
|||
import google.registry.model.tld.label.PremiumList;
|
||||
import google.registry.model.tld.label.PremiumListDao;
|
||||
import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Logger;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -91,6 +92,18 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
|||
assertThat(tld.getBreakglassMode()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_createNewTldJPY() throws Exception {
|
||||
File tldFile = tmpDir.resolve("jpy.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "jpy.yaml"));
|
||||
runCommandForced("--input=" + tldFile);
|
||||
Tld tld = Tld.get("jpy");
|
||||
assertThat(tld).isNotNull();
|
||||
assertThat(tld.getCreateBillingCost()).isEqualTo(Money.of(JPY, new BigDecimal("250")));
|
||||
assertThat(tld.getEapFeeFor(DateTime.now(UTC)).getCost()).isEqualTo(new BigDecimal(0));
|
||||
testTldConfiguredSuccessfully(tld, "jpy.yaml");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSuccess_updateTld() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
|
@ -108,7 +121,7 @@ public class ConfigureTldCommandTest extends CommandTestCase<ConfigureTldCommand
|
|||
@Test
|
||||
void testSuccess_updateTld_existingBsaTimeCarriedOver() throws Exception {
|
||||
Tld tld = createTld("tld");
|
||||
DateTime bsaStartTime = DateTime.now(DateTimeZone.UTC);
|
||||
DateTime bsaStartTime = DateTime.now(UTC);
|
||||
persistResource(tld.asBuilder().setBsaEnrollStartTime(Optional.of(bsaStartTime)).build());
|
||||
File tldFile = tmpDir.resolve("tld.yaml").toFile();
|
||||
Files.asCharSink(tldFile, UTF_8).write(loadFile(getClass(), "tld.yaml"));
|
||||
|
|
55
core/src/test/resources/google/registry/tools/jpy.yaml
Normal file
55
core/src/test/resources/google/registry/tools/jpy.yaml
Normal file
|
@ -0,0 +1,55 @@
|
|||
addGracePeriodLength: "PT432000S"
|
||||
allowedFullyQualifiedHostNames: []
|
||||
allowedRegistrantContactIds: []
|
||||
anchorTenantAddGracePeriodLength: "PT2592000S"
|
||||
autoRenewGracePeriodLength: "PT3888000S"
|
||||
automaticTransferLength: "PT432000S"
|
||||
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
|
||||
createBillingCost:
|
||||
currency: "JPY"
|
||||
amount: 250
|
||||
creationTime: "2022-09-01T00:00:00.000Z"
|
||||
currency: "JPY"
|
||||
defaultPromoTokens: []
|
||||
dnsAPlusAaaaTtl: "PT900S"
|
||||
dnsDsTtl: null
|
||||
dnsNsTtl: null
|
||||
dnsPaused: false
|
||||
dnsWriters:
|
||||
- "VoidDnsWriter"
|
||||
driveFolderId: "driveFolder"
|
||||
eapFeeSchedule:
|
||||
"1970-01-01T00:00:00.000Z":
|
||||
currency: "JPY"
|
||||
amount: 0
|
||||
escrowEnabled: false
|
||||
idnTables: []
|
||||
invoicingEnabled: false
|
||||
lordnUsername: null
|
||||
numDnsPublishLocks: 1
|
||||
pendingDeleteLength: "PT432000S"
|
||||
premiumListName: null
|
||||
pricingEngineClassName: "google.registry.model.pricing.StaticPremiumListPricingEngine"
|
||||
redemptionGracePeriodLength: "PT2592000S"
|
||||
registryLockOrUnlockBillingCost:
|
||||
currency: "JPY"
|
||||
amount: 0
|
||||
renewBillingCostTransitions:
|
||||
"1970-01-01T00:00:00.000Z":
|
||||
currency: "JPY"
|
||||
amount: 100
|
||||
renewGracePeriodLength: "PT432000S"
|
||||
reservedListNames: []
|
||||
restoreBillingCost:
|
||||
currency: "JPY"
|
||||
amount: 70
|
||||
roidSuffix: "JPY"
|
||||
serverStatusChangeBillingCost:
|
||||
currency: "JPY"
|
||||
amount: 100
|
||||
tldStateTransitions:
|
||||
"1970-01-01T00:00:00.000Z": "GENERAL_AVAILABILITY"
|
||||
tldStr: "jpy"
|
||||
tldType: "REAL"
|
||||
tldUnicode: "jpy"
|
||||
transferGracePeriodLength: "PT432000S"
|
Loading…
Add table
Add a link
Reference in a new issue