Statically import commonly used TldState enum values

Takes advantage of the fact that the default state of a TLD created in tests is GENERAL_AVAILABILITY.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=228916164
This commit is contained in:
mcilwain 2019-01-11 11:34:08 -08:00 committed by Ben McIlwain
parent eeb65b4610
commit 170980db2f
14 changed files with 62 additions and 63 deletions

View file

@ -27,6 +27,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registries.findTldForName; import static google.registry.model.registry.Registries.findTldForName;
import static google.registry.model.registry.Registries.getTlds; import static google.registry.model.registry.Registries.getTlds;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY; import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE; import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED; import static google.registry.model.registry.label.ReservationType.FULLY_BLOCKED;
import static google.registry.model.registry.label.ReservationType.NAMESERVER_RESTRICTED; import static google.registry.model.registry.label.ReservationType.NAMESERVER_RESTRICTED;
@ -890,7 +891,7 @@ public class DomainFlowUtils {
/** Check that the registry phase is not predelegation, during which some flows are forbidden. */ /** Check that the registry phase is not predelegation, during which some flows are forbidden. */
public static void verifyNotInPredelegation(Registry registry, DateTime now) public static void verifyNotInPredelegation(Registry registry, DateTime now)
throws BadCommandForRegistryPhaseException { throws BadCommandForRegistryPhaseException {
if (registry.getTldState(now) == TldState.PREDELEGATION) { if (registry.getTldState(now) == PREDELEGATION) {
throw new BadCommandForRegistryPhaseException(); throw new BadCommandForRegistryPhaseException();
} }
} }

View file

@ -19,6 +19,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -113,9 +115,9 @@ public final class OteAccountBuilder {
RegistryEnvironment.get() != RegistryEnvironment.PRODUCTION, RegistryEnvironment.get() != RegistryEnvironment.PRODUCTION,
"Can't setup OT&E in production"); "Can't setup OT&E in production");
clientIdToTld = createClientIdToTldMap(baseClientId); clientIdToTld = createClientIdToTldMap(baseClientId);
sunriseTld = createTld(baseClientId + "-sunrise", TldState.START_DATE_SUNRISE, false, 0); sunriseTld = createTld(baseClientId + "-sunrise", START_DATE_SUNRISE, false, 0);
gaTld = createTld(baseClientId + "-ga", TldState.GENERAL_AVAILABILITY, false, 2); gaTld = createTld(baseClientId + "-ga", GENERAL_AVAILABILITY, false, 2);
eapTld = createTld(baseClientId + "-eap", TldState.GENERAL_AVAILABILITY, true, 3); eapTld = createTld(baseClientId + "-eap", GENERAL_AVAILABILITY, true, 3);
registrars = registrars =
clientIdToTld.keySet().stream() clientIdToTld.keySet().stream()
.map(OteAccountBuilder::createRegistrar) .map(OteAccountBuilder::createRegistrar)

View file

@ -17,6 +17,7 @@ package google.registry.rde.imports;
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Preconditions.checkState;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.util.DateTimeUtils.END_OF_TIME; import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME; import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static google.registry.util.PreconditionsUtils.checkArgumentPresent; import static google.registry.util.PreconditionsUtils.checkArgumentPresent;
@ -155,7 +156,7 @@ public class RdeImportUtils {
Registry registry = Registry.get(tld); Registry registry = Registry.get(tld);
TldState currentState = registry.getTldState(clock.nowUtc()); TldState currentState = registry.getTldState(clock.nowUtc());
checkArgument( checkArgument(
currentState == TldState.PREDELEGATION, currentState == PREDELEGATION,
"TLD '%s' is in state %s and cannot be imported", "TLD '%s' is in state %s and cannot be imported",
tld, tld,
currentState); currentState);

View file

@ -16,6 +16,7 @@ package google.registry.flows;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.AVAILABLE; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.AVAILABLE;
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.REGISTERED; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.REGISTERED;
import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.RESERVED; import static google.registry.monitoring.whitebox.CheckApiMetric.Availability.RESERVED;
@ -28,7 +29,6 @@ import static google.registry.testing.DatastoreHelper.persistResource;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.monitoring.whitebox.CheckApiMetric; import google.registry.monitoring.whitebox.CheckApiMetric;
import google.registry.monitoring.whitebox.CheckApiMetric.Availability; import google.registry.monitoring.whitebox.CheckApiMetric.Availability;
import google.registry.monitoring.whitebox.CheckApiMetric.Status; import google.registry.monitoring.whitebox.CheckApiMetric.Status;
@ -151,7 +151,7 @@ public class CheckApiActionTest {
@Test @Test
public void testFailure_tldInPredelegation() { public void testFailure_tldInPredelegation() {
createTld("predelegated", TldState.PREDELEGATION); createTld("predelegated", PREDELEGATION);
assertThat(getCheckResponse("foo.predelegated")) assertThat(getCheckResponse("foo.predelegated"))
.containsExactly( .containsExactly(
"status", "error", "status", "error",

View file

@ -15,6 +15,7 @@
package google.registry.flows.domain; package google.registry.flows.domain;
import static google.registry.model.eppoutput.CheckData.DomainCheck.create; import static google.registry.model.eppoutput.CheckData.DomainCheck.create;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE; import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.createTlds;
@ -377,7 +378,7 @@ public class DomainCheckFlowTest
@Test @Test
public void testFailure_predelegation() { public void testFailure_predelegation() {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
} }
@ -917,9 +918,7 @@ public class DomainCheckFlowTest
@Test @Test
public void testIcannActivityReportField_getsLogged() throws Exception { public void testIcannActivityReportField_getsLogged() throws Exception {
createTld("com", TldState.GENERAL_AVAILABILITY); createTlds("com", "net", "org");
createTld("net", TldState.GENERAL_AVAILABILITY);
createTld("org", TldState.GENERAL_AVAILABILITY);
setEppInput("domain_check.xml"); setEppInput("domain_check.xml");
runFlow(); runFlow();
assertIcannReportingActivityFieldLogged("srs-dom-check"); assertIcannReportingActivityFieldLogged("srs-dom-check");

View file

@ -14,6 +14,7 @@
package google.registry.flows.domain; package google.registry.flows.domain;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents; import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.createTlds; import static google.registry.testing.DatastoreHelper.createTlds;
@ -130,7 +131,7 @@ public class DomainClaimsCheckFlowTest
@Test @Test
public void testFailure_predelgation() { public void testFailure_predelgation() {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
setEppInput("domain_check_claims.xml"); setEppInput("domain_check_claims.xml");
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();

View file

@ -21,11 +21,14 @@ import static google.registry.flows.FlowTestCase.UserPrivileges.SUPERUSER;
import static google.registry.model.billing.BillingEvent.Flag.ANCHOR_TENANT; import static google.registry.model.billing.BillingEvent.Flag.ANCHOR_TENANT;
import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS; import static google.registry.model.domain.fee.Fee.FEE_EXTENSION_URIS;
import static google.registry.model.eppcommon.StatusValue.OK; import static google.registry.model.eppcommon.StatusValue.OK;
import static google.registry.model.eppcommon.StatusValue.PENDING_DELETE;
import static google.registry.model.eppcommon.StatusValue.SERVER_HOLD; import static google.registry.model.eppcommon.StatusValue.SERVER_HOLD;
import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED; import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED;
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED; import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY; import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.model.registry.Registry.TldState.QUIET_PERIOD;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE; import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.pricing.PricingEngineProxy.isDomainPremium; import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
import static google.registry.testing.DatastoreHelper.assertBillingEvents; import static google.registry.testing.DatastoreHelper.assertBillingEvents;
@ -139,13 +142,11 @@ import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.domain.token.AllocationToken; import google.registry.model.domain.token.AllocationToken;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.Registrar.State; import google.registry.model.registrar.Registrar.State;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
@ -1165,10 +1166,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveContact("jd1234"); persistActiveContact("jd1234");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistResource( persistResource(
newHostResource("ns2.example.net") newHostResource("ns2.example.net").asBuilder().addStatusValue(PENDING_DELETE).build());
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli(); clock.advanceOneMilli();
LinkedResourceInPendingDeleteProhibitsOperationException thrown = LinkedResourceInPendingDeleteProhibitsOperationException thrown =
assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow); assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow);
@ -1191,10 +1189,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
persistActiveHost("ns2.example.net"); persistActiveHost("ns2.example.net");
persistActiveContact("sh8013"); persistActiveContact("sh8013");
persistResource( persistResource(
newContactResource("jd1234") newContactResource("jd1234").asBuilder().addStatusValue(PENDING_DELETE).build());
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
clock.advanceOneMilli(); clock.advanceOneMilli();
LinkedResourceInPendingDeleteProhibitsOperationException thrown = LinkedResourceInPendingDeleteProhibitsOperationException thrown =
assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow); assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow);
@ -1211,7 +1206,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_predelegation() { public void testFailure_predelegation() {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
persistContactsAndHosts(); persistContactsAndHosts();
EppException thrown = EppException thrown =
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow); assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow);
@ -1229,7 +1224,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testFailure_quietPeriod() { public void testFailure_quietPeriod() {
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", QUIET_PERIOD);
persistContactsAndHosts(); persistContactsAndHosts();
EppException thrown = EppException thrown =
assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow); assertThrows(NoGeneralRegistrationsInCurrentPhaseException.class, this::runFlow);
@ -1238,7 +1233,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testSuccess_superuserPredelegation() throws Exception { public void testSuccess_superuserPredelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
persistContactsAndHosts(); persistContactsAndHosts();
doSuccessfulTest( doSuccessfulTest(
"tld", "domain_create_response.xml", SUPERUSER, ImmutableMap.of("DOMAIN", "example.tld")); "tld", "domain_create_response.xml", SUPERUSER, ImmutableMap.of("DOMAIN", "example.tld"));
@ -1254,7 +1249,7 @@ public class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow,
@Test @Test
public void testSuccess_superuserQuietPeriod() throws Exception { public void testSuccess_superuserQuietPeriod() throws Exception {
createTld("tld", TldState.QUIET_PERIOD); createTld("tld", QUIET_PERIOD);
persistContactsAndHosts(); persistContactsAndHosts();
doSuccessfulTest( doSuccessfulTest(
"tld", "domain_create_response.xml", SUPERUSER, ImmutableMap.of("DOMAIN", "example.tld")); "tld", "domain_create_response.xml", SUPERUSER, ImmutableMap.of("DOMAIN", "example.tld"));

View file

@ -24,6 +24,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer; import static google.registry.flows.domain.DomainTransferFlowTestCase.persistWithPendingTransfer;
import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.loadByForeignKey;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.DELETED_DOMAINS_GRACE; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.DELETED_DOMAINS_GRACE;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.DELETED_DOMAINS_NOGRACE; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.DELETED_DOMAINS_NOGRACE;
import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_ADDS_10_YR; import static google.registry.model.reporting.DomainTransactionRecord.TransactionReportField.NET_ADDS_10_YR;
@ -86,7 +87,6 @@ import google.registry.model.host.HostResource;
import google.registry.model.poll.PendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse;
import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
@ -723,7 +723,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
@Test @Test
public void testFailure_predelegation() throws Exception { public void testFailure_predelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
setUpSuccessfulTest(); setUpSuccessfulTest();
EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow); EppException thrown = assertThrows(BadCommandForRegistryPhaseException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml(); assertAboutEppExceptions().that(thrown).marshalsToXml();
@ -731,7 +731,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
@Test @Test
public void testSuccess_superuserPredelegation() throws Exception { public void testSuccess_superuserPredelegation() throws Exception {
createTld("tld", TldState.PREDELEGATION); createTld("tld", PREDELEGATION);
setUpSuccessfulTest(); setUpSuccessfulTest();
clock.advanceOneMilli(); clock.advanceOneMilli();
runFlowAssertResponse( runFlowAssertResponse(

View file

@ -40,7 +40,6 @@ import google.registry.model.host.HostResource;
import google.registry.model.ofy.Ofy; import google.registry.model.ofy.Ofy;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registrar.RegistrarContact; import google.registry.model.registrar.RegistrarContact;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferData; import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferStatus; import google.registry.model.transfer.TransferStatus;
@ -98,7 +97,7 @@ public class RdapJsonFormatterTest {
// Create the registrar in 1999, then update it in 2000. // Create the registrar in 1999, then update it in 2000.
clock.setTo(DateTime.parse("1999-01-01T00:00:00Z")); clock.setTo(DateTime.parse("1999-01-01T00:00:00Z"));
createTld("xn--q9jyb4c", TldState.GENERAL_AVAILABILITY); createTld("xn--q9jyb4c");
registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE)); registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE));
clock.setTo(DateTime.parse("2000-01-01T00:00:00Z")); clock.setTo(DateTime.parse("2000-01-01T00:00:00Z"));
registrar = persistResource(registrar); registrar = persistResource(registrar);

View file

@ -17,6 +17,7 @@ package google.registry.rde.imports;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistActiveContact; import static google.registry.testing.DatastoreHelper.persistActiveContact;
import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.testing.DatastoreHelper.persistNewRegistrar;
@ -47,7 +48,6 @@ import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.EppResourceIndexBucket; import google.registry.model.index.EppResourceIndexBucket;
import google.registry.model.index.ForeignKeyIndex; import google.registry.model.index.ForeignKeyIndex;
import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registry.TldState;
import google.registry.testing.AppEngineRule; import google.registry.testing.AppEngineRule;
import google.registry.testing.FakeClock; import google.registry.testing.FakeClock;
import google.registry.testing.ShardableTestCase; import google.registry.testing.ShardableTestCase;
@ -89,8 +89,8 @@ public class RdeImportUtilsTest extends ShardableTestCase {
clock = new FakeClock(); clock = new FakeClock();
clock.setTo(DateTime.now(UTC)); clock.setTo(DateTime.now(UTC));
rdeImportUtils = new RdeImportUtils(ofy(), clock, "import-bucket", gcsUtils); rdeImportUtils = new RdeImportUtils(ofy(), clock, "import-bucket", gcsUtils);
createTld("test", TldState.PREDELEGATION); createTld("test", PREDELEGATION);
createTld("getld", TldState.GENERAL_AVAILABILITY); createTld("getld");
persistNewRegistrar("RegistrarX", "RegistrarX", Registrar.Type.REAL, 1L); persistNewRegistrar("RegistrarX", "RegistrarX", Registrar.Type.REAL, 1L);
} }

View file

@ -28,6 +28,7 @@ import static google.registry.model.EppResourceUtils.createDomainRepoId;
import static google.registry.model.EppResourceUtils.createRepoId; import static google.registry.model.EppResourceUtils.createRepoId;
import static google.registry.model.ResourceTransferUtils.createTransferResponse; import static google.registry.model.ResourceTransferUtils.createTransferResponse;
import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.label.PremiumListUtils.parentPremiumListEntriesOnRevision; import static google.registry.model.registry.label.PremiumListUtils.parentPremiumListEntriesOnRevision;
import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost; import static google.registry.pricing.PricingEngineProxy.getDomainRenewCost;
import static google.registry.util.CollectionUtils.difference; import static google.registry.util.CollectionUtils.difference;
@ -179,8 +180,7 @@ public class DatastoreHelper {
} }
public static Registry newRegistry(String tld, String roidSuffix) { public static Registry newRegistry(String tld, String roidSuffix) {
return newRegistry( return newRegistry(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY));
tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, TldState.GENERAL_AVAILABILITY));
} }
public static Registry newRegistry( public static Registry newRegistry(
@ -332,17 +332,17 @@ public class DatastoreHelper {
/** Creates and persists a tld. */ /** Creates and persists a tld. */
public static void createTld(String tld) { public static void createTld(String tld) {
createTld(tld, TldState.GENERAL_AVAILABILITY); createTld(tld, GENERAL_AVAILABILITY);
} }
public static void createTld(String tld, String roidSuffix) { public static void createTld(String tld, String roidSuffix) {
createTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, TldState.GENERAL_AVAILABILITY)); createTld(tld, roidSuffix, ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY));
} }
/** Creates and persists the given TLDs. */ /** Creates and persists the given TLDs. */
public static void createTlds(String... tlds) { public static void createTlds(String... tlds) {
for (String tld : tlds) { for (String tld : tlds) {
createTld(tld, TldState.GENERAL_AVAILABILITY); createTld(tld, GENERAL_AVAILABILITY);
} }
} }

View file

@ -16,6 +16,8 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistPremiumList;
import static google.registry.testing.DatastoreHelper.persistReservedList; import static google.registry.testing.DatastoreHelper.persistReservedList;
@ -31,7 +33,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range; import com.google.common.collect.Range;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -68,7 +69,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
assertThat(registry.getCreationTime()).isIn(Range.closed(before, after)); assertThat(registry.getCreationTime()).isIn(Range.closed(before, after));
assertThat(registry.getDomainCreateRestricted()).isFalse(); assertThat(registry.getDomainCreateRestricted()).isFalse();
assertThat(registry.getDnsWriters()).containsExactly("FooDnsWriter"); assertThat(registry.getDnsWriters()).containsExactly("FooDnsWriter");
assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(TldState.PREDELEGATION); assertThat(registry.getTldState(registry.getCreationTime())).isEqualTo(PREDELEGATION);
assertThat(registry.getRedemptionGracePeriodLength()) assertThat(registry.getRedemptionGracePeriodLength())
.isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD); .isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD);
assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH); assertThat(registry.getPendingDeleteLength()).isEqualTo(Registry.DEFAULT_PENDING_DELETE_LENGTH);
@ -104,7 +105,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
"--dns_writers=VoidDnsWriter", "--dns_writers=VoidDnsWriter",
"xn--q9jyb4c"); "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getTldState(DateTime.now(UTC))) assertThat(Registry.get("xn--q9jyb4c").getTldState(DateTime.now(UTC)))
.isEqualTo(TldState.GENERAL_AVAILABILITY); .isEqualTo(GENERAL_AVAILABILITY);
} }
@Test @Test
@ -256,7 +257,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter"); runCommandForced("co.uk", "--roid_suffix=COUK", "--dns_writers=VoidDnsWriter");
Registry registry = Registry.get("co.uk"); Registry registry = Registry.get("co.uk");
assertThat(registry.getTldState(new DateTime())).isEqualTo(TldState.PREDELEGATION); assertThat(registry.getTldState(new DateTime())).isEqualTo(PREDELEGATION);
assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD); assertThat(registry.getAddGracePeriodLength()).isEqualTo(Registry.DEFAULT_ADD_GRACE_PERIOD);
assertThat(registry.getRedemptionGracePeriodLength()) assertThat(registry.getRedemptionGracePeriodLength())
.isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD); .isEqualTo(Registry.DEFAULT_REDEMPTION_GRACE_PERIOD);

View file

@ -14,6 +14,7 @@
package google.registry.tools; package google.registry.tools;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.testing.DatastoreHelper.allowRegistrarAccess; import static google.registry.testing.DatastoreHelper.allowRegistrarAccess;
import static google.registry.testing.DatastoreHelper.newRegistry; import static google.registry.testing.DatastoreHelper.newRegistry;
import static google.registry.testing.DatastoreHelper.persistDeletedDomain; import static google.registry.testing.DatastoreHelper.persistDeletedDomain;
@ -25,7 +26,6 @@ import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.RegistryNotFoundException; import google.registry.model.registry.Registry.RegistryNotFoundException;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.Registry.TldType; import google.registry.model.registry.Registry.TldType;
import org.joda.time.DateTime; import org.joda.time.DateTime;
import org.junit.Before; import org.junit.Before;
@ -43,13 +43,13 @@ public class DeleteTldCommandTest extends CommandTestCase<DeleteTldCommand> {
newRegistry( newRegistry(
TLD_REAL, TLD_REAL,
Ascii.toUpperCase(TLD_REAL), Ascii.toUpperCase(TLD_REAL),
ImmutableSortedMap.of(START_OF_TIME, TldState.GENERAL_AVAILABILITY), ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY),
TldType.REAL)); TldType.REAL));
persistResource( persistResource(
newRegistry( newRegistry(
TLD_TEST, TLD_TEST,
Ascii.toUpperCase(TLD_TEST), Ascii.toUpperCase(TLD_TEST),
ImmutableSortedMap.of(START_OF_TIME, TldState.GENERAL_AVAILABILITY), ImmutableSortedMap.of(START_OF_TIME, GENERAL_AVAILABILITY),
TldType.TEST)); TldType.TEST));
} }

View file

@ -16,6 +16,9 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.Truth8.assertThat;
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.model.registry.Registry.TldState.PREDELEGATION;
import static google.registry.model.registry.Registry.TldState.QUIET_PERIOD;
import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE; import static google.registry.model.registry.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.persistPremiumList; import static google.registry.testing.DatastoreHelper.persistPremiumList;
@ -34,7 +37,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap; import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key; import com.googlecode.objectify.Key;
import google.registry.model.registry.Registry; import google.registry.model.registry.Registry;
import google.registry.model.registry.Registry.TldState;
import google.registry.model.registry.label.PremiumList; import google.registry.model.registry.label.PremiumList;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.PrintStream; import java.io.PrintStream;
@ -75,18 +77,16 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
"xn--q9jyb4c"); "xn--q9jyb4c");
Registry registry = Registry.get("xn--q9jyb4c"); Registry registry = Registry.get("xn--q9jyb4c");
assertThat(registry.getTldState(sunriseStart.minusMillis(1))).isEqualTo(TldState.PREDELEGATION); assertThat(registry.getTldState(sunriseStart.minusMillis(1))).isEqualTo(PREDELEGATION);
assertThat(registry.getTldState(sunriseStart)).isEqualTo(START_DATE_SUNRISE); assertThat(registry.getTldState(sunriseStart)).isEqualTo(START_DATE_SUNRISE);
assertThat(registry.getTldState(sunriseStart.plusMillis(1))).isEqualTo(START_DATE_SUNRISE); assertThat(registry.getTldState(sunriseStart.plusMillis(1))).isEqualTo(START_DATE_SUNRISE);
assertThat(registry.getTldState(quietPeriodStart.minusMillis(1))).isEqualTo(START_DATE_SUNRISE); assertThat(registry.getTldState(quietPeriodStart.minusMillis(1))).isEqualTo(START_DATE_SUNRISE);
assertThat(registry.getTldState(quietPeriodStart)).isEqualTo(TldState.QUIET_PERIOD); assertThat(registry.getTldState(quietPeriodStart)).isEqualTo(QUIET_PERIOD);
assertThat(registry.getTldState(quietPeriodStart.plusMillis(1))) assertThat(registry.getTldState(quietPeriodStart.plusMillis(1))).isEqualTo(QUIET_PERIOD);
.isEqualTo(TldState.QUIET_PERIOD); assertThat(registry.getTldState(gaStart.minusMillis(1))).isEqualTo(QUIET_PERIOD);
assertThat(registry.getTldState(gaStart.minusMillis(1))).isEqualTo(TldState.QUIET_PERIOD); assertThat(registry.getTldState(gaStart)).isEqualTo(GENERAL_AVAILABILITY);
assertThat(registry.getTldState(gaStart)).isEqualTo(TldState.GENERAL_AVAILABILITY); assertThat(registry.getTldState(gaStart.plusMillis(1))).isEqualTo(GENERAL_AVAILABILITY);
assertThat(registry.getTldState(gaStart.plusMillis(1))) assertThat(registry.getTldState(END_OF_TIME)).isEqualTo(GENERAL_AVAILABILITY);
.isEqualTo(TldState.GENERAL_AVAILABILITY);
assertThat(registry.getTldState(END_OF_TIME)).isEqualTo(TldState.GENERAL_AVAILABILITY);
} }
@Test @Test
@ -94,7 +94,7 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
persistResource( persistResource(
Registry.get("xn--q9jyb4c") Registry.get("xn--q9jyb4c")
.asBuilder() .asBuilder()
.setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, TldState.PREDELEGATION)) .setTldStateTransitions(ImmutableSortedMap.of(START_OF_TIME, PREDELEGATION))
.build()); .build());
runCommandForced("--set_current_tld_state=START_DATE_SUNRISE", "xn--q9jyb4c"); runCommandForced("--set_current_tld_state=START_DATE_SUNRISE", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getTldState(now.plusDays(1))) assertThat(Registry.get("xn--q9jyb4c").getTldState(now.plusDays(1)))
@ -569,8 +569,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
Registry.get("xn--q9jyb4c").asBuilder() Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions( .setTldStateTransitions(
ImmutableSortedMap.of( ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION, START_OF_TIME, PREDELEGATION,
now.minusMonths(1), TldState.GENERAL_AVAILABILITY)) now.minusMonths(1), GENERAL_AVAILABILITY))
.build()); .build());
IllegalArgumentException thrown = IllegalArgumentException thrown =
assertThrows( assertThrows(
@ -585,8 +585,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
Registry.get("xn--q9jyb4c").asBuilder() Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions( .setTldStateTransitions(
ImmutableSortedMap.of( ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION, START_OF_TIME, PREDELEGATION,
now.plusMonths(1), TldState.GENERAL_AVAILABILITY)) now.plusMonths(1), GENERAL_AVAILABILITY))
.build()); .build());
IllegalArgumentException thrown = IllegalArgumentException thrown =
assertThrows( assertThrows(
@ -603,8 +603,8 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
Registry.get("xn--q9jyb4c").asBuilder() Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions( .setTldStateTransitions(
ImmutableSortedMap.of( ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION, START_OF_TIME, PREDELEGATION,
now.minusMonths(1), TldState.GENERAL_AVAILABILITY)) now.minusMonths(1), GENERAL_AVAILABILITY))
.build()); .build());
IllegalArgumentException thrown = IllegalArgumentException thrown =
assertThrows( assertThrows(