diff --git a/java/google/registry/model/registrar/Registrar.java b/java/google/registry/model/registrar/Registrar.java index c6a8d37f6..8f2c4b087 100644 --- a/java/google/registry/model/registrar/Registrar.java +++ b/java/google/registry/model/registrar/Registrar.java @@ -32,6 +32,7 @@ import static google.registry.model.ofy.Ofy.RECOMMENDED_MEMCACHE_EXPIRATION; import static google.registry.model.registry.Registries.assertTldsExist; import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy; import static google.registry.util.CollectionUtils.nullToEmptyImmutableSortedCopy; +import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.X509Utils.getCertificateHash; import static google.registry.util.X509Utils.loadCertificate; import static java.nio.charset.StandardCharsets.UTF_8; @@ -849,7 +850,11 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable /** Build the registrar, nullifying empty fields. */ @Override public Registrar build() { - checkNotNull(getInstance().type, "Registrar type cannot be null"); + checkArgumentNotNull(getInstance().type, "Registrar type cannot be null"); + checkArgumentNotNull(getInstance().registrarName, "Registrar name cannot be null"); + checkArgument( + getInstance().localizedAddress != null || getInstance().internationalizedAddress != null, + "Must specify at least one of localized or internationalized address"); checkArgument(getInstance().type.isValidIanaId(getInstance().ianaIdentifier), String.format("Supplied IANA ID is not valid for %s registrar type: %s", getInstance().type, getInstance().ianaIdentifier)); @@ -860,6 +865,7 @@ public class Registrar extends ImmutableObject implements Buildable, Jsonifiable /** Load a registrar entity by its client id outside of a transaction. */ @Nullable public static Registrar loadByClientId(final String clientId) { + checkNotNull(clientId, "Client ID cannot be null"); return ofy().doTransactionless(new Work() { @Override public Registrar run() { diff --git a/java/google/registry/tools/CreateRegistrarCommand.java b/java/google/registry/tools/CreateRegistrarCommand.java index 6b3996a8b..9718ac13e 100644 --- a/java/google/registry/tools/CreateRegistrarCommand.java +++ b/java/google/registry/tools/CreateRegistrarCommand.java @@ -15,7 +15,6 @@ package google.registry.tools; import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Strings.emptyToNull; import static com.google.common.collect.Iterables.filter; @@ -25,11 +24,11 @@ import static google.registry.model.registrar.Registrar.State.ACTIVE; import static google.registry.tools.RegistryToolEnvironment.PRODUCTION; import static google.registry.tools.RegistryToolEnvironment.SANDBOX; import static google.registry.tools.RegistryToolEnvironment.UNITTEST; +import static google.registry.util.PreconditionsUtils.checkArgumentNotNull; import static google.registry.util.RegistrarUtils.normalizeClientId; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; @@ -45,10 +44,6 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand private static final ImmutableSet ENVIRONMENTS_ALLOWING_GROUP_CREATION = ImmutableSet.of(PRODUCTION, SANDBOX, UNITTEST); - // Allows test cases to be cleaner. - @VisibleForTesting - static boolean requireAddress = true; - @Parameter( names = "--create_groups", description = "Whether the Google Groups for this registrar should be created", @@ -65,12 +60,10 @@ final class CreateRegistrarCommand extends CreateOrUpdateRegistrarCommand @Override protected void initRegistrarCommand() throws Exception { checkArgument(mainParameters.size() == 1, "Must specify exactly one client identifier."); - checkNotNull(emptyToNull(password), "--password is a required field"); - checkNotNull(registrarName, "--name is a required field"); - checkNotNull(icannReferralEmail, "--icann_referral_email is a required field"); - if (requireAddress) { - checkNotNull(street, "Address fields are required when creating a registrar"); - } + checkArgumentNotNull(emptyToNull(password), "--password is a required field"); + checkArgumentNotNull(registrarName, "--name is a required field"); + checkArgumentNotNull(icannReferralEmail, "--icann_referral_email is a required field"); + checkArgumentNotNull(street, "Address fields are required when creating a registrar"); // Default new registrars to active. registrarState = Optional.fromNullable(registrarState).or(ACTIVE); } diff --git a/java/google/registry/whois/DomainWhoisResponse.java b/java/google/registry/whois/DomainWhoisResponse.java index 9185d44ed..08e9a6736 100644 --- a/java/google/registry/whois/DomainWhoisResponse.java +++ b/java/google/registry/whois/DomainWhoisResponse.java @@ -66,7 +66,11 @@ final class DomainWhoisResponse extends WhoisResponseImpl { @Override public WhoisResponseResults getResponse(final boolean preferUnicode, String disclaimer) { - Registrar registrar = getRegistrar(domain.getCurrentSponsorClientId()); + Registrar registrar = + checkNotNull( + Registrar.loadByClientId(domain.getCurrentSponsorClientId()), + "Could not load registrar %s", + domain.getCurrentSponsorClientId()); Optional abuseContact = Iterables.tryFind( registrar.getContacts(), diff --git a/java/google/registry/whois/NameserverWhoisResponse.java b/java/google/registry/whois/NameserverWhoisResponse.java index 49276400b..b96fdc4f6 100644 --- a/java/google/registry/whois/NameserverWhoisResponse.java +++ b/java/google/registry/whois/NameserverWhoisResponse.java @@ -53,7 +53,8 @@ final class NameserverWhoisResponse extends WhoisResponseImpl { .cloneProjectedAtTime(getTimestamp()) .getCurrentSponsorClientId() : host.getPersistedCurrentSponsorClientId(); - Registrar registrar = getRegistrar(clientId); + Registrar registrar = + checkNotNull(Registrar.loadByClientId(clientId), "Could not load registrar %s", clientId); emitter .emitField( "Server Name", maybeFormatHostname(host.getFullyQualifiedHostName(), preferUnicode)) diff --git a/java/google/registry/whois/WhoisResponseImpl.java b/java/google/registry/whois/WhoisResponseImpl.java index 7ea69011f..a389aec23 100644 --- a/java/google/registry/whois/WhoisResponseImpl.java +++ b/java/google/registry/whois/WhoisResponseImpl.java @@ -21,12 +21,10 @@ import static com.google.common.html.HtmlEscapers.htmlEscaper; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Optional; -import com.google.common.base.Supplier; import com.google.common.collect.FluentIterable; import com.google.common.collect.Iterables; import com.google.common.collect.Ordering; import google.registry.model.eppcommon.Address; -import google.registry.model.registrar.Registrar; import google.registry.util.Idn; import google.registry.xml.UtcDateTimeAdapter; import java.util.Arrays; @@ -45,13 +43,6 @@ abstract class WhoisResponseImpl implements WhoisResponse { /** ICANN problem reporting URL appended to all WHOIS responses. */ private static final String ICANN_REPORTING_URL = "https://www.icann.org/wicf/"; - private static final Registrar EMPTY_REGISTRAR = new Supplier() { - @Override - public Registrar get() { - // Use Type.TEST here to avoid requiring an IANA ID (the type does not appear in WHOIS). - return new Registrar.Builder().setType(Registrar.Type.TEST).build(); - }}.get(); - /** The time at which this response was created. */ private final DateTime timestamp; @@ -196,11 +187,4 @@ abstract class WhoisResponseImpl implements WhoisResponse { /** An emitter that needs no special logic. */ static class BasicEmitter extends Emitter {} - - /** Returns the registrar for this client id, or an empty registrar with null values. */ - static Registrar getRegistrar(@Nullable String clientId) { - return Optional - .fromNullable(clientId == null ? null : Registrar.loadByClientId(clientId)) - .or(EMPTY_REGISTRAR); - } } diff --git a/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java b/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java index ed5c27aa0..1b9a8b089 100644 --- a/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java +++ b/javatests/google/registry/export/sheet/SyncRegistrarsSheetTest.java @@ -22,6 +22,7 @@ import static google.registry.model.common.Cursor.CursorType.SYNC_REGISTRAR_SHEE import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.deleteResource; +import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static org.joda.time.DateTimeZone.UTC; @@ -94,13 +95,7 @@ public class SyncRegistrarsSheetTest { @Test public void test_wereRegistrarsModified_atDifferentCursorTimes() throws Exception { - persistResource(new Registrar.Builder() - .setClientId("SomeRegistrar") - .setRegistrarName("Some Registrar Inc.") - .setType(Registrar.Type.REAL) - .setIanaIdentifier(8L) - .setState(Registrar.State.ACTIVE) - .build()); + persistNewRegistrar("SomeRegistrar", "Some Registrar Inc.", Registrar.Type.REAL, 8L); persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().minusHours(1))); assertThat(newSyncRegistrarsSheet().wereRegistrarsModified()).isTrue(); persistResource(Cursor.createGlobal(SYNC_REGISTRAR_SHEET, clock.nowUtc().plusHours(1))); @@ -327,18 +322,14 @@ public class SyncRegistrarsSheetTest { @Test public void testRun_missingValues_stillWorks() throws Exception { - persistResource(new Registrar.Builder() - .setClientId("SomeRegistrar") - .setType(Registrar.Type.REAL) - .setIanaIdentifier(8L) - .build()); + persistNewRegistrar("SomeRegistrar", "Some Registrar", Registrar.Type.REAL, 8L); newSyncRegistrarsSheet().run("foobar"); verify(sheetSynchronizer).synchronize(eq("foobar"), rowsCaptor.capture()); ImmutableMap row = getOnlyElement(getOnlyElement(rowsCaptor.getAllValues())); assertThat(row).containsEntry("clientIdentifier", "SomeRegistrar"); - assertThat(row).containsEntry("registrarName", ""); + assertThat(row).containsEntry("registrarName", "Some Registrar"); assertThat(row).containsEntry("state", ""); assertThat(row).containsEntry("ianaIdentifier", "8"); assertThat(row).containsEntry("billingIdentifier", ""); @@ -352,8 +343,8 @@ public class SyncRegistrarsSheetTest { assertThat(row).containsEntry("contactsMarkedAsWhoisAdmin", ""); assertThat(row).containsEntry("contactsMarkedAsWhoisTech", ""); assertThat(row).containsEntry("emailAddress", ""); - assertThat(row).containsEntry("address.street", "UNKNOWN"); - assertThat(row).containsEntry("address.city", "UNKNOWN"); + assertThat(row).containsEntry("address.street", "123 Fake St"); + assertThat(row).containsEntry("address.city", "Fakington"); assertThat(row).containsEntry("address.state", ""); assertThat(row).containsEntry("address.zip", ""); assertThat(row).containsEntry("address.countryCode", "US"); diff --git a/javatests/google/registry/model/ofy/OfyFilterTest.java b/javatests/google/registry/model/ofy/OfyFilterTest.java index 7d7a4fd58..cfc0104c6 100644 --- a/javatests/google/registry/model/ofy/OfyFilterTest.java +++ b/javatests/google/registry/model/ofy/OfyFilterTest.java @@ -16,6 +16,7 @@ package google.registry.model.ofy; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.ofy.ObjectifyService.initOfy; +import static google.registry.testing.DatastoreHelper.newContactResource; import static org.junit.Assert.fail; import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig; @@ -26,8 +27,7 @@ import com.googlecode.objectify.ObjectifyFilter; import com.googlecode.objectify.ObjectifyService; import com.googlecode.objectify.annotation.Entity; import com.googlecode.objectify.annotation.Id; -import google.registry.model.registrar.Registrar; -import google.registry.model.registrar.Registrar.Type; +import google.registry.model.contact.ContactResource; import google.registry.testing.ExceptionRule; import org.junit.After; import org.junit.Before; @@ -93,9 +93,8 @@ public class OfyFilterTest { @Test public void testKeyCreateAfterFilter() throws Exception { new OfyFilter().init(null); - Registrar registrar = - new Registrar.Builder().setType(Type.TEST).setClientId("clientId").build(); - Key.create(registrar); + ContactResource contact = newContactResource("contact1234"); + Key.create(contact); } @Entity diff --git a/javatests/google/registry/model/registrar/RegistrarTest.java b/javatests/google/registry/model/registrar/RegistrarTest.java index 0309b66c5..801d8ba7d 100644 --- a/javatests/google/registry/model/registrar/RegistrarTest.java +++ b/javatests/google/registry/model/registrar/RegistrarTest.java @@ -314,8 +314,26 @@ public class RegistrarTest extends EntityTestCase { @Test public void testFailure_missingRegistrarType() throws Exception { - thrown.expect(NullPointerException.class); - new Registrar.Builder().build(); + thrown.expect(IllegalArgumentException.class, "Registrar type cannot be null"); + new Registrar.Builder().setRegistrarName("blah").build(); + } + + @Test + public void testFailure_missingRegistrarName() throws Exception { + thrown.expect(IllegalArgumentException.class, "Registrar name cannot be null"); + new Registrar.Builder().setClientId("blahid").setType(Registrar.Type.TEST).build(); + } + + @Test + public void testFailure_missingAddress() throws Exception { + thrown.expect( + IllegalArgumentException.class, + "Must specify at least one of localized or internationalized address"); + new Registrar.Builder() + .setClientId("blahid") + .setType(Registrar.Type.TEST) + .setRegistrarName("Blah Co") + .build(); } @Test diff --git a/javatests/google/registry/rde/RdeMarshallerTest.java b/javatests/google/registry/rde/RdeMarshallerTest.java index bab2f736f..1c6f2edec 100644 --- a/javatests/google/registry/rde/RdeMarshallerTest.java +++ b/javatests/google/registry/rde/RdeMarshallerTest.java @@ -20,8 +20,6 @@ import google.registry.model.registrar.Registrar; import google.registry.testing.AppEngineRule; import google.registry.testing.ShardableTestCase; import google.registry.xml.XmlTestUtils; -import org.joda.time.DateTime; -import org.joda.time.format.ISODateTimeFormat; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -82,46 +80,10 @@ public class RdeMarshallerTest extends ShardableTestCase { "registrar.upDate"); } - @Test - public void testMarshalRegistrar_breaksRdeXmlSchema_producesErrorMessage() throws Exception { - Registrar reg = Registrar.loadByClientId("TheRegistrar").asBuilder() - .setLocalizedAddress(null) - .setInternationalizedAddress(null) - .build(); - DepositFragment fragment = new RdeMarshaller().marshalRegistrar(reg); - assertThat(fragment.type()).isEqualTo(RdeResourceType.REGISTRAR); - assertThat(fragment.xml()).isEmpty(); - assertThat(fragment.error()).isEqualTo("" - + "RDE XML schema validation failed: " - + "Key(EntityGroupRoot(\"cross-tld\")/Registrar(\"TheRegistrar\"))\n" - + "org.xml.sax.SAXParseException; lineNumber: 0; columnNumber: 0; cvc-complex-type.2.4.a: " - + "Invalid content was found starting with element 'rdeRegistrar:voice'. " - + "One of '{\"urn:ietf:params:xml:ns:rdeRegistrar-1.0\":postalInfo}' is expected.\n" - + "\n" - + " TheRegistrar\n" - + " The Registrar\n" - + " 1\n" - + " ok\n" - + " +1.2223334444\n" - + " new.registrar@example.com\n" - + " \n" - + " whois.nic.fakewhois.example\n" - + " \n" - + " " + ft(reg.getCreationTime()) + "\n" - + " " + ft(reg.getLastUpdateTime()) + "\n" - + "\n" - + "\n"); - } - @Test public void testMarshalRegistrar_unicodeCharacters_dontGetMangled() throws Exception { DepositFragment fragment = new RdeMarshaller().marshalRegistrar(Registrar.loadByClientId("TheRegistrar")); assertThat(fragment.xml()).contains("123 Example Bőulevard"); } - - /** Formats {@code timestamp} without milliseconds. */ - private static String ft(DateTime timestamp) { - return ISODateTimeFormat.dateTimeNoMillis().withZoneUTC().print(timestamp); - } } diff --git a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java index 2e59b3f90..3f2d039f7 100644 --- a/javatests/google/registry/rde/imports/RdeImportUtilsTest.java +++ b/javatests/google/registry/rde/imports/RdeImportUtilsTest.java @@ -47,6 +47,7 @@ import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndexBucket; import google.registry.model.index.ForeignKeyIndex; +import google.registry.model.registrar.Registrar; import google.registry.model.registry.Registry.TldState; import google.registry.testing.AppEngineRule; import google.registry.testing.ExceptionRule; @@ -96,7 +97,7 @@ public class RdeImportUtilsTest extends ShardableTestCase { rdeImportUtils = new RdeImportUtils(ofy(), clock, "import-bucket", gcsUtils); createTld("test", TldState.PREDELEGATION); createTld("getld", TldState.GENERAL_AVAILABILITY); - persistNewRegistrar("RegistrarX", 1L); + persistNewRegistrar("RegistrarX", "RegistrarX", Registrar.Type.REAL, 1L); } @After @@ -287,8 +288,8 @@ public class RdeImportUtilsTest extends ShardableTestCase { .setContacts(ImmutableSet.of( DesignatedContact.create(Type.ADMIN, Key.create(admin)), DesignatedContact.create(Type.TECH, Key.create(admin)))) - .setPersistedCurrentSponsorClientId("RegistrarX") - .setCreationClientId("RegistrarX") + .setPersistedCurrentSponsorClientId("registrarx") + .setCreationClientId("registrarx") .setCreationTime(DateTime.parse("1999-04-03T22:00:00.0Z")) .setRegistrationExpirationTime(DateTime.parse("2015-04-03T22:00:00.0Z")) .build(); diff --git a/javatests/google/registry/testing/DatastoreHelper.java b/javatests/google/registry/testing/DatastoreHelper.java index 9b6ace72a..8ea3a3114 100644 --- a/javatests/google/registry/testing/DatastoreHelper.java +++ b/javatests/google/registry/testing/DatastoreHelper.java @@ -83,6 +83,7 @@ import google.registry.model.ofy.ObjectifyService; import google.registry.model.poll.PollMessage; import google.registry.model.pricing.StaticPremiumListPricingEngine; import google.registry.model.registrar.Registrar; +import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registry.Registry; import google.registry.model.registry.Registry.TldState; import google.registry.model.registry.Registry.TldType; @@ -611,14 +612,22 @@ public class DatastoreHelper { .build()); } - /** Creates a stripped-down {@link Registrar} with the specified clientId and ianaIdentifier */ - public static Registrar persistNewRegistrar(String clientId, long ianaIdentifier) { + /** Persists and returns a {@link Registrar} with the specified attributes. */ + public static Registrar persistNewRegistrar( + String clientId, String registrarName, Registrar.Type type, long ianaIdentifier) { return persistSimpleResource( new Registrar.Builder() - .setClientId(clientId) - .setType(Registrar.Type.REAL) - .setIanaIdentifier(ianaIdentifier) - .build()); + .setClientId(clientId) + .setRegistrarName(registrarName) + .setType(type) + .setIanaIdentifier(ianaIdentifier) + .setLocalizedAddress( + new RegistrarAddress.Builder() + .setStreet(ImmutableList.of("123 Fake St")) + .setCity("Fakington") + .setCountryCode("US") + .build()) + .build()); } private static Iterable getBillingEvents() { diff --git a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java index cccbec159..68331166d 100644 --- a/javatests/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/javatests/google/registry/testing/FullFieldsTestEntityHelper.java @@ -130,7 +130,8 @@ public final class FullFieldsTestEntityHelper { HostResource.Builder builder = new HostResource.Builder() .setRepoId(generateNewContactHostRoid()) .setFullyQualifiedHostName(Idn.toASCII(fqhn)) - .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")); + .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")) + .setPersistedCurrentSponsorClientId("TheRegistrar"); if ((ip1 != null) || (ip2 != null)) { ImmutableSet.Builder ipBuilder = new ImmutableSet.Builder<>(); if (ip1 != null) { diff --git a/javatests/google/registry/tools/CreateRegistrarCommandTest.java b/javatests/google/registry/tools/CreateRegistrarCommandTest.java index 5aba5d291..c6812b18f 100644 --- a/javatests/google/registry/tools/CreateRegistrarCommandTest.java +++ b/javatests/google/registry/tools/CreateRegistrarCommandTest.java @@ -19,7 +19,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.CertificateSamples.SAMPLE_CERT; import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH; import static google.registry.testing.DatastoreHelper.createTlds; -import static google.registry.testing.DatastoreHelper.persistResource; +import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static org.joda.time.DateTimeZone.UTC; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.verify; @@ -49,21 +49,24 @@ public class CreateRegistrarCommandTest extends CommandTestCase { public void setUp() throws Exception { command.setConnection(connection); createTld("example"); - persistNewRegistrar("acme", 99); + persistNewRegistrar("acme", "ACME", Registrar.Type.REAL, 99L); } @Test diff --git a/javatests/google/registry/tools/MutatingCommandTest.java b/javatests/google/registry/tools/MutatingCommandTest.java index 0200baaa8..1acbed98b 100644 --- a/javatests/google/registry/tools/MutatingCommandTest.java +++ b/javatests/google/registry/tools/MutatingCommandTest.java @@ -20,6 +20,7 @@ import static google.registry.model.ofy.ObjectifyService.ofy; import static google.registry.testing.DatastoreHelper.createTld; import static google.registry.testing.DatastoreHelper.deleteResource; import static google.registry.testing.DatastoreHelper.persistActiveHost; +import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static org.joda.time.DateTimeZone.UTC; @@ -58,16 +59,8 @@ public class MutatingCommandTest { @Before public void init() { - registrar1 = persistResource(new Registrar.Builder() - .setType(Registrar.Type.REAL) - .setClientId("Registrar1") - .setIanaIdentifier(1L) - .build()); - registrar2 = persistResource(new Registrar.Builder() - .setType(Registrar.Type.REAL) - .setClientId("Registrar2") - .setIanaIdentifier(2L) - .build()); + registrar1 = persistNewRegistrar("Registrar1", "Registrar1", Registrar.Type.REAL, 1L); + registrar2 = persistNewRegistrar("Registrar2", "Registrar2", Registrar.Type.REAL, 2L); newRegistrar1 = registrar1.asBuilder().setBillingIdentifier(42L).build(); newRegistrar2 = registrar2.asBuilder().setBlockPremiumNames(true).build(); diff --git a/javatests/google/registry/whois/NameserverWhoisResponseTest.java b/javatests/google/registry/whois/NameserverWhoisResponseTest.java index ef6e9ab01..317627b47 100644 --- a/javatests/google/registry/whois/NameserverWhoisResponseTest.java +++ b/javatests/google/registry/whois/NameserverWhoisResponseTest.java @@ -16,7 +16,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatastoreHelper.createTld; -import static google.registry.testing.DatastoreHelper.persistResource; +import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.whois.WhoisHelper.loadWhoisTestFile; import com.google.common.collect.ImmutableList; @@ -50,13 +50,7 @@ public class NameserverWhoisResponseTest { @Before public void setUp() { - persistResource(new Registrar.Builder() - .setClientId("example") - .setRegistrarName("Example Registrar, Inc.") - .setType(Registrar.Type.REAL) - .setIanaIdentifier(8L) - .build()); - + persistNewRegistrar("example", "Example Registrar, Inc.", Registrar.Type.REAL, 8L); createTld("tld"); hostResource1 = new HostResource.Builder() diff --git a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java index e9b3748c7..006c67122 100644 --- a/javatests/google/registry/whois/RegistrarWhoisResponseTest.java +++ b/javatests/google/registry/whois/RegistrarWhoisResponseTest.java @@ -15,6 +15,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; +import static google.registry.testing.DatastoreHelper.persistNewRegistrar; import static google.registry.testing.DatastoreHelper.persistResource; import static google.registry.testing.DatastoreHelper.persistSimpleResources; import static google.registry.whois.WhoisHelper.loadWhoisTestFile; @@ -120,12 +121,8 @@ public class RegistrarWhoisResponseTest { @Test public void testSetOfFields() { - Registrar registrar = new Registrar.Builder() - .setClientId("exregistrar") - .setType(Registrar.Type.REAL) - .setIanaIdentifier(8L) - .setState(Registrar.State.ACTIVE) - .build(); + Registrar registrar = + persistNewRegistrar("exregistrar", "Ex-Registrar", Registrar.Type.REAL, 8L); RegistrarWhoisResponse registrarWhoisResponse = new RegistrarWhoisResponse(registrar, clock.nowUtc()); diff --git a/javatests/google/registry/whois/testdata/whois_server_nameserver.txt b/javatests/google/registry/whois/testdata/whois_server_nameserver.txt index b05866110..9119354cc 100644 --- a/javatests/google/registry/whois/testdata/whois_server_nameserver.txt +++ b/javatests/google/registry/whois/testdata/whois_server_nameserver.txt @@ -1,6 +1,6 @@ Server Name: ns1.cat.lol IP Address: 1.2.3.4 -Registrar: +Registrar: The Registrar Registrar WHOIS Server: whois.nic.fakewhois.example Registrar URL: http://www.referral.example/path >>> Last update of WHOIS database: 2009-06-29T20:13:00Z <<<