Modify getTldCommand to return TLD in YAML (#2102)

This commit is contained in:
sarahcaseybot 2023-08-10 14:20:56 -04:00 committed by GitHub
parent d7a3c0c439
commit ee66805d2e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 2 deletions

View file

@ -14,10 +14,13 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.tld.TldYamlUtils.getObjectMapper;
import static google.registry.model.tld.Tlds.assertTldsExist; import static google.registry.model.tld.Tlds.assertTldsExist;
import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters; import com.beust.jcommander.Parameters;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import google.registry.model.tld.Tld; import google.registry.model.tld.Tld;
import java.util.List; import java.util.List;
@ -31,9 +34,10 @@ final class GetTldCommand implements Command {
private List<String> mainParameters; private List<String> mainParameters;
@Override @Override
public void run() { public void run() throws JsonProcessingException {
ObjectMapper mapper = getObjectMapper();
for (String tld : assertTldsExist(mainParameters)) { for (String tld : assertTldsExist(mainParameters)) {
System.out.println(Tld.get(tld)); System.out.println(mapper.writeValueAsString(Tld.get(tld)));
} }
} }
} }

View file

@ -16,6 +16,7 @@ package google.registry.tools;
import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.createTlds; import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.TestDataHelper.loadFile;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException; import com.beust.jcommander.ParameterException;
@ -28,6 +29,7 @@ class GetTldCommandTest extends CommandTestCase<GetTldCommand> {
void testSuccess() throws Exception { void testSuccess() throws Exception {
createTld("xn--q9jyb4c"); createTld("xn--q9jyb4c");
runCommand("xn--q9jyb4c"); runCommand("xn--q9jyb4c");
assertInStdout(loadFile(getClass(), "tld.yaml"));
} }
@Test @Test

View file

@ -0,0 +1,55 @@
tldStr: "xn--q9jyb4c"
roidSuffix: "Q9JYB4C"
pricingEngineClassName: "google.registry.model.pricing.StaticPremiumListPricingEngine"
dnsWriters:
- "VoidDnsWriter"
numDnsPublishLocks: 1
dnsAPlusAaaaTtl: null
dnsNsTtl: null
dnsDsTtl: null
tldUnicode: "みんな"
driveFolderId: null
tldType: "REAL"
invoicingEnabled: false
tldStateTransitions:
"1970-01-01T00:00:00.000Z": "GENERAL_AVAILABILITY"
creationTime: "2022-09-01T00:00:00.000Z"
reservedListNames: []
premiumListName: "xn--q9jyb4c"
escrowEnabled: false
dnsPaused: false
addGracePeriodLength: 432000000
anchorTenantAddGracePeriodLength: 2592000000
autoRenewGracePeriodLength: 3888000000
redemptionGracePeriodLength: 2592000000
renewGracePeriodLength: 432000000
transferGracePeriodLength: 432000000
automaticTransferLength: 432000000
pendingDeleteLength: 432000000
currency: "USD"
createBillingCost:
currency: "USD"
amount: 13.00
restoreBillingCost:
currency: "USD"
amount: 17.00
serverStatusChangeBillingCost:
currency: "USD"
amount: 19.00
registryLockOrUnlockBillingCost:
currency: "USD"
amount: 0.00
renewBillingCostTransitions:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 11.00
lordnUsername: null
claimsPeriodEnd: "294247-01-10T04:00:54.775Z"
allowedRegistrantContactIds: []
allowedFullyQualifiedHostNames: []
defaultPromoTokens: []
idnTables: []
eapFeeSchedule:
"1970-01-01T00:00:00.000Z":
currency: "USD"
amount: 0.00