diff --git a/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java b/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java index 596d467a8..0483e1472 100644 --- a/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java +++ b/core/src/main/java/google/registry/batch/AsyncTaskEnqueuer.java @@ -29,7 +29,7 @@ import com.google.common.flogger.FluentLogger; import google.registry.config.RegistryConfig.Config; import google.registry.model.EppResource; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.request.Action.Service; import google.registry.util.CloudTasksUtils; @@ -140,8 +140,8 @@ public final class AsyncTaskEnqueuer { } /** Enqueues a task to asynchronously refresh DNS for a renamed host. */ - public void enqueueAsyncDnsRefresh(HostResource host, DateTime now) { - VKey hostKey = host.createVKey(); + public void enqueueAsyncDnsRefresh(Host host, DateTime now) { + VKey hostKey = host.createVKey(); logger.atInfo().log("Enqueuing async DNS refresh for renamed host %s.", hostKey); addTaskToQueueWithRetry( asyncDnsRefreshPullQueue, diff --git a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java index f31cb7e3d..30d29da9e 100644 --- a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java @@ -31,7 +31,7 @@ import google.registry.model.EppResource; import google.registry.model.EppResourceUtils; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntryDao; @@ -43,8 +43,8 @@ import google.registry.util.Clock; import javax.inject.Inject; /** - * Hard deletes load-test ContactResources, HostResources, their subordinate history entries, and - * the associated ForeignKey and EppResourceIndex entities. + * Hard deletes load-test ContactResources, Hosts, their subordinate history entries, and the + * associated ForeignKey and EppResourceIndex entities. * *

This only deletes contacts and hosts, NOT domains. To delete domains, use {@link * DeleteProberDataAction} and pass it the TLD(s) that the load test domains were created on. Note @@ -93,7 +93,7 @@ public class DeleteLoadTestDataAction implements Runnable { () -> { LOAD_TEST_REGISTRARS.forEach(this::deletePollMessages); tm().loadAllOfStream(ContactResource.class).forEach(this::deleteContact); - tm().loadAllOfStream(HostResource.class).forEach(this::deleteHost); + tm().loadAllOfStream(Host.class).forEach(this::deleteHost); }); } @@ -123,11 +123,11 @@ public class DeleteLoadTestDataAction implements Runnable { deleteResource(contact); } - private void deleteHost(HostResource host) { + private void deleteHost(Host host) { if (!LOAD_TEST_REGISTRARS.contains(host.getPersistedCurrentSponsorRegistrarId())) { return; } - VKey hostVKey = host.createVKey(); + VKey hostVKey = host.createVKey(); // We can remove hosts from linked domains, so we should do so then delete the hosts ImmutableSet> linkedDomains = EppResourceUtils.getLinkedDomainKeys(hostVKey, clock.nowUtc(), null); @@ -135,7 +135,7 @@ public class DeleteLoadTestDataAction implements Runnable { .values() .forEach( domain -> { - ImmutableSet> remainingHosts = + ImmutableSet> remainingHosts = domain.getNsHosts().stream() .filter(vkey -> !vkey.equals(hostVKey)) .collect(toImmutableSet()); diff --git a/core/src/main/java/google/registry/beam/rde/RdePipeline.java b/core/src/main/java/google/registry/beam/rde/RdePipeline.java index 953d2dc1f..0bb7b9a24 100644 --- a/core/src/main/java/google/registry/beam/rde/RdePipeline.java +++ b/core/src/main/java/google/registry/beam/rde/RdePipeline.java @@ -49,8 +49,8 @@ import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; +import google.registry.model.host.Host; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.rde.RdeMode; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar.Type; @@ -148,7 +148,7 @@ import org.joda.time.DateTime; * then loaded from the remaining referenced contact histories, and marshalled into (pending * deposit: deposit fragment) pairs. * - *

{@link HostResource}

+ *

{@link Host}

* * Similar to {@link ContactResource}, we join the most recent host history with referenced hosts to * find most recent referenced hosts. For external hosts we do the same treatment as we did on @@ -467,10 +467,9 @@ public class RdePipeline implements Serializable { Counter activeDomainCounter = Metrics.counter("RDE", "ActiveDomainBase"); Counter domainFragmentCounter = Metrics.counter("RDE", "DomainFragment"); Counter referencedContactCounter = Metrics.counter("RDE", "ReferencedContactResource"); - Counter referencedHostCounter = Metrics.counter("RDE", "ReferencedHostResource"); + Counter referencedHostCounter = Metrics.counter("RDE", "ReferencedHost"); return domainHistories.apply( - "Map DomainHistory to DepositFragment " - + "and emit referenced ContactResource and HostResource", + "Map DomainHistory to DepositFragment " + "and emit referenced ContactResource and Host", ParDo.of( new DoFn, KV>() { @ProcessElement @@ -565,10 +564,10 @@ public class RdePipeline implements Serializable { private PCollectionTuple processHostHistories( PCollection> referencedHosts, PCollection> hostHistories) { - Counter subordinateHostCounter = Metrics.counter("RDE", "SubordinateHostResource"); - Counter externalHostCounter = Metrics.counter("RDE", "ExternalHostResource"); + Counter subordinateHostCounter = Metrics.counter("RDE", "SubordinateHost"); + Counter externalHostCounter = Metrics.counter("RDE", "ExternalHost"); Counter externalHostFragmentCounter = Metrics.counter("RDE", "ExternalHostFragment"); - return removeUnreferencedResource(referencedHosts, hostHistories, HostResource.class) + return removeUnreferencedResource(referencedHosts, hostHistories, Host.class) .apply( "Map external DomainResource to DepositFragment and process subordinate domains", ParDo.of( @@ -576,8 +575,8 @@ public class RdePipeline implements Serializable { @ProcessElement public void processElement( @Element KV kv, MultiOutputReceiver receiver) { - HostResource host = - (HostResource) + Host host = + (Host) loadResourceByHistoryEntryId( HostHistory.class, kv.getKey(), @@ -631,11 +630,9 @@ public class RdePipeline implements Serializable { Counter referencedSubordinateHostCounter = Metrics.counter("RDE", "ReferencedSubordinateHost"); return KeyedPCollectionTuple.of(HOST_TO_PENDING_DEPOSIT, superordinateDomains) .and(REVISION_ID, domainHistories) + .apply("Join Host:PendingDeposits with DomainHistory on Domain", CoGroupByKey.create()) .apply( - "Join HostResource:PendingDeposits with DomainHistory on DomainResource", - CoGroupByKey.create()) - .apply( - " Remove unreferenced DomainResource", + " Remove unreferenced Domain", Filter.by( kv -> { boolean toInclude = @@ -647,7 +644,7 @@ public class RdePipeline implements Serializable { return toInclude; })) .apply( - "Map subordinate HostResource to DepositFragment", + "Map subordinate Host to DepositFragment", FlatMapElements.into( kvs( TypeDescriptor.of(PendingDeposit.class), @@ -664,8 +661,8 @@ public class RdePipeline implements Serializable { new ImmutableSet.Builder<>(); for (KV hostToPendingDeposits : kv.getValue().getAll(HOST_TO_PENDING_DEPOSIT)) { - HostResource host = - (HostResource) + Host host = + (Host) loadResourceByHistoryEntryId( HostHistory.class, hostToPendingDeposits.getKey(), diff --git a/core/src/main/java/google/registry/beam/resave/ResaveAllEppResourcesPipeline.java b/core/src/main/java/google/registry/beam/resave/ResaveAllEppResourcesPipeline.java index 8d1637bc6..014e1e9fd 100644 --- a/core/src/main/java/google/registry/beam/resave/ResaveAllEppResourcesPipeline.java +++ b/core/src/main/java/google/registry/beam/resave/ResaveAllEppResourcesPipeline.java @@ -25,7 +25,7 @@ import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainBase; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.PersistenceModule.TransactionIsolationLevel; import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.util.DateTimeUtils; @@ -52,7 +52,7 @@ import org.joda.time.DateTime; public class ResaveAllEppResourcesPipeline implements Serializable { private static final ImmutableSet> EPP_RESOURCE_CLASSES = - ImmutableSet.of(ContactResource.class, Domain.class, HostResource.class); + ImmutableSet.of(ContactResource.class, Domain.class, Host.class); /** * There exist three possible situations where we know we'll want to project domains to the diff --git a/core/src/main/java/google/registry/dns/RefreshDnsAction.java b/core/src/main/java/google/registry/dns/RefreshDnsAction.java index e131f7c55..a0d9311bb 100644 --- a/core/src/main/java/google/registry/dns/RefreshDnsAction.java +++ b/core/src/main/java/google/registry/dns/RefreshDnsAction.java @@ -21,7 +21,7 @@ import google.registry.model.EppResource; import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.request.Action; import google.registry.request.HttpException.BadRequestException; import google.registry.request.HttpException.NotFoundException; @@ -66,7 +66,7 @@ public final class RefreshDnsAction implements Runnable { dnsQueue.addDomainRefreshTask(domainOrHostName); break; case HOST: - verifyHostIsSubordinate(loadAndVerifyExistence(HostResource.class, domainOrHostName)); + verifyHostIsSubordinate(loadAndVerifyExistence(Host.class, domainOrHostName)); dnsQueue.addHostRefreshTask(domainOrHostName); break; default: @@ -86,7 +86,7 @@ public final class RefreshDnsAction implements Runnable { domainOrHostName))); } - private static void verifyHostIsSubordinate(HostResource host) { + private static void verifyHostIsSubordinate(Host host) { if (!host.isSubordinate()) { throw new BadRequestException( String.format("%s isn't a subordinate hostname", host.getHostName())); diff --git a/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java b/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java index 54a7f2ff2..87cbf02be 100644 --- a/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java +++ b/core/src/main/java/google/registry/dns/writer/clouddns/CloudDnsWriter.java @@ -38,7 +38,7 @@ import google.registry.dns.writer.DnsWriter; import google.registry.dns.writer.DnsWriterZone; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.tld.Registries; import google.registry.util.Clock; import google.registry.util.Concurrent; @@ -190,7 +190,7 @@ public class CloudDnsWriter extends BaseDnsWriter { // Load the target host. Note that it can be absent if this host was just deleted. // desiredRecords is populated with an empty set to indicate that all existing records // should be deleted. - Optional host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc()); + Optional host = loadByForeignKey(Host.class, hostName, clock.nowUtc()); // Return early if the host is deleted. if (!host.isPresent()) { diff --git a/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java b/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java index cb28ce2e5..9b2771111 100644 --- a/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java +++ b/core/src/main/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriter.java @@ -29,7 +29,7 @@ import google.registry.dns.writer.BaseDnsWriter; import google.registry.dns.writer.DnsWriterZone; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.tld.Registries; import google.registry.util.Clock; import java.io.IOException; @@ -215,7 +215,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { private void addInBailiwickNameServerSet(Domain domain, Update update) { for (String hostName : intersection(domain.loadNameserverHostNames(), domain.getSubordinateHosts())) { - Optional host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc()); + Optional host = loadByForeignKey(Host.class, hostName, clock.nowUtc()); checkState(host.isPresent(), "Host %s cannot be loaded", hostName); update.add(makeAddressSet(host.get())); update.add(makeV6AddressSet(host.get())); @@ -236,7 +236,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { return nameServerSet; } - private RRset makeAddressSet(HostResource host) { + private RRset makeAddressSet(Host host) { RRset addressSet = new RRset(); for (InetAddress address : host.getInetAddresses()) { if (address instanceof Inet4Address) { @@ -252,7 +252,7 @@ public class DnsUpdateWriter extends BaseDnsWriter { return addressSet; } - private RRset makeV6AddressSet(HostResource host) { + private RRset makeV6AddressSet(Host host) { RRset addressSet = new RRset(); for (InetAddress address : host.getInetAddresses()) { if (address instanceof Inet6Address) { diff --git a/core/src/main/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml b/core/src/main/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml index bad80fa24..eba8edb84 100644 --- a/core/src/main/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml +++ b/core/src/main/java/google/registry/env/common/default/WEB-INF/datastore-indexes.xml @@ -26,7 +26,7 @@ - + @@ -52,7 +52,7 @@ - + @@ -87,7 +87,7 @@ - + diff --git a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java index 7814b6757..c83f1a133 100644 --- a/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java +++ b/core/src/main/java/google/registry/flows/domain/DomainFlowUtils.java @@ -114,7 +114,7 @@ import google.registry.model.domain.secdns.SecDnsUpdateExtension.Remove; import google.registry.model.domain.token.AllocationToken; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppoutput.EppResponse.ResponseExtension; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.Registrar.State; @@ -375,7 +375,7 @@ public class DomainFlowUtils { static void verifyNotInPendingDelete( Set contacts, VKey registrant, - Set> nameservers) + Set> nameservers) throws EppException { ImmutableList.Builder> keysToLoad = new ImmutableList.Builder<>(); contacts.stream().map(DesignatedContact::getContactKey).forEach(keysToLoad::add); diff --git a/core/src/main/java/google/registry/flows/host/HostCheckFlow.java b/core/src/main/java/google/registry/flows/host/HostCheckFlow.java index 734325f84..93dbc8bdc 100644 --- a/core/src/main/java/google/registry/flows/host/HostCheckFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostCheckFlow.java @@ -30,8 +30,8 @@ import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.CheckData.HostCheck; import google.registry.model.eppoutput.CheckData.HostCheckData; import google.registry.model.eppoutput.EppResponse; +import google.registry.model.host.Host; import google.registry.model.host.HostCommand.Check; -import google.registry.model.host.HostResource; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; import javax.inject.Inject; @@ -61,8 +61,7 @@ public final class HostCheckFlow implements Flow { extensionManager.validate(); // There are no legal extensions for this flow. ImmutableList hostnames = ((Check) resourceCommand).getTargetIds(); verifyTargetIdCount(hostnames, maxChecks); - ImmutableSet existingIds = - checkResourcesExist(HostResource.class, hostnames, clock.nowUtc()); + ImmutableSet existingIds = checkResourcesExist(Host.class, hostnames, clock.nowUtc()); ImmutableList.Builder checks = new ImmutableList.Builder<>(); for (String hostname : hostnames) { boolean unused = !existingIds.contains(hostname); diff --git a/core/src/main/java/google/registry/flows/host/HostCreateFlow.java b/core/src/main/java/google/registry/flows/host/HostCreateFlow.java index 2919205b4..b1576e59b 100644 --- a/core/src/main/java/google/registry/flows/host/HostCreateFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostCreateFlow.java @@ -46,9 +46,9 @@ import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.CreateData.HostCreateData; import google.registry.model.eppoutput.EppResponse; +import google.registry.model.host.Host; import google.registry.model.host.HostCommand.Create; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; @@ -105,7 +105,7 @@ public final class HostCreateFlow implements TransactionalFlow { extensionManager.validate(); Create command = (Create) resourceCommand; DateTime now = tm().getTransactionTime(); - verifyResourceDoesNotExist(HostResource.class, targetId, now, registrarId); + verifyResourceDoesNotExist(Host.class, targetId, now, registrarId); // The superordinate domain of the host object if creating an in-bailiwick host, or null if // creating an external host. This is looked up before we actually create the Host object so // we can detect error conditions earlier. @@ -121,8 +121,8 @@ public final class HostCreateFlow implements TransactionalFlow { ? new SubordinateHostMustHaveIpException() : new UnexpectedExternalHostIpException(); } - HostResource newHost = - new HostResource.Builder() + Host newHost = + new Host.Builder() .setCreationRegistrarId(registrarId) .setPersistedCurrentSponsorRegistrarId(registrarId) .setHostName(targetId) diff --git a/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java b/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java index 07ed394f1..1b766f0ce 100644 --- a/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostDeleteFlow.java @@ -38,8 +38,8 @@ import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; import google.registry.model.eppoutput.EppResponse; +import google.registry.model.host.Host; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.reporting.HistoryEntry.Type; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import javax.inject.Inject; @@ -92,8 +92,8 @@ public final class HostDeleteFlow implements TransactionalFlow { extensionManager.validate(); DateTime now = tm().getTransactionTime(); validateHostName(targetId); - checkLinkedDomains(targetId, now, HostResource.class); - HostResource existingHost = loadAndVerifyExistence(HostResource.class, targetId, now); + checkLinkedDomains(targetId, now, Host.class); + Host existingHost = loadAndVerifyExistence(Host.class, targetId, now); verifyNoDisallowedStatuses(existingHost, DISALLOWED_STATUSES); if (!isSuperuser) { // Hosts transfer with their superordinate domains, so for hosts with a superordinate domain, @@ -104,8 +104,7 @@ public final class HostDeleteFlow implements TransactionalFlow { : existingHost; verifyResourceOwnership(registrarId, owningResource); } - HostResource newHost = - existingHost.asBuilder().setStatusValues(null).setDeletionTime(now).build(); + Host newHost = existingHost.asBuilder().setStatusValues(null).setDeletionTime(now).build(); if (existingHost.isSubordinate()) { dnsQueue.addHostRefreshTask(existingHost.getHostName()); tm().update( diff --git a/core/src/main/java/google/registry/flows/host/HostInfoFlow.java b/core/src/main/java/google/registry/flows/host/HostInfoFlow.java index e83036965..7aa369deb 100644 --- a/core/src/main/java/google/registry/flows/host/HostInfoFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostInfoFlow.java @@ -30,8 +30,8 @@ import google.registry.flows.annotations.ReportingSpec; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppoutput.EppResponse; +import google.registry.model.host.Host; import google.registry.model.host.HostInfoData; -import google.registry.model.host.HostResource; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.util.Clock; import javax.inject.Inject; @@ -65,7 +65,7 @@ public final class HostInfoFlow implements Flow { extensionManager.validate(); // There are no legal extensions for this flow. validateHostName(targetId); DateTime now = clock.nowUtc(); - HostResource host = loadAndVerifyExistence(HostResource.class, targetId, now); + Host host = loadAndVerifyExistence(Host.class, targetId, now); ImmutableSet.Builder statusValues = new ImmutableSet.Builder<>(); statusValues.addAll(host.getStatusValues()); if (isLinked(host.createVKey(), now)) { diff --git a/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java b/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java index a7394729d..dc0029ca1 100644 --- a/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java +++ b/core/src/main/java/google/registry/flows/host/HostUpdateFlow.java @@ -52,11 +52,11 @@ import google.registry.model.domain.metadata.MetadataExtension; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppinput.ResourceCommand; import google.registry.model.eppoutput.EppResponse; +import google.registry.model.host.Host; import google.registry.model.host.HostCommand.Update; import google.registry.model.host.HostCommand.Update.AddRemove; import google.registry.model.host.HostCommand.Update.Change; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.reporting.IcannReportingTypes.ActivityReportField; import google.registry.persistence.VKey; @@ -133,7 +133,7 @@ public final class HostUpdateFlow implements TransactionalFlow { String suppliedNewHostName = change.getFullyQualifiedHostName(); DateTime now = tm().getTransactionTime(); validateHostName(targetId); - HostResource existingHost = loadAndVerifyExistence(HostResource.class, targetId, now); + Host existingHost = loadAndVerifyExistence(Host.class, targetId, now); boolean isHostRename = suppliedNewHostName != null; String oldHostName = targetId; String newHostName = firstNonNull(suppliedNewHostName, oldHostName); @@ -148,7 +148,7 @@ public final class HostUpdateFlow implements TransactionalFlow { EppResource owningResource = firstNonNull(oldSuperordinateDomain, existingHost); verifyUpdateAllowed( command, existingHost, newSuperordinateDomain.orElse(null), owningResource, isHostRename); - if (isHostRename && loadAndGetKey(HostResource.class, newHostName, now) != null) { + if (isHostRename && loadAndGetKey(Host.class, newHostName, now) != null) { throw new HostAlreadyExistsException(newHostName); } AddRemove add = command.getInnerAdd(); @@ -175,7 +175,7 @@ public final class HostUpdateFlow implements TransactionalFlow { newSuperordinateDomain.isPresent() ? newSuperordinateDomain.get().getCurrentSponsorRegistrarId() : owningResource.getPersistedCurrentSponsorRegistrarId(); - HostResource newHost = + Host newHost = existingHost .asBuilder() .setHostName(newHostName) @@ -210,7 +210,7 @@ public final class HostUpdateFlow implements TransactionalFlow { private void verifyUpdateAllowed( Update command, - HostResource existingHost, + Host existingHost, Domain newSuperordinateDomain, EppResource owningResource, boolean isHostRename) @@ -237,8 +237,8 @@ public final class HostUpdateFlow implements TransactionalFlow { verifyNoDisallowedStatuses(existingHost, DISALLOWED_STATUSES); } - private void verifyHasIpsIffIsExternal( - Update command, HostResource existingHost, HostResource newHost) throws EppException { + private void verifyHasIpsIffIsExternal(Update command, Host existingHost, Host newHost) + throws EppException { boolean wasSubordinate = existingHost.isSubordinate(); boolean willBeSubordinate = newHost.isSubordinate(); boolean willBeExternal = !willBeSubordinate; @@ -258,7 +258,7 @@ public final class HostUpdateFlow implements TransactionalFlow { } } - private void enqueueTasks(HostResource existingHost, HostResource newHost) { + private void enqueueTasks(Host existingHost, Host newHost) { // Only update DNS for subordinate hosts. External hosts have no glue to write, so they // are only written as NS records from the referencing domain. if (existingHost.isSubordinate()) { @@ -277,7 +277,7 @@ public final class HostUpdateFlow implements TransactionalFlow { } } - private static void updateSuperordinateDomains(HostResource existingHost, HostResource newHost) { + private static void updateSuperordinateDomains(Host existingHost, Host newHost) { if (existingHost.isSubordinate() && newHost.isSubordinate() && Objects.equals( diff --git a/core/src/main/java/google/registry/model/BackupGroupRoot.java b/core/src/main/java/google/registry/model/BackupGroupRoot.java index aa6b29f61..c7212b539 100644 --- a/core/src/main/java/google/registry/model/BackupGroupRoot.java +++ b/core/src/main/java/google/registry/model/BackupGroupRoot.java @@ -41,7 +41,7 @@ public abstract class BackupGroupRoot extends ImmutableObject implements UnsafeS * that this is updated on every save, rather than only in response to an {@code } command */ @XmlTransient - // Prevents subclasses from unexpectedly accessing as property (e.g., HostResource), which would + // Prevents subclasses from unexpectedly accessing as property (e.g., Host), which would // require an unnecessary non-private setter method. @Access(AccessType.FIELD) @AttributeOverride(name = "lastUpdateTime", column = @Column(name = "updateTimestamp")) diff --git a/core/src/main/java/google/registry/model/EntityClasses.java b/core/src/main/java/google/registry/model/EntityClasses.java index 7b9720423..02d99728a 100644 --- a/core/src/main/java/google/registry/model/EntityClasses.java +++ b/core/src/main/java/google/registry/model/EntityClasses.java @@ -23,8 +23,8 @@ import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.token.AllocationToken; +import google.registry.model.host.Host; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndexBucket; import google.registry.model.index.ForeignKeyIndex; @@ -55,8 +55,8 @@ public final class EntityClasses { ForeignKeyIndex.ForeignKeyHostIndex.class, GaeUserIdConverter.class, HistoryEntry.class, + Host.class, HostHistory.class, - HostResource.class, Lock.class, PollMessage.class, PollMessage.Autorenew.class, diff --git a/core/src/main/java/google/registry/model/EppResourceUtils.java b/core/src/main/java/google/registry/model/EppResourceUtils.java index c9c0304b9..da4ba7249 100644 --- a/core/src/main/java/google/registry/model/EppResourceUtils.java +++ b/core/src/main/java/google/registry/model/EppResourceUtils.java @@ -35,7 +35,7 @@ import google.registry.model.EppResource.ResourceWithTransferData; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.reporting.HistoryEntry; import google.registry.model.reporting.HistoryEntryDao; @@ -345,8 +345,8 @@ public final class EppResourceUtils { public static ImmutableSet> getLinkedDomainKeys( VKey key, DateTime now, @Nullable Integer limit) { checkArgument( - key.getKind().equals(ContactResource.class) || key.getKind().equals(HostResource.class), - "key must be either VKey or VKey, but it is %s", + key.getKind().equals(ContactResource.class) || key.getKind().equals(Host.class), + "key must be either VKey or VKey, but it is %s", key); boolean isContactKey = key.getKind().equals(ContactResource.class); if (tm().isOfy()) { diff --git a/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java b/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java index db6f6a47e..c5ba6aab2 100644 --- a/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java +++ b/core/src/main/java/google/registry/model/bulkquery/BulkQueryEntities.java @@ -26,7 +26,7 @@ import google.registry.model.domain.GracePeriod; import google.registry.model.domain.GracePeriod.GracePeriodHistory; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DomainDsDataHistory; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.persistence.VKey; import google.registry.persistence.transaction.JpaTransactionManager; @@ -68,7 +68,7 @@ public class BulkQueryEntities { DomainLite domainLite, ImmutableSet gracePeriods, ImmutableSet delegationSignerData, - ImmutableSet> nsHosts) { + ImmutableSet> nsHosts) { Domain.Builder builder = new Domain.Builder(); builder.copyFrom(domainLite); builder.setGracePeriods(gracePeriods); @@ -82,7 +82,7 @@ public class BulkQueryEntities { public static DomainHistory assembleDomainHistory( DomainHistoryLite domainHistoryLite, ImmutableSet dsDataHistories, - ImmutableSet> domainHistoryHosts, + ImmutableSet> domainHistoryHosts, ImmutableSet gracePeriodHistories, ImmutableSet transactionRecords) { DomainHistory.Builder builder = new DomainHistory.Builder(); diff --git a/core/src/main/java/google/registry/model/bulkquery/DomainHistoryHost.java b/core/src/main/java/google/registry/model/bulkquery/DomainHistoryHost.java index f50f41630..8b328a26d 100644 --- a/core/src/main/java/google/registry/model/bulkquery/DomainHistoryHost.java +++ b/core/src/main/java/google/registry/model/bulkquery/DomainHistoryHost.java @@ -16,7 +16,7 @@ package google.registry.model.bulkquery; import com.google.common.base.Objects; import google.registry.model.domain.DomainHistory.DomainHistoryId; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import java.io.Serializable; import javax.persistence.Access; @@ -44,8 +44,8 @@ public class DomainHistoryHost implements Serializable { return new DomainHistoryId(domainHistoryDomainRepoId, domainHistoryHistoryRevisionId); } - public VKey getHostVKey() { - return VKey.create(HostResource.class, hostRepoId); + public VKey getHostVKey() { + return VKey.create(Host.class, hostRepoId); } @Override diff --git a/core/src/main/java/google/registry/model/bulkquery/DomainHost.java b/core/src/main/java/google/registry/model/bulkquery/DomainHost.java index df427da90..a543cfb47 100644 --- a/core/src/main/java/google/registry/model/bulkquery/DomainHost.java +++ b/core/src/main/java/google/registry/model/bulkquery/DomainHost.java @@ -15,7 +15,7 @@ package google.registry.model.bulkquery; import com.google.common.base.Objects; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import java.io.Serializable; import javax.persistence.Access; @@ -40,8 +40,8 @@ public class DomainHost implements Serializable { return domainRepoId; } - public VKey getHostVKey() { - return VKey.create(HostResource.class, hostRepoId); + public VKey getHostVKey() { + return VKey.create(Host.class, hostRepoId); } @Override diff --git a/core/src/main/java/google/registry/model/domain/Domain.java b/core/src/main/java/google/registry/model/domain/Domain.java index 9b4c75be0..868539b44 100644 --- a/core/src/main/java/google/registry/model/domain/Domain.java +++ b/core/src/main/java/google/registry/model/domain/Domain.java @@ -20,7 +20,7 @@ import google.registry.model.EppResource.ForeignKeyedEppResource; import google.registry.model.annotations.ExternalMessagingName; import google.registry.model.annotations.ReportedOn; import google.registry.model.domain.secdns.DelegationSignerData; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.persistence.WithStringVKey; import java.util.Set; @@ -89,7 +89,7 @@ public class Domain extends DomainBase implements ForeignKeyedEppResource { }) @Access(AccessType.PROPERTY) @Column(name = "host_repo_id") - public Set> getNsHosts() { + public Set> getNsHosts() { return super.nsHosts; } diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java index ae7192238..c2ca61793 100644 --- a/core/src/main/java/google/registry/model/domain/DomainBase.java +++ b/core/src/main/java/google/registry/model/domain/DomainBase.java @@ -57,7 +57,7 @@ import google.registry.model.domain.launch.LaunchNotice; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; @@ -128,7 +128,7 @@ public class DomainBase extends EppResource @Index String tld; /** References to hosts that are the nameservers for the domain. */ - @EmptySetToNull @Index @Transient Set> nsHosts; + @EmptySetToNull @Index @Transient Set> nsHosts; /** Contacts. */ VKey adminContact; @@ -372,13 +372,13 @@ public class DomainBase extends EppResource return idnTableName; } - public ImmutableSet> getNameservers() { + public ImmutableSet> getNameservers() { return nullToEmptyImmutableCopy(nsHosts); } // Hibernate needs this in order to populate nsHosts but no one else should ever use it @SuppressWarnings("UnusedMethod") - private void setNsHosts(Set> nsHosts) { + private void setNsHosts(Set> nsHosts) { this.nsHosts = forceEmptyToNull(nsHosts); } @@ -602,7 +602,7 @@ public class DomainBase extends EppResource return tm().transact( () -> tm().loadByKeys(getNameservers()).values().stream() - .map(HostResource::getHostName) + .map(Host::getHostName) .collect(toImmutableSortedSet(Ordering.natural()))); } @@ -787,32 +787,32 @@ public class DomainBase extends EppResource return thisCastToDerived(); } - public B setNameservers(VKey nameserver) { + public B setNameservers(VKey nameserver) { getInstance().nsHosts = ImmutableSet.of(nameserver); getInstance().resetUpdateTimestamp(); return thisCastToDerived(); } - public B setNameservers(ImmutableSet> nameservers) { + public B setNameservers(ImmutableSet> nameservers) { getInstance().nsHosts = forceEmptyToNull(nameservers); getInstance().resetUpdateTimestamp(); return thisCastToDerived(); } - public B addNameserver(VKey nameserver) { + public B addNameserver(VKey nameserver) { return addNameservers(ImmutableSet.of(nameserver)); } - public B addNameservers(ImmutableSet> nameservers) { + public B addNameservers(ImmutableSet> nameservers) { return setNameservers( ImmutableSet.copyOf(Sets.union(getInstance().getNameservers(), nameservers))); } - public B removeNameserver(VKey nameserver) { + public B removeNameserver(VKey nameserver) { return removeNameservers(ImmutableSet.of(nameserver)); } - public B removeNameservers(ImmutableSet> nameservers) { + public B removeNameservers(ImmutableSet> nameservers) { return setNameservers( ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers))); } diff --git a/core/src/main/java/google/registry/model/domain/DomainCommand.java b/core/src/main/java/google/registry/model/domain/DomainCommand.java index 08d24acd8..b4fa6f15d 100644 --- a/core/src/main/java/google/registry/model/domain/DomainCommand.java +++ b/core/src/main/java/google/registry/model/domain/DomainCommand.java @@ -38,7 +38,7 @@ import google.registry.model.eppinput.ResourceCommand.ResourceCheck; import google.registry.model.eppinput.ResourceCommand.ResourceCreateOrChange; import google.registry.model.eppinput.ResourceCommand.ResourceUpdate; import google.registry.model.eppinput.ResourceCommand.SingleResourceCommand; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.ForeignKeyIndex; import google.registry.persistence.VKey; import java.util.Set; @@ -126,7 +126,7 @@ public class DomainCommand { Set nameserverFullyQualifiedHostNames; /** Resolved keys to hosts that are the nameservers for the domain. */ - @XmlTransient Set> nameservers; + @XmlTransient Set> nameservers; /** Foreign keyed associated contacts for the domain (other than registrant). */ @XmlElement(name = "contact") @@ -156,7 +156,7 @@ public class DomainCommand { return nullToEmptyImmutableCopy(nameserverFullyQualifiedHostNames); } - public ImmutableSet> getNameservers() { + public ImmutableSet> getNameservers() { return nullToEmptyImmutableCopy(nameservers); } @@ -349,7 +349,7 @@ public class DomainCommand { Set nameserverFullyQualifiedHostNames; /** Resolved keys to hosts that are the nameservers for the domain. */ - @XmlTransient Set> nameservers; + @XmlTransient Set> nameservers; /** Foreign keyed associated contacts for the domain (other than registrant). */ @XmlElement(name = "contact") @@ -363,7 +363,7 @@ public class DomainCommand { return nullSafeImmutableCopy(nameserverFullyQualifiedHostNames); } - public ImmutableSet> getNameservers() { + public ImmutableSet> getNameservers() { return nullToEmptyImmutableCopy(nameservers); } @@ -413,13 +413,13 @@ public class DomainCommand { } } - private static Set> linkHosts( - Set fullyQualifiedHostNames, DateTime now) throws InvalidReferencesException { + private static Set> linkHosts(Set fullyQualifiedHostNames, DateTime now) + throws InvalidReferencesException { if (fullyQualifiedHostNames == null) { return null; } return ImmutableSet.copyOf( - loadByForeignKeysCached(fullyQualifiedHostNames, HostResource.class, now).values()); + loadByForeignKeysCached(fullyQualifiedHostNames, Host.class, now).values()); } private static Set linkContacts( diff --git a/core/src/main/java/google/registry/model/domain/DomainHistory.java b/core/src/main/java/google/registry/model/domain/DomainHistory.java index b985197a0..f271149dc 100644 --- a/core/src/main/java/google/registry/model/domain/DomainHistory.java +++ b/core/src/main/java/google/registry/model/domain/DomainHistory.java @@ -26,7 +26,7 @@ import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.GracePeriod.GracePeriodHistory; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.domain.secdns.DomainDsDataHistory; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.HistoryEntry; import google.registry.persistence.VKey; @@ -113,7 +113,7 @@ public class DomainHistory extends HistoryEntry { }) @ImmutableObject.EmptySetToNull @Column(name = "host_repo_id") - Set> nsHosts; + Set> nsHosts; @DoNotCompare @OneToMany( @@ -221,8 +221,8 @@ public class DomainHistory extends HistoryEntry { return new DomainHistoryId(getDomainRepoId(), getId()); } - /** Returns keys to the {@link HostResource} that are the nameservers for the domain. */ - public Set> getNsHosts() { + /** Returns keys to the {@link Host} that are the nameservers for the domain. */ + public Set> getNsHosts() { return nsHosts; } @@ -406,7 +406,7 @@ public class DomainHistory extends HistoryEntry { public DomainHistory buildAndAssemble( ImmutableSet dsDataHistories, - ImmutableSet> domainHistoryHosts, + ImmutableSet> domainHistoryHosts, ImmutableSet gracePeriodHistories, ImmutableSet transactionRecords) { DomainHistory instance = super.build(); diff --git a/core/src/main/java/google/registry/model/eppcommon/StatusValue.java b/core/src/main/java/google/registry/model/eppcommon/StatusValue.java index 480f0e754..9bee17d82 100644 --- a/core/src/main/java/google/registry/model/eppcommon/StatusValue.java +++ b/core/src/main/java/google/registry/model/eppcommon/StatusValue.java @@ -24,8 +24,8 @@ import google.registry.model.contact.ContactBase; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainBase; +import google.registry.model.host.Host; import google.registry.model.host.HostBase; -import google.registry.model.host.HostResource; import google.registry.model.translators.EnumToAttributeAdapter.EppEnum; import google.registry.model.translators.StatusValueAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -135,7 +135,7 @@ public enum StatusValue implements EppEnum { DomainBase.class, Domain.class, HostBase.class, - HostResource.class), + Host.class), NONE, DOMAINS(DomainBase.class, Domain.class); diff --git a/core/src/main/java/google/registry/model/host/HostResource.java b/core/src/main/java/google/registry/model/host/Host.java similarity index 88% rename from core/src/main/java/google/registry/model/host/HostResource.java rename to core/src/main/java/google/registry/model/host/Host.java index 7436d8086..414571212 100644 --- a/core/src/main/java/google/registry/model/host/HostResource.java +++ b/core/src/main/java/google/registry/model/host/Host.java @@ -27,7 +27,7 @@ import javax.persistence.AccessType; /** * A persistable Host resource including mutable and non-mutable fields. * - *

The {@link javax.persistence.Id} of the HostResource is the repoId. + *

The {@link javax.persistence.Id} of the Host is the repoId. */ @ReportedOn @Entity @@ -54,7 +54,7 @@ import javax.persistence.AccessType; @ExternalMessagingName("host") @WithStringVKey @Access(AccessType.FIELD) // otherwise it'll use the default if the repoId (property) -public class HostResource extends HostBase implements ForeignKeyedEppResource { +public class Host extends HostBase implements ForeignKeyedEppResource { @Override @javax.persistence.Id @@ -64,8 +64,8 @@ public class HostResource extends HostBase implements ForeignKeyedEppResource { } @Override - public VKey createVKey() { - return VKey.create(HostResource.class, getRepoId(), Key.create(this)); + public VKey createVKey() { + return VKey.create(Host.class, getRepoId(), Key.create(this)); } @Override @@ -73,11 +73,11 @@ public class HostResource extends HostBase implements ForeignKeyedEppResource { return new Builder(clone(this)); } - /** A builder for constructing {@link HostResource}, since it is immutable. */ - public static class Builder extends HostBase.Builder { + /** A builder for constructing {@link Host}, since it is immutable. */ + public static class Builder extends HostBase.Builder { public Builder() {} - private Builder(HostResource instance) { + private Builder(Host instance) { super(instance); } diff --git a/core/src/main/java/google/registry/model/host/HostBase.java b/core/src/main/java/google/registry/model/host/HostBase.java index f2ba52c7b..868d23131 100644 --- a/core/src/main/java/google/registry/model/host/HostBase.java +++ b/core/src/main/java/google/registry/model/host/HostBase.java @@ -126,8 +126,7 @@ public class HostBase extends EppResource { @Override public VKey createVKey() { throw new UnsupportedOperationException( - "HostBase is not an actual persisted entity you can create a key to;" - + " use HostResource instead"); + "HostBase is not an actual persisted entity you can create a key to; use Host instead"); } @Deprecated diff --git a/core/src/main/java/google/registry/model/host/HostCommand.java b/core/src/main/java/google/registry/model/host/HostCommand.java index a417c4b71..7d584572f 100644 --- a/core/src/main/java/google/registry/model/host/HostCommand.java +++ b/core/src/main/java/google/registry/model/host/HostCommand.java @@ -29,26 +29,26 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlType; -/** A collection of {@link HostResource} commands. */ +/** A collection of {@link Host} commands. */ public class HostCommand { /** The fields on "chgType" from RFC5732. */ @XmlTransient abstract static class HostCreateOrChange extends AbstractSingleResourceCommand - implements ResourceCreateOrChange { + implements ResourceCreateOrChange { public String getFullyQualifiedHostName() { return getTargetId(); } } /** - * A create command for a {@link HostResource}, mapping "createType" from RFC5732. */ @XmlType(propOrder = {"targetId", "inetAddresses"}) @XmlRootElement public static class Create extends HostCreateOrChange - implements ResourceCreateOrChange { + implements ResourceCreateOrChange { /** IP Addresses for this host. Can be null if this is an external host. */ @XmlElement(name = "addr") Set inetAddresses; @@ -58,23 +58,22 @@ public class HostCommand { } } - /** A delete command for a {@link HostResource}. */ + /** A delete command for a {@link Host}. */ @XmlRootElement public static class Delete extends AbstractSingleResourceCommand {} - /** An info request for a {@link HostResource}. */ + /** An info request for a {@link Host}. */ @XmlRootElement public static class Info extends AbstractSingleResourceCommand {} - /** A check request for {@link HostResource}. */ + /** A check request for {@link Host}. */ @XmlRootElement public static class Check extends ResourceCheck {} - /** An update to a {@link HostResource}. */ + /** An update to a {@link Host}. */ @XmlRootElement @XmlType(propOrder = {"targetId", "innerAdd", "innerRemove", "innerChange"}) - public static class Update extends ResourceUpdate - { + public static class Update extends ResourceUpdate { @XmlElement(name = "chg") protected Change innerChange; diff --git a/core/src/main/java/google/registry/model/host/HostHistory.java b/core/src/main/java/google/registry/model/host/HostHistory.java index ee0f61e56..29d9ee69f 100644 --- a/core/src/main/java/google/registry/model/host/HostHistory.java +++ b/core/src/main/java/google/registry/model/host/HostHistory.java @@ -59,7 +59,7 @@ import javax.persistence.PostLoad; @IdClass(HostHistoryId.class) public class HostHistory extends HistoryEntry implements UnsafeSerializable { - // Store HostBase instead of HostResource so we don't pick up its @Id + // Store HostBase instead of Host so we don't pick up its @Id // Nullable for the sake of pre-Registry-3.0 history objects @DoNotCompare @Nullable HostBase hostBase; @@ -74,7 +74,7 @@ public class HostHistory extends HistoryEntry implements UnsafeSerializable { /** This method is private because it is only used by Hibernate. */ @SuppressWarnings("unused") private void setHostRepoId(String hostRepoId) { - parent = Key.create(HostResource.class, hostRepoId); + parent = Key.create(Host.class, hostRepoId); } @Id @@ -99,9 +99,9 @@ public class HostHistory extends HistoryEntry implements UnsafeSerializable { return Optional.ofNullable(hostBase); } - /** The key to the {@link google.registry.model.host.HostResource} this is based off of. */ - public VKey getParentVKey() { - return VKey.create(HostResource.class, getHostRepoId()); + /** The key to the {@link Host} this is based off of. */ + public VKey getParentVKey() { + return VKey.create(Host.class, getHostRepoId()); } /** Creates a {@link VKey} instance for this entity. */ @@ -113,7 +113,7 @@ public class HostHistory extends HistoryEntry implements UnsafeSerializable { @Override public Optional getResourceAtPointInTime() { - return getHostBase().map(hostBase -> new HostResource.Builder().copyFrom(hostBase).build()); + return getHostBase().map(hostBase -> new Host.Builder().copyFrom(hostBase).build()); } @PostLoad @@ -210,7 +210,7 @@ public class HostHistory extends HistoryEntry implements UnsafeSerializable { } public Builder setHostRepoId(String hostRepoId) { - getInstance().parent = Key.create(HostResource.class, hostRepoId); + getInstance().parent = Key.create(Host.class, hostRepoId); return this; } } diff --git a/core/src/main/java/google/registry/model/index/ForeignKeyIndex.java b/core/src/main/java/google/registry/model/index/ForeignKeyIndex.java index 208db9a5b..c4d22de55 100644 --- a/core/src/main/java/google/registry/model/index/ForeignKeyIndex.java +++ b/core/src/main/java/google/registry/model/index/ForeignKeyIndex.java @@ -49,7 +49,7 @@ import google.registry.model.annotations.DeleteAfterMigration; import google.registry.model.annotations.ReportedOn; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.persistence.transaction.JpaTransactionManager; @@ -80,10 +80,10 @@ public abstract class ForeignKeyIndex extends BackupGroup @Entity public static class ForeignKeyDomainIndex extends ForeignKeyIndex {} - /** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */ + /** The {@link ForeignKeyIndex} type for {@link Host} entities. */ @ReportedOn @Entity - public static class ForeignKeyHostIndex extends ForeignKeyIndex {} + public static class ForeignKeyHostIndex extends ForeignKeyIndex {} private static final ImmutableBiMap< Class, Class>> @@ -91,14 +91,14 @@ public abstract class ForeignKeyIndex extends BackupGroup ImmutableBiMap.of( ContactResource.class, ForeignKeyContactIndex.class, Domain.class, ForeignKeyDomainIndex.class, - HostResource.class, ForeignKeyHostIndex.class); + Host.class, ForeignKeyHostIndex.class); private static final ImmutableMap, String> RESOURCE_CLASS_TO_FKI_PROPERTY = ImmutableMap.of( ContactResource.class, "contactId", Domain.class, "fullyQualifiedDomainName", - HostResource.class, "fullyQualifiedHostName"); + Host.class, "fullyQualifiedHostName"); @Id String foreignKey; @@ -106,7 +106,7 @@ public abstract class ForeignKeyIndex extends BackupGroup * The deletion time of this {@link ForeignKeyIndex}. * *

This will generally be equal to the deletion time of {@link #topReference}. However, in the - * case of a {@link HostResource} that was renamed, this field will hold the time of the rename. + * case of a {@link Host} that was renamed, this field will hold the time of the rename. */ @Index DateTime deletionTime; diff --git a/core/src/main/java/google/registry/model/package-info.java b/core/src/main/java/google/registry/model/package-info.java index 597ef539e..f32058170 100644 --- a/core/src/main/java/google/registry/model/package-info.java +++ b/core/src/main/java/google/registry/model/package-info.java @@ -33,7 +33,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; * via Objectify. * *

All first class entities are represented as a resource class - {@link - * google.registry.model.domain.Domain}, {@link google.registry.model.host.HostResource}, {@link + * google.registry.model.domain.Domain}, {@link google.registry.model.host.Host}, {@link * google.registry.model.contact.ContactResource}, and {@link * google.registry.model.registrar.Registrar}. Resource objects are written in a single shared * entity group per TLD. All commands that operate on those entities are grouped in a "Command" diff --git a/core/src/main/java/google/registry/model/poll/PollMessage.java b/core/src/main/java/google/registry/model/poll/PollMessage.java index 44922d3ae..7a00c4e0e 100644 --- a/core/src/main/java/google/registry/model/poll/PollMessage.java +++ b/core/src/main/java/google/registry/model/poll/PollMessage.java @@ -40,9 +40,9 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.DomainRenewData; import google.registry.model.eppoutput.EppResponse.ResponseData; +import google.registry.model.host.Host; import google.registry.model.host.HostHistory; import google.registry.model.host.HostHistory.HostHistoryId; -import google.registry.model.host.HostResource; import google.registry.model.poll.PendingActionNotificationResponse.ContactPendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PendingActionNotificationResponse.HostPendingActionNotificationResponse; @@ -105,7 +105,7 @@ public abstract class PollMessage extends ImmutableObject public enum Type { DOMAIN(1L, Domain.class), CONTACT(2L, ContactResource.class), - HOST(3L, HostResource.class); + HOST(3L, Host.class); private final long id; private final Class clazz; @@ -216,7 +216,7 @@ public abstract class PollMessage extends ImmutableObject /** * Returns the host repo id. * - *

This may only be used on a HostResource poll event. + *

This may only be used on a Host poll event. */ public String getHostRepoId() { checkArgument(getType() == Type.DOMAIN); diff --git a/core/src/main/java/google/registry/model/reporting/HistoryEntry.java b/core/src/main/java/google/registry/model/reporting/HistoryEntry.java index e2d7b089e..cc2414747 100644 --- a/core/src/main/java/google/registry/model/reporting/HistoryEntry.java +++ b/core/src/main/java/google/registry/model/reporting/HistoryEntry.java @@ -44,10 +44,10 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.DomainHistory.DomainHistoryId; import google.registry.model.domain.Period; import google.registry.model.eppcommon.Trid; +import google.registry.model.host.Host; import google.registry.model.host.HostBase; import google.registry.model.host.HostHistory; import google.registry.model.host.HostHistory.HostHistoryId; -import google.registry.model.host.HostResource; import google.registry.persistence.VKey; import java.util.Optional; import java.util.Set; @@ -389,7 +389,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe if (parentKind.equals(getKind(Domain.class))) { resultEntity = new DomainHistory.Builder().copyFrom(this).setDomainRepoId(parent.getName()).build(); - } else if (parentKind.equals(getKind(HostResource.class))) { + } else if (parentKind.equals(getKind(Host.class))) { resultEntity = new HostHistory.Builder().copyFrom(this).setHostRepoId(parent.getName()).build(); } else if (parentKind.equals(getKind(ContactResource.class))) { @@ -413,7 +413,7 @@ public class HistoryEntry extends ImmutableObject implements Buildable, UnsafeSe DomainHistory.class, new DomainHistoryId(repoId, id), Key.create(parent, DomainHistory.class, id)); - } else if (parentKind.equals(getKind(HostResource.class))) { + } else if (parentKind.equals(getKind(Host.class))) { return VKey.create( HostHistory.class, new HostHistoryId(repoId, id), diff --git a/core/src/main/java/google/registry/model/reporting/HistoryEntryDao.java b/core/src/main/java/google/registry/model/reporting/HistoryEntryDao.java index dc80f21ac..4ee9ee9a3 100644 --- a/core/src/main/java/google/registry/model/reporting/HistoryEntryDao.java +++ b/core/src/main/java/google/registry/model/reporting/HistoryEntryDao.java @@ -29,8 +29,8 @@ import google.registry.model.contact.ContactHistory; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; +import google.registry.model.host.Host; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.persistence.VKey; import google.registry.persistence.transaction.CriteriaQueryBuilder; import java.util.Comparator; @@ -55,7 +55,7 @@ public class HistoryEntryDao { ContactHistory.class, Domain.class, DomainHistory.class, - HostResource.class, + Host.class, HostHistory.class); public static ImmutableMap, String> REPO_ID_FIELD_NAMES = diff --git a/core/src/main/java/google/registry/rdap/RdapDomainSearchAction.java b/core/src/main/java/google/registry/rdap/RdapDomainSearchAction.java index a199b9039..dfafb9901 100644 --- a/core/src/main/java/google/registry/rdap/RdapDomainSearchAction.java +++ b/core/src/main/java/google/registry/rdap/RdapDomainSearchAction.java @@ -37,7 +37,7 @@ import com.google.common.net.InetAddresses; import com.google.common.primitives.Booleans; import com.googlecode.objectify.cmd.Query; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.rdap.RdapJsonFormatter.OutputDataType; @@ -301,8 +301,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { */ private DomainSearchResponse searchByNameserverLdhName( final RdapSearchPattern partialStringQuery) { - ImmutableCollection> hostKeys = - getNameserverRefsByLdhName(partialStringQuery); + ImmutableCollection> hostKeys = getNameserverRefsByLdhName(partialStringQuery); if (Iterables.isEmpty(hostKeys)) { metricInformationBuilder.setNumHostsRetrieved(0); throw new NotFoundException("No matching nameservers found"); @@ -311,7 +310,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { } /** - * Assembles a list of {@link HostResource} keys by name. + * Assembles a list of {@link Host} keys by name. * *

Nameserver query strings with wildcards are allowed to have a suffix after the wildcard, * which must be a domain. If the domain is not specified, or is not an existing domain in one of @@ -320,7 +319,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { * initial string is not required (e.g. "*.example.tld" is valid), because we can look up the * domain and just list all of its subordinate hosts. */ - private ImmutableCollection> getNameserverRefsByLdhName( + private ImmutableCollection> getNameserverRefsByLdhName( final RdapSearchPattern partialStringQuery) { // Handle queries without a wildcard. if (!partialStringQuery.getHasWildcard()) { @@ -341,9 +340,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { // limit in order to avoid arbitrarily long-running queries. Optional desiredRegistrar = getDesiredRegistrar(); if (tm().isOfy()) { - Query query = + Query query = queryItems( - HostResource.class, + Host.class, "fullyQualifiedHostName", partialStringQuery, Optional.empty(), @@ -359,9 +358,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { return replicaJpaTm() .transact( () -> { - CriteriaQueryBuilder builder = + CriteriaQueryBuilder builder = queryItemsSql( - HostResource.class, + Host.class, "fullyQualifiedHostName", partialStringQuery, Optional.empty(), @@ -376,22 +375,22 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { return getMatchingResourcesSql(builder, true, maxNameserversInFirstStage) .resources() .stream() - .map(HostResource::createVKey) + .map(Host::createVKey) .collect(toImmutableSet()); }); } } - /** Assembles a list of {@link HostResource} keys by name when the pattern has no wildcard. */ - private ImmutableList> getNameserverRefsByLdhNameWithoutWildcard( + /** Assembles a list of {@link Host} keys by name when the pattern has no wildcard. */ + private ImmutableList> getNameserverRefsByLdhNameWithoutWildcard( final RdapSearchPattern partialStringQuery) { // If we need to check the sponsoring registrar, we need to load the resource rather than just // the key. Optional desiredRegistrar = getDesiredRegistrar(); if (desiredRegistrar.isPresent()) { - Optional host = + Optional host = loadByForeignKey( - HostResource.class, + Host.class, partialStringQuery.getInitialString(), shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); return (!host.isPresent() @@ -399,17 +398,17 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { ? ImmutableList.of() : ImmutableList.of(host.get().createVKey()); } else { - VKey hostKey = + VKey hostKey = loadAndGetKey( - HostResource.class, + Host.class, partialStringQuery.getInitialString(), shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); return (hostKey == null) ? ImmutableList.of() : ImmutableList.of(hostKey); } } - /** Assembles a list of {@link HostResource} keys by name using a superordinate domain suffix. */ - private ImmutableList> getNameserverRefsByLdhNameWithSuffix( + /** Assembles a list of {@link Host} keys by name using a superordinate domain suffix. */ + private ImmutableList> getNameserverRefsByLdhNameWithSuffix( final RdapSearchPattern partialStringQuery) { // The suffix must be a domain that we manage. That way, we can look up the domain and search // through the subordinate hosts. This is more efficient, and lets us permit wildcard searches @@ -425,17 +424,15 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { "A suffix in a lookup by nameserver name " + "must be a domain defined in the system")); Optional desiredRegistrar = getDesiredRegistrar(); - ImmutableList.Builder> builder = new ImmutableList.Builder<>(); + ImmutableList.Builder> builder = new ImmutableList.Builder<>(); for (String fqhn : ImmutableSortedSet.copyOf(domain.getSubordinateHosts())) { // We can't just check that the host name starts with the initial query string, because // then the query ns.exam*.example.com would match against nameserver ns.example.com. if (partialStringQuery.matches(fqhn)) { if (desiredRegistrar.isPresent()) { - Optional host = + Optional host = loadByForeignKey( - HostResource.class, - fqhn, - shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); + Host.class, fqhn, shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); if (host.isPresent() && desiredRegistrar .get() @@ -443,11 +440,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { builder.add(host.get().createVKey()); } } else { - VKey hostKey = + VKey hostKey = loadAndGetKey( - HostResource.class, - fqhn, - shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); + Host.class, fqhn, shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); if (hostKey != null) { builder.add(hostKey); } else { @@ -477,11 +472,11 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { */ private DomainSearchResponse searchByNameserverIp(final InetAddress inetAddress) { Optional desiredRegistrar = getDesiredRegistrar(); - ImmutableSet> hostKeys; + ImmutableSet> hostKeys; if (tm().isOfy()) { - Query query = + Query query = queryItems( - HostResource.class, + Host.class, "inetAddresses", inetAddress.getHostAddress(), Optional.empty(), @@ -524,7 +519,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { @SuppressWarnings("unchecked") Stream resultStream = query.getResultStream(); return resultStream - .map(repoId -> VKey.create(HostResource.class, repoId)) + .map(repoId -> VKey.create(Host.class, repoId)) .collect(toImmutableSet()); }); } @@ -538,7 +533,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { * #searchByNameserverIp} after they assemble the relevant host keys. */ private DomainSearchResponse searchByNameserverRefs( - final ImmutableCollection> hostKeys) { + final ImmutableCollection> hostKeys) { // We must break the query up into chunks, because the in operator is limited to 30 subqueries. // Since it is possible for the same domain to show up more than once in our result list (if // we do a wildcard nameserver search that returns multiple nameservers used by the same @@ -548,7 +543,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { ImmutableSortedSet.Builder domainSetBuilder = ImmutableSortedSet.orderedBy(Comparator.comparing(Domain::getDomainName)); int numHostKeysSearched = 0; - for (List> chunk : Iterables.partition(hostKeys, 30)) { + for (List> chunk : Iterables.partition(hostKeys, 30)) { numHostKeysSearched += chunk.size(); if (tm().isOfy()) { Query query = @@ -574,7 +569,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase { replicaJpaTm() .transact( () -> { - for (VKey hostKey : hostKeys) { + for (VKey hostKey : hostKeys) { CriteriaQueryBuilder queryBuilder = CriteriaQueryBuilder.create(replicaJpaTm(), Domain.class) .whereFieldContains("nsHosts", hostKey) diff --git a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java index 5ae6acac3..4408585e6 100644 --- a/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java +++ b/core/src/main/java/google/registry/rdap/RdapJsonFormatter.java @@ -48,7 +48,7 @@ import google.registry.model.domain.DesignatedContact.Type; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.Address; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registrar.RegistrarPoc; @@ -235,8 +235,8 @@ public class RdapJsonFormatter { ImmutableMap.of("type", ImmutableList.of("fax")); /** Sets the ordering for hosts; just use the fully qualified host name. */ - private static final Ordering HOST_RESOURCE_ORDERING = - Ordering.natural().onResultOf(HostResource::getHostName); + private static final Ordering HOST_RESOURCE_ORDERING = + Ordering.natural().onResultOf(Host::getHostName); /** Sets the ordering for designated contacts; order them in a fixed order by contact type. */ private static final Ordering DESIGNATED_CONTACT_ORDERING = @@ -356,7 +356,7 @@ public class RdapJsonFormatter { // Kick off the database loads of the nameservers that we will need, so it can load // asynchronously while we load and process the contacts. - ImmutableSet loadedHosts = + ImmutableSet loadedHosts = tm().transact(() -> ImmutableSet.copyOf(tm().loadByKeys(domain.getNameservers()).values())); // Load the registrant and other contacts and add them to the data. ImmutableMap, ContactResource> loadedContacts = @@ -393,8 +393,8 @@ public class RdapJsonFormatter { } // Add the nameservers to the data; the load was kicked off above for efficiency. // RDAP Response Profile 2.9: we MUST have the nameservers - for (HostResource hostResource : HOST_RESOURCE_ORDERING.immutableSortedCopy(loadedHosts)) { - builder.nameserversBuilder().add(createRdapNameserver(hostResource, OutputDataType.INTERNAL)); + for (Host host : HOST_RESOURCE_ORDERING.immutableSortedCopy(loadedHosts)) { + builder.nameserversBuilder().add(createRdapNameserver(host, OutputDataType.INTERNAL)); } // RDAP Response Profile 2.10 - MUST contain a secureDns member including at least a @@ -410,23 +410,23 @@ public class RdapJsonFormatter { } /** - * Creates a JSON object for a {@link HostResource}. + * Creates a JSON object for a {@link Host}. * - * @param hostResource the host resource object from which the JSON object should be created + * @param host the host resource object from which the JSON object should be created * @param outputDataType whether to generate full or summary data */ - RdapNameserver createRdapNameserver(HostResource hostResource, OutputDataType outputDataType) { + RdapNameserver createRdapNameserver(Host host, OutputDataType outputDataType) { RdapNameserver.Builder builder = RdapNameserver.builder(); - builder.linksBuilder().add(makeSelfLink("nameserver", hostResource.getHostName())); + builder.linksBuilder().add(makeSelfLink("nameserver", host.getHostName())); if (outputDataType != OutputDataType.FULL) { builder.remarksBuilder().add(RdapIcannStandardInformation.SUMMARY_DATA_REMARK); } // We need the ldhName: RDAP Response Profile 2.9.1, 4.1 - builder.setLdhName(hostResource.getHostName()); + builder.setLdhName(host.getHostName()); // Handle is optional, but if given it MUST be the ROID. // We will set it always as it's important as a "self link" - builder.setHandle(hostResource.getRepoId()); + builder.setHandle(host.getRepoId()); // Status is optional for internal Nameservers - RDAP Response Profile 2.9.2 // It isn't mentioned at all anywhere else. So we can just not put it at all? @@ -434,14 +434,14 @@ public class RdapJsonFormatter { // To be safe, we'll put it on the "FULL" version anyway if (outputDataType == OutputDataType.FULL) { ImmutableSet.Builder statuses = new ImmutableSet.Builder<>(); - statuses.addAll(hostResource.getStatusValues()); - if (isLinked(hostResource.createVKey(), getRequestTime())) { + statuses.addAll(host.getStatusValues()); + if (isLinked(host.createVKey(), getRequestTime())) { statuses.add(StatusValue.LINKED); } - if (hostResource.isSubordinate() + if (host.isSubordinate() && tm().transact( () -> - tm().loadByKey(hostResource.getSuperordinateDomain()) + tm().loadByKey(host.getSuperordinateDomain()) .cloneProjectedAtTime(getRequestTime()) .getStatusValues() .contains(StatusValue.PENDING_TRANSFER))) { @@ -453,14 +453,14 @@ public class RdapJsonFormatter { makeStatusValueList( statuses.build(), false, // isRedacted - hostResource.getDeletionTime().isBefore(getRequestTime()))); + host.getDeletionTime().isBefore(getRequestTime()))); } // For query responses - we MUST have all the ip addresses: RDAP Response Profile 4.2. // // However, it is optional for internal responses: RDAP Response Profile 2.9.2 if (outputDataType != OutputDataType.INTERNAL) { - for (InetAddress inetAddress : hostResource.getInetAddresses()) { + for (InetAddress inetAddress : host.getInetAddresses()) { if (inetAddress instanceof Inet4Address) { builder.ipv4Builder().add(InetAddresses.toAddrString(inetAddress)); } else if (inetAddress instanceof Inet6Address) { @@ -472,8 +472,7 @@ public class RdapJsonFormatter { // RDAP Response Profile 4.3 - Registrar member is optional, so we only set it for FULL if (outputDataType == OutputDataType.FULL) { Registrar registrar = - Registrar.loadRequiredRegistrarCached( - hostResource.getPersistedCurrentSponsorRegistrarId()); + Registrar.loadRequiredRegistrarCached(host.getPersistedCurrentSponsorRegistrarId()); builder.entitiesBuilder().add(createRdapRegistrarEntity(registrar, OutputDataType.INTERNAL)); } if (outputDataType != OutputDataType.INTERNAL) { diff --git a/core/src/main/java/google/registry/rdap/RdapNameserverAction.java b/core/src/main/java/google/registry/rdap/RdapNameserverAction.java index d7da3ba63..445fccd1b 100644 --- a/core/src/main/java/google/registry/rdap/RdapNameserverAction.java +++ b/core/src/main/java/google/registry/rdap/RdapNameserverAction.java @@ -21,7 +21,7 @@ import static google.registry.request.Action.Method.HEAD; import static google.registry.util.DateTimeUtils.START_OF_TIME; import google.registry.flows.EppException; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapObjectClasses.RdapNameserver; @@ -61,12 +61,12 @@ public class RdapNameserverAction extends RdapActionBase { } // If there are no undeleted nameservers with the given name, the foreign key should point to // the most recently deleted one. - Optional hostResource = + Optional host = loadByForeignKey( - HostResource.class, + Host.class, pathSearchString, shouldIncludeDeleted() ? START_OF_TIME : getRequestTime()); - if (!hostResource.isPresent() || !isAuthorized(hostResource.get())) { + if (!host.isPresent() || !isAuthorized(host.get())) { // RFC7480 5.3 - if the server wishes to respond that it doesn't have data satisfying the // query, it MUST reply with 404 response code. // @@ -74,6 +74,6 @@ public class RdapNameserverAction extends RdapActionBase { // exists but we don't want to show it to you", because we DON'T wish to say that. throw new NotFoundException(pathSearchString + " not found"); } - return rdapJsonFormatter.createRdapNameserver(hostResource.get(), OutputDataType.FULL); + return rdapJsonFormatter.createRdapNameserver(host.get(), OutputDataType.FULL); } } diff --git a/core/src/main/java/google/registry/rdap/RdapNameserverSearchAction.java b/core/src/main/java/google/registry/rdap/RdapNameserverSearchAction.java index 9a0bc8588..f7bdc1c76 100644 --- a/core/src/main/java/google/registry/rdap/RdapNameserverSearchAction.java +++ b/core/src/main/java/google/registry/rdap/RdapNameserverSearchAction.java @@ -28,7 +28,7 @@ import com.google.common.net.InetAddresses; import com.google.common.primitives.Booleans; import com.googlecode.objectify.cmd.Query; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.transaction.CriteriaQueryBuilder; import google.registry.rdap.RdapJsonFormatter.OutputDataType; import google.registry.rdap.RdapMetrics.EndpointType; @@ -159,16 +159,15 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { NameserverSearchResponse.builder() .setIncompletenessWarningType(IncompletenessWarningType.COMPLETE); - Optional hostResource = - loadByForeignKey( - HostResource.class, partialStringQuery.getInitialString(), getRequestTime()); + Optional host = + loadByForeignKey(Host.class, partialStringQuery.getInitialString(), getRequestTime()); - metricInformationBuilder.setNumHostsRetrieved(hostResource.isPresent() ? 1 : 0); + metricInformationBuilder.setNumHostsRetrieved(host.isPresent() ? 1 : 0); - if (shouldBeVisible(hostResource)) { + if (shouldBeVisible(host)) { builder .nameserverSearchResultsBuilder() - .add(rdapJsonFormatter.createRdapNameserver(hostResource.get(), OutputDataType.FULL)); + .add(rdapJsonFormatter.createRdapNameserver(host.get(), OutputDataType.FULL)); } return builder.build(); } @@ -187,7 +186,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { throw new UnprocessableEntityException( "A suffix after a wildcard in a nameserver lookup must be an in-bailiwick domain"); } - List hostList = new ArrayList<>(); + List hostList = new ArrayList<>(); for (String fqhn : ImmutableSortedSet.copyOf(domain.get().getSubordinateHosts())) { if (cursorString.isPresent() && (fqhn.compareTo(cursorString.get()) <= 0)) { continue; @@ -195,10 +194,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { // We can't just check that the host name starts with the initial query string, because // then the query ns.exam*.example.com would match against nameserver ns.example.com. if (partialStringQuery.matches(fqhn)) { - Optional hostResource = - loadByForeignKey(HostResource.class, fqhn, getRequestTime()); - if (shouldBeVisible(hostResource)) { - hostList.add(hostResource.get()); + Optional host = loadByForeignKey(Host.class, fqhn, getRequestTime()); + if (shouldBeVisible(host)) { + hostList.add(host.get()); if (hostList.size() > rdapResultSetMaxSize) { break; } @@ -222,9 +220,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { // Add 1 so we can detect truncation. int querySizeLimit = getStandardQuerySizeLimit(); if (tm().isOfy()) { - Query query = + Query query = queryItems( - HostResource.class, + Host.class, "fullyQualifiedHostName", partialStringQuery, cursorString, @@ -236,9 +234,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { return replicaJpaTm() .transact( () -> { - CriteriaQueryBuilder queryBuilder = + CriteriaQueryBuilder queryBuilder = queryItemsSql( - HostResource.class, + Host.class, "fullyQualifiedHostName", partialStringQuery, cursorString, @@ -254,11 +252,11 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { private NameserverSearchResponse searchByIp(InetAddress inetAddress) { // Add 1 so we can detect truncation. int querySizeLimit = getStandardQuerySizeLimit(); - RdapResultSet rdapResultSet; + RdapResultSet rdapResultSet; if (tm().isOfy()) { - Query query = + Query query = queryItems( - HostResource.class, + Host.class, "inetAddresses", inetAddress.getHostAddress(), Optional.empty(), @@ -296,11 +294,11 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { javax.persistence.Query query = replicaJpaTm() .getEntityManager() - .createNativeQuery(queryBuilder.toString(), HostResource.class) + .createNativeQuery(queryBuilder.toString(), Host.class) .setMaxResults(querySizeLimit); parameters.build().forEach(query::setParameter); @SuppressWarnings("unchecked") - List resultList = query.getResultList(); + List resultList = query.getResultList(); return filterResourcesByVisibility(resultList, querySizeLimit); }); } @@ -309,7 +307,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { /** Output JSON for a lists of hosts contained in an {@link RdapResultSet}. */ private NameserverSearchResponse makeSearchResults( - RdapResultSet resultSet, CursorType cursorType) { + RdapResultSet resultSet, CursorType cursorType) { return makeSearchResults( resultSet.resources(), resultSet.incompletenessWarningType(), @@ -319,7 +317,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { /** Output JSON for a list of hosts. */ private NameserverSearchResponse makeSearchResults( - List hosts, + List hosts, IncompletenessWarningType incompletenessWarningType, int numHostsRetrieved, CursorType cursorType) { @@ -329,7 +327,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase { NameserverSearchResponse.Builder builder = NameserverSearchResponse.builder().setIncompletenessWarningType(incompletenessWarningType); Optional newCursor = Optional.empty(); - for (HostResource host : Iterables.limit(hosts, rdapResultSetMaxSize)) { + for (Host host : Iterables.limit(hosts, rdapResultSetMaxSize)) { newCursor = Optional.of((cursorType == CursorType.NAME) ? host.getHostName() : host.getRepoId()); builder diff --git a/core/src/main/java/google/registry/rde/HostResourceToXjcConverter.java b/core/src/main/java/google/registry/rde/HostToXjcConverter.java similarity index 80% rename from core/src/main/java/google/registry/rde/HostResourceToXjcConverter.java rename to core/src/main/java/google/registry/rde/HostToXjcConverter.java index 4d6aaa419..3f75703ee 100644 --- a/core/src/main/java/google/registry/rde/HostResourceToXjcConverter.java +++ b/core/src/main/java/google/registry/rde/HostToXjcConverter.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument; import com.google.common.net.InetAddresses; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.xjc.host.XjcHostAddrType; import google.registry.xjc.host.XjcHostIpType; import google.registry.xjc.host.XjcHostStatusType; @@ -30,23 +30,23 @@ import java.net.Inet6Address; import java.net.InetAddress; import org.joda.time.DateTime; -/** Utility class that turns {@link HostResource} as {@link XjcRdeHostElement}. */ -final class HostResourceToXjcConverter { +/** Utility class that turns a {@link Host} resource into {@link XjcRdeHostElement}. */ +final class HostToXjcConverter { - /** Converts a subordinate {@link HostResource} to {@link XjcRdeHostElement}. */ - static XjcRdeHostElement convertSubordinate(HostResource host, Domain superordinateDomain) { + /** Converts a subordinate {@link Host} to {@link XjcRdeHostElement}. */ + static XjcRdeHostElement convertSubordinate(Host host, Domain superordinateDomain) { checkArgument(superordinateDomain.createVKey().equals(host.getSuperordinateDomain())); return new XjcRdeHostElement(convertSubordinateHost(host, superordinateDomain)); } - /** Converts an external {@link HostResource} to {@link XjcRdeHostElement}. */ - static XjcRdeHostElement convertExternal(HostResource host) { + /** Converts an external {@link Host} to {@link XjcRdeHostElement}. */ + static XjcRdeHostElement convertExternal(Host host) { checkArgument(!host.isSubordinate()); return new XjcRdeHostElement(convertExternalHost(host)); } - /** Converts {@link HostResource} to {@link XjcRdeHost}. */ - static XjcRdeHost convertSubordinateHost(HostResource model, Domain superordinateDomain) { + /** Converts {@link Host} to {@link XjcRdeHost}. */ + static XjcRdeHost convertSubordinateHost(Host model, Domain superordinateDomain) { XjcRdeHost bean = convertHostCommon( model, @@ -58,14 +58,14 @@ final class HostResourceToXjcConverter { return bean; } - /** Converts {@link HostResource} to {@link XjcRdeHost}. */ - static XjcRdeHost convertExternalHost(HostResource model) { + /** Converts {@link Host} to {@link XjcRdeHost}. */ + static XjcRdeHost convertExternalHost(Host model) { return convertHostCommon( model, model.getPersistedCurrentSponsorRegistrarId(), model.getLastTransferTime()); } private static XjcRdeHost convertHostCommon( - HostResource model, String registrarId, DateTime lastTransferTime) { + Host model, String registrarId, DateTime lastTransferTime) { XjcRdeHost bean = new XjcRdeHost(); bean.setName(model.getHostName()); bean.setRoid(model.getRepoId()); @@ -105,5 +105,5 @@ final class HostResourceToXjcConverter { return bean; } - private HostResourceToXjcConverter() {} + private HostToXjcConverter() {} } diff --git a/core/src/main/java/google/registry/rde/RdeFragmenter.java b/core/src/main/java/google/registry/rde/RdeFragmenter.java index dfae9927f..b49c2c7e1 100644 --- a/core/src/main/java/google/registry/rde/RdeFragmenter.java +++ b/core/src/main/java/google/registry/rde/RdeFragmenter.java @@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableMap; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.rde.RdeMode; import java.util.HashMap; import java.util.Map; @@ -71,8 +71,8 @@ public class RdeFragmenter { cache.put(WatermarkModePair.create(watermark, RdeMode.FULL), result); cache.put(WatermarkModePair.create(watermark, RdeMode.THIN), result); return result; - } else if (resource instanceof HostResource) { - HostResource host = (HostResource) resource; + } else if (resource instanceof Host) { + Host host = (Host) resource; result = Optional.of( host.isSubordinate() diff --git a/core/src/main/java/google/registry/rde/RdeMarshaller.java b/core/src/main/java/google/registry/rde/RdeMarshaller.java index 0030f5a06..323e4e05e 100644 --- a/core/src/main/java/google/registry/rde/RdeMarshaller.java +++ b/core/src/main/java/google/registry/rde/RdeMarshaller.java @@ -22,7 +22,7 @@ import com.googlecode.objectify.Key; import google.registry.model.ImmutableObject; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.rde.RdeMode; import google.registry.model.registrar.Registrar; import google.registry.tldconfig.idn.IdnTable; @@ -129,16 +129,17 @@ public final class RdeMarshaller implements Serializable { RdeResourceType.DOMAIN, domain, DomainToXjcConverter.convert(domain, mode)); } - /** Turns {@link HostResource} object into an XML fragment. */ - public DepositFragment marshalSubordinateHost(HostResource host, Domain superordinateDomain) { - return marshalResource(RdeResourceType.HOST, host, - HostResourceToXjcConverter.convertSubordinate(host, superordinateDomain)); + /** Turns {@link Host} object into an XML fragment. */ + public DepositFragment marshalSubordinateHost(Host host, Domain superordinateDomain) { + return marshalResource( + RdeResourceType.HOST, + host, + HostToXjcConverter.convertSubordinate(host, superordinateDomain)); } - /** Turns {@link HostResource} object into an XML fragment. */ - public DepositFragment marshalExternalHost(HostResource host) { - return marshalResource(RdeResourceType.HOST, host, - HostResourceToXjcConverter.convertExternal(host)); + /** Turns {@link Host} object into an XML fragment. */ + public DepositFragment marshalExternalHost(Host host) { + return marshalResource(RdeResourceType.HOST, host, HostToXjcConverter.convertExternal(host)); } /** Turns {@link Registrar} object into an XML fragment. */ diff --git a/core/src/main/java/google/registry/rde/RdeStagingAction.java b/core/src/main/java/google/registry/rde/RdeStagingAction.java index 0bf36dffd..7e0ca3499 100644 --- a/core/src/main/java/google/registry/rde/RdeStagingAction.java +++ b/core/src/main/java/google/registry/rde/RdeStagingAction.java @@ -47,7 +47,7 @@ import google.registry.model.common.Cursor; import google.registry.model.common.Cursor.CursorType; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.EppResourceIndex; import google.registry.model.rde.RdeMode; import google.registry.model.registrar.Registrar; @@ -82,8 +82,8 @@ import org.joda.time.Duration; * type and loads the embedded resource from it, which is then projected to watermark time to * account for things like pending transfer. * - *

Only {@link ContactResource}s and {@link HostResource}s that are referenced by an included - * {@link Domain} will be included in the corresponding pending deposit. + *

Only {@link ContactResource}s and {@link Host}s that are referenced by an included {@link + * Domain} will be included in the corresponding pending deposit. * *

{@link Registrar} entities, both active and inactive, are included in all deposits. They are * not rewinded point-in-time. diff --git a/core/src/main/java/google/registry/tools/CommandUtilities.java b/core/src/main/java/google/registry/tools/CommandUtilities.java index dc5c3be47..476567e87 100644 --- a/core/src/main/java/google/registry/tools/CommandUtilities.java +++ b/core/src/main/java/google/registry/tools/CommandUtilities.java @@ -21,7 +21,7 @@ import com.google.common.base.Strings; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.ForeignKeyIndex; import google.registry.persistence.VKey; import org.joda.time.DateTime; @@ -32,7 +32,7 @@ class CommandUtilities { /** A useful parameter enum for commands that operate on {@link EppResource} objects. */ public enum ResourceType { CONTACT(ContactResource.class), - HOST(HostResource.class), + HOST(Host.class), DOMAIN(Domain.class); private final Class clazz; diff --git a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java index 9ea453536..73e410855 100644 --- a/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java +++ b/core/src/main/java/google/registry/tools/GenerateDnsReportCommand.java @@ -26,7 +26,7 @@ import com.beust.jcommander.Parameters; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.transaction.QueryComposer.Comparator; import google.registry.tools.params.PathParameter; import google.registry.util.Clock; @@ -87,8 +87,8 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi { write(domain); } - Iterable nameservers = tm().transact(() -> tm().loadAllOf(HostResource.class)); - for (HostResource nameserver : nameservers) { + Iterable nameservers = tm().transact(() -> tm().loadAllOf(Host.class)); + for (Host nameserver : nameservers) { // Skip deleted hosts and external hosts. if (isBeforeOrAt(nameserver.getDeletionTime(), now) || nameserver.getInetAddresses().isEmpty()) { @@ -126,7 +126,7 @@ final class GenerateDnsReportCommand implements CommandWithRemoteApi { writeJson(mapBuilder.build()); } - private void write(HostResource nameserver) { + private void write(Host nameserver) { ImmutableList ipAddresses = nameserver .getInetAddresses() diff --git a/core/src/main/java/google/registry/tools/GetHostCommand.java b/core/src/main/java/google/registry/tools/GetHostCommand.java index 5776c9299..8ea191330 100644 --- a/core/src/main/java/google/registry/tools/GetHostCommand.java +++ b/core/src/main/java/google/registry/tools/GetHostCommand.java @@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.util.DomainNameUtils; import java.util.List; @@ -35,7 +35,6 @@ final class GetHostCommand extends GetEppResourceCommand { public void runAndPrint() { mainParameters.stream() .map(DomainNameUtils::canonicalizeHostname) - .forEach( - h -> printResource("Host", h, loadByForeignKey(HostResource.class, h, readTimestamp))); + .forEach(h -> printResource("Host", h, loadByForeignKey(Host.class, h, readTimestamp))); } } diff --git a/core/src/main/java/google/registry/tools/ListHostsCommand.java b/core/src/main/java/google/registry/tools/ListHostsCommand.java index f53da3ff3..0fe9b3a44 100644 --- a/core/src/main/java/google/registry/tools/ListHostsCommand.java +++ b/core/src/main/java/google/registry/tools/ListHostsCommand.java @@ -17,7 +17,7 @@ package google.registry.tools; import com.beust.jcommander.Parameters; import google.registry.tools.server.ListHostsAction; -/** Command to list all HostResource entities in the system. */ +/** Command to list all Host entities in the system. */ @Parameters(separators = " =", commandDescription = "List all hosts.") final class ListHostsCommand extends ListObjectsCommand { diff --git a/core/src/main/java/google/registry/tools/UniformRapidSuspensionCommand.java b/core/src/main/java/google/registry/tools/UniformRapidSuspensionCommand.java index d28f9686d..10e77444f 100644 --- a/core/src/main/java/google/registry/tools/UniformRapidSuspensionCommand.java +++ b/core/src/main/java/google/registry/tools/UniformRapidSuspensionCommand.java @@ -35,7 +35,7 @@ import com.google.template.soy.data.SoyMapData; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.tools.soy.DomainRenewSoyInfo; import google.registry.tools.soy.UniformRapidSuspensionSoyInfo; import google.registry.util.DomainNameUtils; @@ -130,7 +130,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { checkArgumentPresent(domainOpt, "Domain '%s' does not exist or is deleted", domainName); Domain domain = domainOpt.get(); Set missingHosts = - difference(newHostsSet, checkResourcesExist(HostResource.class, newCanonicalHosts, now)); + difference(newHostsSet, checkResourcesExist(Host.class, newCanonicalHosts, now)); checkArgument(missingHosts.isEmpty(), "Hosts do not exist: %s", missingHosts); checkArgument( locksToPreserve.isEmpty() || undo, @@ -204,8 +204,7 @@ final class UniformRapidSuspensionCommand extends MutatingEppToolCommand { private ImmutableSortedSet getExistingNameservers(Domain domain) { ImmutableSortedSet.Builder nameservers = ImmutableSortedSet.naturalOrder(); - for (HostResource host : - tm().transact(() -> tm().loadByKeys(domain.getNameservers()).values())) { + for (Host host : tm().transact(() -> tm().loadByKeys(domain.getNameservers()).values())) { nameservers.add(host.getForeignKey()); } return nameservers.build(); diff --git a/core/src/main/java/google/registry/tools/params/EppResourceTypeParameter.java b/core/src/main/java/google/registry/tools/params/EppResourceTypeParameter.java index 4b009cd4e..8e9d4bb49 100644 --- a/core/src/main/java/google/registry/tools/params/EppResourceTypeParameter.java +++ b/core/src/main/java/google/registry/tools/params/EppResourceTypeParameter.java @@ -17,13 +17,13 @@ package google.registry.tools.params; import google.registry.model.EppResource; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; /** Enum to make it easy for a command to accept a flag that specifies an EppResource subclass. */ public enum EppResourceTypeParameter { CONTACT(ContactResource.class), DOMAIN(Domain.class), - HOST(HostResource.class); + HOST(Host.class); private final Class type; diff --git a/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java b/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java index 701f9778d..ba7f254e7 100644 --- a/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java +++ b/core/src/main/java/google/registry/tools/server/GenerateZoneFilesAction.java @@ -31,7 +31,7 @@ import google.registry.config.RegistryConfig.Config; import google.registry.gcs.GcsUtils; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.request.Action; import google.registry.request.HttpException.BadRequestException; import google.registry.request.JsonActionRunner; @@ -196,8 +196,8 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA Domain domain, DateTime exportTime, ImmutableList.Builder result) { ImmutableSet subordinateHosts = domain.getSubordinateHosts(); if (!subordinateHosts.isEmpty()) { - for (HostResource unprojectedHost : tm().loadByKeys(domain.getNameservers()).values()) { - HostResource host = loadAtPointInTime(unprojectedHost, exportTime); + for (Host unprojectedHost : tm().loadByKeys(domain.getNameservers()).values()) { + Host host = loadAtPointInTime(unprojectedHost, exportTime); // A null means the host was deleted (or not created) at this time. if (host != null && subordinateHosts.contains(host.getHostName())) { String stanza = hostStanza(host, domain.getTld()); @@ -232,7 +232,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA private String domainStanza(Domain domain, DateTime exportTime) { StringBuilder result = new StringBuilder(); String domainLabel = stripTld(domain.getDomainName(), domain.getTld()); - for (HostResource nameserver : tm().loadByKeys(domain.getNameservers()).values()) { + for (Host nameserver : tm().loadByKeys(domain.getNameservers()).values()) { result.append( String.format( NS_FORMAT, @@ -267,7 +267,7 @@ public class GenerateZoneFilesAction implements Runnable, JsonActionRunner.JsonA * } * */ - private String hostStanza(HostResource host, String tld) { + private String hostStanza(Host host, String tld) { StringBuilder result = new StringBuilder(); for (InetAddress addr : host.getInetAddresses()) { // must be either IPv4 or IPv6 diff --git a/core/src/main/java/google/registry/tools/server/ListHostsAction.java b/core/src/main/java/google/registry/tools/server/ListHostsAction.java index 38f49e97b..7c9d27c22 100644 --- a/core/src/main/java/google/registry/tools/server/ListHostsAction.java +++ b/core/src/main/java/google/registry/tools/server/ListHostsAction.java @@ -22,7 +22,7 @@ import static java.util.Comparator.comparing; import com.google.common.collect.ImmutableSet; import google.registry.model.EppResourceUtils; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.request.Action; import google.registry.request.auth.Auth; import google.registry.util.Clock; @@ -35,7 +35,7 @@ import org.joda.time.DateTime; path = ListHostsAction.PATH, method = {GET, POST}, auth = Auth.AUTH_INTERNAL_OR_ADMIN) -public final class ListHostsAction extends ListObjectsAction { +public final class ListHostsAction extends ListObjectsAction { public static final String PATH = "/_dr/admin/list/hosts"; @@ -48,10 +48,10 @@ public final class ListHostsAction extends ListObjectsAction { } @Override - public ImmutableSet loadObjects() { + public ImmutableSet loadObjects() { final DateTime now = clock.nowUtc(); - return tm().transact(() -> tm().loadAllOf(HostResource.class)).stream() + return tm().transact(() -> tm().loadAllOf(Host.class)).stream() .filter(host -> EppResourceUtils.isActive(host, now)) - .collect(toImmutableSortedSet(comparing(HostResource::getHostName))); + .collect(toImmutableSortedSet(comparing(Host::getHostName))); } } diff --git a/core/src/main/java/google/registry/whois/NameserverLookupByHostCommand.java b/core/src/main/java/google/registry/whois/NameserverLookupByHostCommand.java index 3ca6432d3..c3de436f9 100644 --- a/core/src/main/java/google/registry/whois/NameserverLookupByHostCommand.java +++ b/core/src/main/java/google/registry/whois/NameserverLookupByHostCommand.java @@ -18,7 +18,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.model.EppResourceUtils.loadByForeignKeyCached; import com.google.common.net.InternetDomainName; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import java.util.Optional; import org.joda.time.DateTime; @@ -34,10 +34,10 @@ public class NameserverLookupByHostCommand extends DomainOrHostLookupCommand { @Override protected Optional getResponse(InternetDomainName hostName, DateTime now) { - Optional hostResource = + Optional host = cached - ? loadByForeignKeyCached(HostResource.class, hostName.toString(), now) - : loadByForeignKey(HostResource.class, hostName.toString(), now); - return hostResource.map(host -> new NameserverWhoisResponse(host, now)); + ? loadByForeignKeyCached(Host.class, hostName.toString(), now) + : loadByForeignKey(Host.class, hostName.toString(), now); + return host.map(h -> new NameserverWhoisResponse(h, now)); } } diff --git a/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java b/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java index a0fc736b6..b5568c155 100644 --- a/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java +++ b/core/src/main/java/google/registry/whois/NameserverLookupByIpCommand.java @@ -26,7 +26,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Streams; import com.google.common.net.InetAddresses; import com.google.common.net.InternetDomainName; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.tld.Registries; import java.net.InetAddress; import org.joda.time.DateTime; @@ -51,12 +51,12 @@ final class NameserverLookupByIpCommand implements WhoisCommand { @Override @SuppressWarnings("unchecked") public WhoisResponse executeQuery(DateTime now) throws WhoisException { - Iterable hostsFromDb; + Iterable hostsFromDb; if (tm().isOfy()) { hostsFromDb = auditedOfy() .load() - .type(HostResource.class) + .type(Host.class) .filter("inetAddresses", ipAddress) .filter("deletionTime >", now.toDate()); } else { @@ -76,12 +76,12 @@ final class NameserverLookupByIpCommand implements WhoisCommand { "SELECT * From \"Host\" WHERE " + "ARRAY[ CAST(:address AS TEXT) ] <@ inet_addresses AND " + "deletion_time > CAST(:now AS timestamptz)", - HostResource.class) + Host.class) .setParameter("address", InetAddresses.toAddrString(ipAddress)) .setParameter("now", now.toString()) .getResultList()); } - ImmutableList hosts = + ImmutableList hosts = Streams.stream(hostsFromDb) .filter( host -> diff --git a/core/src/main/java/google/registry/whois/NameserverWhoisResponse.java b/core/src/main/java/google/registry/whois/NameserverWhoisResponse.java index 72b3c3f7b..eacc0b563 100644 --- a/core/src/main/java/google/registry/whois/NameserverWhoisResponse.java +++ b/core/src/main/java/google/registry/whois/NameserverWhoisResponse.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.google.common.net.InetAddresses; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import java.util.Optional; import org.joda.time.DateTime; @@ -32,15 +32,15 @@ import org.joda.time.DateTime; final class NameserverWhoisResponse extends WhoisResponseImpl { /** Nameserver(s) which were the target of this WHOIS command. */ - private final ImmutableList hosts; + private final ImmutableList hosts; /** Creates new WHOIS nameserver response on the given host. */ - NameserverWhoisResponse(HostResource host, DateTime timestamp) { + NameserverWhoisResponse(Host host, DateTime timestamp) { this(ImmutableList.of(checkNotNull(host, "host")), timestamp); } /** Creates new WHOIS nameserver response on the given list of hosts. */ - NameserverWhoisResponse(ImmutableList hosts, DateTime timestamp) { + NameserverWhoisResponse(ImmutableList hosts, DateTime timestamp) { super(timestamp); this.hosts = checkNotNull(hosts, "hosts"); } @@ -48,9 +48,9 @@ final class NameserverWhoisResponse extends WhoisResponseImpl { @Override public WhoisResponseResults getResponse(boolean preferUnicode, String disclaimer) { // If we have subordinate hosts, load their registrar ids in a single transaction up-front. - ImmutableList subordinateHosts = - hosts.stream().filter(HostResource::isSubordinate).collect(toImmutableList()); - ImmutableMap hostRegistrars = + ImmutableList subordinateHosts = + hosts.stream().filter(Host::isSubordinate).collect(toImmutableList()); + ImmutableMap hostRegistrars = subordinateHosts.isEmpty() ? ImmutableMap.of() : tm().transact( @@ -64,7 +64,7 @@ final class NameserverWhoisResponse extends WhoisResponseImpl { BasicEmitter emitter = new BasicEmitter(); for (int i = 0; i < hosts.size(); i++) { - HostResource host = hosts.get(i); + Host host = hosts.get(i); String registrarId = host.isSubordinate() ? hostRegistrars.get(host) diff --git a/core/src/main/resources/META-INF/persistence.xml b/core/src/main/resources/META-INF/persistence.xml index 5dcc9a372..53a31e03f 100644 --- a/core/src/main/resources/META-INF/persistence.xml +++ b/core/src/main/resources/META-INF/persistence.xml @@ -53,7 +53,7 @@ google.registry.model.domain.secdns.DomainDsDataHistory google.registry.model.domain.token.AllocationToken google.registry.model.host.HostHistory - google.registry.model.host.HostResource + google.registry.model.host.Host google.registry.model.poll.PollMessage google.registry.model.poll.PollMessage$OneTime google.registry.model.poll.PollMessage$Autorenew @@ -104,7 +104,7 @@ google.registry.model.contact.VKeyConverter_ContactResource google.registry.model.domain.VKeyConverter_Domain google.registry.model.domain.token.VKeyConverter_AllocationToken - google.registry.model.host.VKeyConverter_HostResource + google.registry.model.host.VKeyConverter_Host google.registry.model.poll.VKeyConverter_Autorenew google.registry.model.poll.VKeyConverter_OneTime diff --git a/core/src/test/java/google/registry/batch/RelockDomainActionTest.java b/core/src/test/java/google/registry/batch/RelockDomainActionTest.java index 4d41cef4b..3def0e534 100644 --- a/core/src/test/java/google/registry/batch/RelockDomainActionTest.java +++ b/core/src/test/java/google/registry/batch/RelockDomainActionTest.java @@ -37,7 +37,7 @@ import com.google.cloud.tasks.v2.HttpMethod; import com.google.common.collect.ImmutableSet; import google.registry.model.domain.Domain; import google.registry.model.domain.RegistryLock; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.testing.AppEngineExtension; import google.registry.testing.CloudTasksHelper; import google.registry.testing.CloudTasksHelper.TaskMatcher; @@ -95,7 +95,7 @@ public class RelockDomainActionTest { @BeforeEach void beforeEach() throws Exception { createTlds("tld", "net"); - HostResource host = persistActiveHost("ns1.example.net"); + Host host = persistActiveHost("ns1.example.net"); domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host)); oldLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, POC_ID, false); diff --git a/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java b/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java index 16e99803b..9546a7410 100644 --- a/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java +++ b/core/src/test/java/google/registry/beam/rde/RdePipelineTest.java @@ -62,9 +62,9 @@ import google.registry.model.domain.DomainBase; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.Period; import google.registry.model.eppcommon.Trid; +import google.registry.model.host.Host; import google.registry.model.host.HostBase; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.rde.RdeMode; import google.registry.model.rde.RdeRevision; import google.registry.model.rde.RdeRevision.RdeRevisionId; @@ -272,7 +272,7 @@ public class RdePipelineTest { // This host is never referenced. persistHostHistory(persistActiveHost("ns0.domain.tld")); - HostResource host1 = persistActiveHost("ns1.external.tld"); + Host host1 = persistActiveHost("ns1.external.tld"); persistHostHistory(host1); Domain helloDomain = persistEppResource( @@ -282,7 +282,7 @@ public class RdePipelineTest { .build()); persistDomainHistory(helloDomain); persistHostHistory(persistActiveHost("not-used-subordinate.hello.soy")); - HostResource host2 = persistActiveHost("ns1.hello.soy"); + Host host2 = persistActiveHost("ns1.hello.soy"); persistHostHistory(host2); Domain kittyDomain = persistEppResource( @@ -306,7 +306,7 @@ public class RdePipelineTest { persistContactHistory(contact3); // This is a subordinate domain in TLD .cat, which is not included in any pending deposit. But // it should still be included as a subordinate host in the pendign deposit for .soy. - HostResource host3 = persistActiveHost("ns1.lol.cat"); + Host host3 = persistActiveHost("ns1.lol.cat"); persistHostHistory(host3); persistDomainHistory( helloDomain @@ -331,7 +331,7 @@ public class RdePipelineTest { persistDomainHistory(kittyDomain.asBuilder().setDeletionTime(clock.nowUtc()).build()); ContactResource futureContact = persistActiveContact("future-contact"); persistContactHistory(futureContact); - HostResource futureHost = persistActiveHost("ns1.future.tld"); + Host futureHost = persistActiveHost("ns1.future.tld"); persistHostHistory(futureHost); persistDomainHistory( persistEppResource( diff --git a/core/src/test/java/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java b/core/src/test/java/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java index c2514dbea..1487c8b49 100644 --- a/core/src/test/java/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java +++ b/core/src/test/java/google/registry/dns/writer/clouddns/CloudDnsWriterTest.java @@ -18,7 +18,7 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistResource; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doThrow; @@ -41,7 +41,7 @@ import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -283,31 +283,28 @@ public class CloudDnsWriterTest { /** Returns a domain to be persisted in Datastore. */ private static Domain fakeDomain( - String domainName, ImmutableSet nameservers, int numDsRecords) { + String domainName, ImmutableSet nameservers, int numDsRecords) { ImmutableSet.Builder dsDataBuilder = new ImmutableSet.Builder<>(); for (int i = 0; i < numDsRecords; i++) { dsDataBuilder.add(DelegationSignerData.create(i, 3, 1, base16().decode("1234567890ABCDEF"))); } - ImmutableSet.Builder> hostResourceRefBuilder = new ImmutableSet.Builder<>(); - for (HostResource nameserver : nameservers) { - hostResourceRefBuilder.add(nameserver.createVKey()); + ImmutableSet.Builder> hostRefBuilder = new ImmutableSet.Builder<>(); + for (Host nameserver : nameservers) { + hostRefBuilder.add(nameserver.createVKey()); } return DatabaseHelper.newDomain(domainName) .asBuilder() - .setNameservers(hostResourceRefBuilder.build()) + .setNameservers(hostRefBuilder.build()) .setDsData(dsDataBuilder.build()) .build(); } /** Returns a nameserver used for its NS record. */ - private static HostResource fakeHost(String nameserver, InetAddress... addresses) { - return newHostResource(nameserver) - .asBuilder() - .setInetAddresses(ImmutableSet.copyOf(addresses)) - .build(); + private static Host fakeHost(String nameserver, InetAddress... addresses) { + return newHost(nameserver).asBuilder().setInetAddresses(ImmutableSet.copyOf(addresses)).build(); } @MockitoSettings(strictness = Strictness.LENIENT) diff --git a/core/src/test/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java b/core/src/test/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java index 2ae4c0ade..2e37b4ce7 100644 --- a/core/src/test/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java +++ b/core/src/test/java/google/registry/dns/writer/dnsupdate/DnsUpdateWriterTest.java @@ -18,7 +18,7 @@ import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHost; @@ -38,7 +38,7 @@ import com.google.common.net.InetAddresses; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -98,8 +98,8 @@ public class DnsUpdateWriterTest { @Test void testPublishDomainCreate_publishesNameServers() throws Exception { - HostResource host1 = persistActiveHost("ns1.example.tld"); - HostResource host2 = persistActiveHost("ns2.example.tld"); + Host host1 = persistActiveHost("ns1.example.tld"); + Host host2 = persistActiveHost("ns2.example.tld"); Domain domain = persistActiveDomain("example.tld") .asBuilder() @@ -121,7 +121,7 @@ public class DnsUpdateWriterTest { @MockitoSettings(strictness = Strictness.LENIENT) @Test void testPublishAtomic_noCommit() { - HostResource host1 = persistActiveHost("ns.example1.tld"); + Host host1 = persistActiveHost("ns.example1.tld"); Domain domain1 = persistActiveDomain("example1.tld") .asBuilder() @@ -129,7 +129,7 @@ public class DnsUpdateWriterTest { .build(); persistResource(domain1); - HostResource host2 = persistActiveHost("ns.example2.tld"); + Host host2 = persistActiveHost("ns.example2.tld"); Domain domain2 = persistActiveDomain("example2.tld") .asBuilder() @@ -145,7 +145,7 @@ public class DnsUpdateWriterTest { @Test void testPublishAtomic_oneUpdate() throws Exception { - HostResource host1 = persistActiveHost("ns.example1.tld"); + Host host1 = persistActiveHost("ns.example1.tld"); Domain domain1 = persistActiveDomain("example1.tld") .asBuilder() @@ -153,7 +153,7 @@ public class DnsUpdateWriterTest { .build(); persistResource(domain1); - HostResource host2 = persistActiveHost("ns.example2.tld"); + Host host2 = persistActiveHost("ns.example2.tld"); Domain domain2 = persistActiveDomain("example2.tld") .asBuilder() @@ -235,9 +235,9 @@ public class DnsUpdateWriterTest { @Test void testPublishHostCreate_publishesAddressRecords() throws Exception { - HostResource host = + Host host = persistResource( - newHostResource("ns1.example.tld") + newHost("ns1.example.tld") .asBuilder() .setInetAddresses( ImmutableSet.of( @@ -305,10 +305,10 @@ public class DnsUpdateWriterTest { @Test void testPublishDomainExternalAndInBailiwickNameServer() throws Exception { - HostResource externalNameserver = persistResource(newHostResource("ns1.example.com")); - HostResource inBailiwickNameserver = + Host externalNameserver = persistResource(newHost("ns1.example.com")); + Host inBailiwickNameserver = persistResource( - newHostResource("ns1.example.tld") + newHost("ns1.example.tld") .asBuilder() .setInetAddresses( ImmutableSet.of( @@ -342,9 +342,9 @@ public class DnsUpdateWriterTest { @Test void testPublishDomainDeleteOrphanGlues() throws Exception { - HostResource inBailiwickNameserver = + Host inBailiwickNameserver = persistResource( - newHostResource("ns1.example.tld") + newHost("ns1.example.tld") .asBuilder() .setInetAddresses( ImmutableSet.of( @@ -401,7 +401,7 @@ public class DnsUpdateWriterTest { @SuppressWarnings("AssertThrowsMultipleStatements") @Test void testPublishHostFails_whenDnsUpdateReturnsError() throws Exception { - HostResource host = + Host host = persistActiveSubordinateHost("ns1.example.tld", persistActiveDomain("example.tld")) .asBuilder() .setInetAddresses(ImmutableSet.of(InetAddresses.forString("10.0.0.1"))) diff --git a/core/src/test/java/google/registry/flows/EppLifecycleHostTest.java b/core/src/test/java/google/registry/flows/EppLifecycleHostTest.java index 8c48f402a..0559ff24b 100644 --- a/core/src/test/java/google/registry/flows/EppLifecycleHostTest.java +++ b/core/src/test/java/google/registry/flows/EppLifecycleHostTest.java @@ -20,11 +20,11 @@ import static google.registry.model.eppoutput.Result.Code.SUCCESS; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTlds; import static google.registry.testing.EppMetricSubject.assertThat; -import static google.registry.testing.HostResourceSubject.assertAboutHosts; +import static google.registry.testing.HostSubject.assertAboutHosts; import com.google.common.collect.ImmutableMap; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.testing.AppEngineExtension; import org.joda.time.DateTime; import org.junit.jupiter.api.Test; @@ -210,8 +210,8 @@ class EppLifecycleHostTest extends EppTestCase { DateTime timeAfterCreates = DateTime.parse("2000-06-01T00:06:00Z"); - HostResource exampleBarFooTldHost = - loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get(); + Host exampleBarFooTldHost = + loadByForeignKey(Host.class, "ns1.example.bar.foo.tld", timeAfterCreates).get(); Domain exampleBarFooTldDomain = loadByForeignKey(Domain.class, "example.bar.foo.tld", timeAfterCreates).get(); assertAboutHosts() @@ -220,8 +220,8 @@ class EppLifecycleHostTest extends EppTestCase { assertThat(exampleBarFooTldDomain.getSubordinateHosts()) .containsExactly("ns1.example.bar.foo.tld"); - HostResource exampleFooTldHost = - loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get(); + Host exampleFooTldHost = + loadByForeignKey(Host.class, "ns1.example.foo.tld", timeAfterCreates).get(); Domain exampleFooTldDomain = loadByForeignKey(Domain.class, "example.foo.tld", timeAfterCreates).get(); assertAboutHosts() @@ -229,8 +229,7 @@ class EppLifecycleHostTest extends EppTestCase { .hasSuperordinateDomain(exampleFooTldDomain.createVKey()); assertThat(exampleFooTldDomain.getSubordinateHosts()).containsExactly("ns1.example.foo.tld"); - HostResource exampleTldHost = - loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get(); + Host exampleTldHost = loadByForeignKey(Host.class, "ns1.example.tld", timeAfterCreates).get(); Domain exampleTldDomain = loadByForeignKey(Domain.class, "example.tld", timeAfterCreates).get(); assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(exampleTldDomain.createVKey()); assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld"); diff --git a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java index ed4f944dd..6837786ef 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainCreateFlowTest.java @@ -43,7 +43,7 @@ import static google.registry.testing.DatabaseHelper.deleteTld; import static google.registry.testing.DatabaseHelper.getHistoryEntries; import static google.registry.testing.DatabaseHelper.loadRegistrar; import static google.registry.testing.DatabaseHelper.newContactResource; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; @@ -1698,8 +1698,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase { private ContactResource registrant; private ContactResource contact; - private HostResource host1; - private HostResource host2; - private HostResource host3; + private Host host1; + private Host host2; + private Host host3; private Domain domain; @BeforeEach @@ -147,7 +147,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase { // Create a subordinate host that is not delegated to by anyone. host3 = persistResource( - new HostResource.Builder() + new Host.Builder() .setHostName("ns2.example.tld") .setRepoId("3FF-TLD") .setSuperordinateDomain(domain.createVKey()) diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java b/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java index 67a3f8825..0a265842e 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferFlowTestCase.java @@ -39,7 +39,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; import google.registry.model.transfer.TransferData; @@ -73,7 +73,7 @@ abstract class DomainTransferFlowTestCase protected ContactResource contact; protected Domain domain; - HostResource subordinateHost; + Host subordinateHost; private DomainHistory historyEntryDomainCreate; DomainTransferFlowTestCase() { @@ -111,7 +111,7 @@ abstract class DomainTransferFlowTestCase REGISTRATION_EXPIRATION_TIME); subordinateHost = persistResource( - new HostResource.Builder() + new Host.Builder() .setRepoId("2-".concat(Ascii.toUpperCase(tld))) .setHostName("ns1." + label + "." + tld) .setPersistedCurrentSponsorRegistrarId("TheRegistrar") diff --git a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java index a7613b2ff..12c89d7a4 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainTransferRequestFlowTest.java @@ -41,7 +41,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; -import static google.registry.testing.HostResourceSubject.assertAboutHosts; +import static google.registry.testing.HostSubject.assertAboutHosts; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.money.CurrencyUnit.JPY; import static org.joda.money.CurrencyUnit.USD; diff --git a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java index 754eb3f80..0e1a67309 100644 --- a/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/domain/DomainUpdateFlowTest.java @@ -99,7 +99,7 @@ import google.registry.model.domain.DomainHistory; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse; import google.registry.model.poll.PollMessage; import google.registry.model.tld.Registry; @@ -148,8 +148,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase> nameservers = new ImmutableSet.Builder<>(); + ImmutableSet.Builder> nameservers = new ImmutableSet.Builder<>(); for (int i = 1; i < 15; i++) { if (i != 2) { // Skip 2 since that's the one that the tests will add. nameservers.add( - loadByForeignKey( - HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc()) + loadByForeignKey(Host.class, String.format("ns%d.example.foo", i), clock.nowUtc()) .get() .createVKey()); } @@ -318,9 +315,9 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase> nameservers = new ImmutableSet.Builder<>(); + ImmutableSet.Builder> nameservers = new ImmutableSet.Builder<>(); for (int i = 0; i < 26; i++) { - HostResource host = persistActiveHost(String.format("max_test_%d.example.tld", i)); + Host host = persistActiveHost(String.format("max_test_%d.example.tld", i)); if (i < 13) { nameservers.add(host.createVKey()); } @@ -394,7 +391,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase { +class HostCheckFlowTest extends ResourceCheckFlowTestCase { HostCheckFlowTest() { setEppInput("host_check.xml"); diff --git a/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java b/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java index 274b7e8a8..f2849087f 100644 --- a/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostCreateFlowTest.java @@ -19,13 +19,13 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistDeletedHost; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; -import static google.registry.testing.HostResourceSubject.assertAboutHosts; +import static google.registry.testing.HostSubject.assertAboutHosts; import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued; import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -51,14 +51,14 @@ import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistE import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.testing.DatabaseHelper; import org.joda.time.DateTime; import org.junit.jupiter.api.Test; /** Unit tests for {@link HostCreateFlow}. */ -class HostCreateFlowTest extends ResourceFlowTestCase { +class HostCreateFlowTest extends ResourceFlowTestCase { private void setEppHostCreateInput(String hostName, String hostAddrs) { setEppInput( @@ -83,7 +83,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase { +class HostDeleteFlowTest extends ResourceFlowTestCase { @BeforeEach void initFlowTest() { @@ -111,7 +111,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase exception) { persistResource( - newHostResource("ns1.example.tld") + newHost("ns1.example.tld") .asBuilder() .setStatusValues(ImmutableSet.of(statusValue)) .build()); @@ -166,7 +166,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase { +class HostInfoFlowTest extends ResourceFlowTestCase { @BeforeEach void initHostTest() { @@ -51,9 +51,9 @@ class HostInfoFlowTest extends ResourceFlowTestCase setEppInput("host_info.xml", ImmutableMap.of("HOSTNAME", "ns1.example.tld")); } - private HostResource persistHostResource() throws Exception { + private Host persistHost() throws Exception { return persistResource( - new HostResource.Builder() + new Host.Builder() .setHostName(getUniqueIdFromCommand()) .setRepoId("1FF-FOOBAR") .setPersistedCurrentSponsorRegistrarId("my sponsor") @@ -81,7 +81,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase @Test void testSuccess() throws Exception { - persistHostResource(); + persistHost(); assertTransactionalFlow(false); // Check that the persisted host info was returned. runFlowAssertResponse( @@ -94,11 +94,11 @@ class HostInfoFlowTest extends ResourceFlowTestCase @Test void testSuccess_linked() throws Exception { - persistHostResource(); + persistHost(); persistResource( DatabaseHelper.newDomain("example.foobar") .asBuilder() - .addNameserver(persistHostResource().createVKey()) + .addNameserver(persistHost().createVKey()) .build()); assertTransactionalFlow(false); // Check that the persisted host info was returned. @@ -121,7 +121,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase .setLastTransferTime(domainTransferTime) .setPersistedCurrentSponsorRegistrarId("superclientid") .build()); - HostResource firstHost = persistHostResource(); + Host firstHost = persistHost(); persistResource( firstHost .asBuilder() @@ -166,8 +166,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase @Test void testFailure_existedButWasDeleted() throws Exception { - persistResource( - persistHostResource().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); + persistResource(persistHost().asBuilder().setDeletionTime(clock.nowUtc().minusDays(1)).build()); ResourceDoesNotExistException thrown = assertThrows(ResourceDoesNotExistException.class, this::runFlow); assertThat(thrown).hasMessageThat().contains(String.format("(%s)", getUniqueIdFromCommand())); @@ -197,7 +196,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase @Test void testIcannActivityReportField_getsLogged() throws Exception { - persistHostResource(); + persistHost(); runFlow(); assertIcannReportingActivityFieldLogged("srs-host-info"); } diff --git a/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java b/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java index e39c9ca7f..1cc4e9c47 100644 --- a/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java +++ b/core/src/test/java/google/registry/flows/host/HostUpdateFlowTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.assertNoBillingEvents; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType; import static google.registry.testing.DatabaseHelper.loadByEntity; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHost; @@ -34,7 +34,7 @@ import static google.registry.testing.DomainSubject.assertAboutDomains; import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions; import static google.registry.testing.GenericEppResourceSubject.assertAboutEppResources; import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntries; -import static google.registry.testing.HostResourceSubject.assertAboutHosts; +import static google.registry.testing.HostSubject.assertAboutHosts; import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued; import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued; import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued; @@ -71,7 +71,7 @@ import google.registry.flows.host.HostUpdateFlow.HostAlreadyExistsException; import google.registry.flows.host.HostUpdateFlow.RenameHostToExternalRemoveIpException; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.ForeignKeyIndex; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; @@ -84,7 +84,7 @@ import org.joda.time.DateTime; import org.junit.jupiter.api.Test; /** Unit tests for {@link HostUpdateFlow}. */ -class HostUpdateFlowTest extends ResourceFlowTestCase { +class HostUpdateFlowTest extends ResourceFlowTestCase { private void setEppHostUpdateInput( String oldHostName, String newHostName, String ipOrStatusToAdd, String ipOrStatusToRem) { @@ -148,15 +148,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase oldFkiAfterRename = - ForeignKeyIndex.load(HostResource.class, oldHostName(), clock.nowUtc()); + ForeignKeyIndex oldFkiAfterRename = + ForeignKeyIndex.load(Host.class, oldHostName(), clock.nowUtc()); assertThat(oldFkiAfterRename).isNull(); } @@ -194,15 +193,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase { private Domain domain; private ContactResource contact; - private HostResource host; + private Host host; @BeforeEach void setUp() { diff --git a/core/src/test/java/google/registry/model/EppResourceTest.java b/core/src/test/java/google/registry/model/EppResourceTest.java index 34e5a242f..8ffd7b4ca 100644 --- a/core/src/test/java/google/registry/model/EppResourceTest.java +++ b/core/src/test/java/google/registry/model/EppResourceTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import com.google.common.collect.ImmutableList; import google.registry.model.contact.ContactResource; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.testing.TestCacheExtension; import java.time.Duration; import org.junit.jupiter.api.Test; @@ -51,15 +51,15 @@ public class EppResourceTest extends EntityTestCase { @Test void test_loadCached_ignoresHostChange() { - HostResource originalHost = persistActiveHost("ns1.example.com"); + Host originalHost = persistActiveHost("ns1.example.com"); assertThat(EppResource.loadCached(ImmutableList.of(originalHost.createVKey()))) .containsExactly(originalHost.createVKey(), originalHost); - HostResource modifiedHost = + Host modifiedHost = persistResource( originalHost.asBuilder().setLastTransferTime(fakeClock.nowUtc().minusDays(60)).build()); assertThat(EppResource.loadCached(ImmutableList.of(originalHost.createVKey()))) .containsExactly(originalHost.createVKey(), originalHost); - assertThat(loadByForeignKey(HostResource.class, "ns1.example.com", fakeClock.nowUtc())) + assertThat(loadByForeignKey(Host.class, "ns1.example.com", fakeClock.nowUtc())) .hasValue(modifiedHost); } } diff --git a/core/src/test/java/google/registry/model/EppResourceUtilsTest.java b/core/src/test/java/google/registry/model/EppResourceUtilsTest.java index d8900e878..e0793e76b 100644 --- a/core/src/test/java/google/registry/model/EppResourceUtilsTest.java +++ b/core/src/test/java/google/registry/model/EppResourceUtilsTest.java @@ -17,12 +17,12 @@ package google.registry.model; import static com.google.common.truth.Truth.assertThat; import static google.registry.model.EppResourceUtils.loadAtPointInTime; import static google.registry.testing.DatabaseHelper.createTld; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.util.DateTimeUtils.START_OF_TIME; import static org.joda.time.DateTimeZone.UTC; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.ofy.Ofy; import google.registry.testing.AppEngineExtension; import google.registry.testing.FakeClock; @@ -54,10 +54,9 @@ class EppResourceUtilsTest { void testLoadAtPointInTime_beforeCreated_returnsNull() { clock.advanceOneMilli(); // Don't save a commit log, we shouldn't need one. - HostResource host = persistResource( - newHostResource("ns1.cat.tld").asBuilder() - .setCreationTimeForTest(clock.nowUtc()) - .build()); + Host host = + persistResource( + newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(clock.nowUtc()).build()); assertThat(loadAtPointInTime(host, clock.nowUtc().minus(Duration.millis(1)))).isNull(); } @@ -65,10 +64,9 @@ class EppResourceUtilsTest { void testLoadAtPointInTime_atOrAfterLastAutoUpdateTime_returnsResource() { clock.advanceOneMilli(); // Don't save a commit log, we shouldn't need one. - HostResource host = persistResource( - newHostResource("ns1.cat.tld").asBuilder() - .setCreationTimeForTest(START_OF_TIME) - .build()); + Host host = + persistResource( + newHost("ns1.cat.tld").asBuilder().setCreationTimeForTest(START_OF_TIME).build()); assertThat(loadAtPointInTime(host, clock.nowUtc())).isEqualTo(host); } } diff --git a/core/src/test/java/google/registry/model/bulkquery/TestSetupHelper.java b/core/src/test/java/google/registry/model/bulkquery/TestSetupHelper.java index d7685baea..887b6c935 100644 --- a/core/src/test/java/google/registry/model/bulkquery/TestSetupHelper.java +++ b/core/src/test/java/google/registry/model/bulkquery/TestSetupHelper.java @@ -35,7 +35,7 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; @@ -75,7 +75,7 @@ public final class TestSetupHelper { public ContactResource contact; public Domain domain; public DomainHistory domainHistory; - public HostResource host; + public Host host; private JpaTransactionManager originalJpaTm; private JpaTransactionManager bulkQueryJpaTm; @@ -135,7 +135,7 @@ public final class TestSetupHelper { .build(); } - static Domain createFullDomain(ContactResource contact, HostResource host, FakeClock fakeClock) { + static Domain createFullDomain(ContactResource contact, Host host, FakeClock fakeClock) { return createSimpleDomain(contact) .asBuilder() .setDomainName(DOMAIN_NAME) @@ -169,8 +169,8 @@ public final class TestSetupHelper { .build(); } - static HostResource createHost() { - return new HostResource.Builder() + static Host createHost() { + return new Host.Builder() .setRepoId("host1") .setHostName("ns1.example.com") .setCreationRegistrarId(REGISTRAR_ID) diff --git a/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java b/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java index abf0a5460..000412eb3 100644 --- a/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java +++ b/core/src/test/java/google/registry/model/common/ClassPathManagerTest.java @@ -21,7 +21,7 @@ import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.token.AllocationToken; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndexBucket; import google.registry.model.index.ForeignKeyIndex.ForeignKeyContactIndex; @@ -53,7 +53,7 @@ public class ClassPathManagerTest { .isEqualTo(ForeignKeyContactIndex.class); assertThat(ClassPathManager.getClass("AllocationToken")).isEqualTo(AllocationToken.class); assertThat(ClassPathManager.getClass("RdeRevision")).isEqualTo(RdeRevision.class); - assertThat(ClassPathManager.getClass("HostResource")).isEqualTo(HostResource.class); + assertThat(ClassPathManager.getClass("Host")).isEqualTo(Host.class); assertThat(ClassPathManager.getClass("Registrar")).isEqualTo(Registrar.class); assertThat(ClassPathManager.getClass("ContactResource")).isEqualTo(ContactResource.class); assertThat(ClassPathManager.getClass("GaeUserIdConverter")).isEqualTo(GaeUserIdConverter.class); @@ -106,7 +106,7 @@ public class ClassPathManagerTest { .isEqualTo("ForeignKeyContactIndex"); assertThat(ClassPathManager.getClassName(AllocationToken.class)).isEqualTo("AllocationToken"); assertThat(ClassPathManager.getClassName(RdeRevision.class)).isEqualTo("RdeRevision"); - assertThat(ClassPathManager.getClassName(HostResource.class)).isEqualTo("HostResource"); + assertThat(ClassPathManager.getClassName(Host.class)).isEqualTo("Host"); assertThat(ClassPathManager.getClassName(Registrar.class)).isEqualTo("Registrar"); assertThat(ClassPathManager.getClassName(ContactResource.class)).isEqualTo("ContactResource"); assertThat(ClassPathManager.getClassName(GaeUserIdConverter.class)) diff --git a/core/src/test/java/google/registry/model/domain/DomainSqlTest.java b/core/src/test/java/google/registry/model/domain/DomainSqlTest.java index a613c8f36..3da803ea4 100644 --- a/core/src/test/java/google/registry/model/domain/DomainSqlTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainSqlTest.java @@ -47,7 +47,7 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.transfer.ContactTransferData; @@ -81,8 +81,8 @@ public class DomainSqlTest { private DomainHistory historyEntry; private VKey contactKey; private VKey contact2Key; - private VKey host1VKey; - private HostResource host; + private VKey host1VKey; + private Host host; private ContactResource contact; private ContactResource contact2; private ImmutableSet gracePeriods; @@ -95,7 +95,7 @@ public class DomainSqlTest { contactKey = createKey(ContactResource.class, "contact_id1"); contact2Key = createKey(ContactResource.class, "contact_id2"); - host1VKey = createKey(HostResource.class, "host1"); + host1VKey = createKey(Host.class, "host1"); domain = new Domain.Builder() @@ -130,7 +130,7 @@ public class DomainSqlTest { .build(); host = - new HostResource.Builder() + new Host.Builder() .setRepoId("host1") .setHostName("ns1.example.com") .setCreationRegistrarId("registrar1") @@ -676,8 +676,8 @@ public class DomainSqlTest { jpaTm() .transact( () -> { - HostResource host2 = - new HostResource.Builder() + Host host2 = + new Host.Builder() .setRepoId("host2") .setHostName("ns2.example.com") .setCreationRegistrarId("registrar1") diff --git a/core/src/test/java/google/registry/model/domain/DomainTest.java b/core/src/test/java/google/registry/model/domain/DomainTest.java index f0559a252..3de3b0351 100644 --- a/core/src/test/java/google/registry/model/domain/DomainTest.java +++ b/core/src/test/java/google/registry/model/domain/DomainTest.java @@ -22,7 +22,7 @@ import static google.registry.model.EppResourceUtils.loadByForeignKey; import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.insertInDb; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; @@ -55,7 +55,7 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; @@ -100,7 +100,7 @@ public class DomainTest { saveRegistrar("gaining"); createTld("com"); domain = persistActiveDomain("example.com"); - VKey hostKey = persistActiveHost("ns1.example.com").createVKey(); + VKey hostKey = persistActiveHost("ns1.example.com").createVKey(); contact1Key = persistActiveContact("contact_id1").createVKey(); contact2Key = persistActiveContact("contact_id1").createVKey(); domainHistory = @@ -288,7 +288,7 @@ public class DomainTest { assertThat( DatabaseHelper.newDomain("example.com") .asBuilder() - .setNameservers(ImmutableSet.of(newHostResource("foo.example.tld").createVKey())) + .setNameservers(ImmutableSet.of(newHost("foo.example.tld").createVKey())) .build() .nsHosts) .isNotNull(); @@ -336,8 +336,7 @@ public class DomainTest { @Test void testImplicitStatusValues() { - ImmutableSet> nameservers = - ImmutableSet.of(newHostResource("foo.example.tld").createVKey()); + ImmutableSet> nameservers = ImmutableSet.of(newHost("foo.example.tld").createVKey()); StatusValue[] statuses = {StatusValue.OK}; // OK is implicit if there's no other statuses but there are nameservers. assertAboutDomains() diff --git a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java index 82efef965..9a2756e2d 100644 --- a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java +++ b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid; import static google.registry.testing.DatabaseHelper.newDomain; -import static google.registry.testing.DatabaseHelper.newHostResourceWithRoid; +import static google.registry.testing.DatabaseHelper.newHostWithRoid; import static google.registry.util.DateTimeUtils.END_OF_TIME; import static java.nio.charset.StandardCharsets.UTF_8; @@ -36,7 +36,7 @@ import google.registry.model.domain.Period; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.DomainTransactionRecord; import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField; import google.registry.model.reporting.HistoryEntry; @@ -102,7 +102,7 @@ public class DomainHistoryTest extends EntityTestCase { static Domain createDomainWithContactsAndHosts() { createTld("tld"); - HostResource host = newHostResourceWithRoid("ns1.example.com", "host1"); + Host host = newHostWithRoid("ns1.example.com", "host1"); ContactResource contact = newContactResourceWithRoid("contactId", "contact1"); jpaTm() diff --git a/core/src/test/java/google/registry/model/history/HostHistoryTest.java b/core/src/test/java/google/registry/model/history/HostHistoryTest.java index d76d5a259..4fdfa1db1 100644 --- a/core/src/test/java/google/registry/model/history/HostHistoryTest.java +++ b/core/src/test/java/google/registry/model/history/HostHistoryTest.java @@ -19,14 +19,14 @@ import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableO import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm; import static google.registry.testing.DatabaseHelper.insertInDb; import static google.registry.testing.DatabaseHelper.loadByEntity; -import static google.registry.testing.DatabaseHelper.newHostResourceWithRoid; +import static google.registry.testing.DatabaseHelper.newHostWithRoid; import static java.nio.charset.StandardCharsets.UTF_8; import google.registry.model.EntityTestCase; import google.registry.model.eppcommon.Trid; +import google.registry.model.host.Host; import google.registry.model.host.HostBase; import google.registry.model.host.HostHistory; -import google.registry.model.host.HostResource; import google.registry.model.reporting.HistoryEntry; import google.registry.util.SerializeUtils; import org.junit.jupiter.api.Test; @@ -40,9 +40,9 @@ public class HostHistoryTest extends EntityTestCase { @Test void testPersistence() { - HostResource host = newHostResourceWithRoid("ns1.example.com", "host1"); + Host host = newHostWithRoid("ns1.example.com", "host1"); insertInDb(host); - HostResource hostFromDb = loadByEntity(host); + Host hostFromDb = loadByEntity(host); HostHistory hostHistory = createHostHistory(hostFromDb); insertInDb(hostHistory); jpaTm() @@ -56,9 +56,9 @@ public class HostHistoryTest extends EntityTestCase { @Test void testSerializable() { - HostResource host = newHostResourceWithRoid("ns1.example.com", "host1"); + Host host = newHostWithRoid("ns1.example.com", "host1"); insertInDb(host); - HostResource hostFromDb = loadByEntity(host); + Host hostFromDb = loadByEntity(host); HostHistory hostHistory = createHostHistory(hostFromDb); insertInDb(hostHistory); HostHistory fromDatabase = jpaTm().transact(() -> jpaTm().loadByKey(hostHistory.createVKey())); @@ -67,10 +67,10 @@ public class HostHistoryTest extends EntityTestCase { @Test void testLegacyPersistence_nullHostBase() { - HostResource host = newHostResourceWithRoid("ns1.example.com", "host1"); + Host host = newHostWithRoid("ns1.example.com", "host1"); insertInDb(host); - HostResource hostFromDb = loadByEntity(host); + Host hostFromDb = loadByEntity(host); HostHistory hostHistory = createHostHistory(hostFromDb).asBuilder().setHost(null).build(); insertInDb(hostHistory); diff --git a/core/src/test/java/google/registry/model/host/HostResourceTest.java b/core/src/test/java/google/registry/model/host/HostTest.java similarity index 88% rename from core/src/test/java/google/registry/model/host/HostResourceTest.java rename to core/src/test/java/google/registry/model/host/HostTest.java index e3199d38f..85aa42146 100644 --- a/core/src/test/java/google/registry/model/host/HostResourceTest.java +++ b/core/src/test/java/google/registry/model/host/HostTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistNewRegistrars; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.testing.HostResourceSubject.assertAboutHosts; +import static google.registry.testing.HostSubject.assertAboutHosts; import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; @@ -40,15 +40,15 @@ import org.joda.time.DateTime; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -/** Unit tests for {@link HostResource}. */ -class HostResourceTest extends EntityTestCase { +/** Unit tests for {@link Host}. */ +class HostTest extends EntityTestCase { private final DateTime day3 = fakeClock.nowUtc(); private final DateTime day2 = day3.minusDays(1); private final DateTime day1 = day2.minusDays(1); private Domain domain; - private HostResource host; + private Host host; @BeforeEach void setUp() { @@ -73,7 +73,7 @@ class HostResourceTest extends EntityTestCase { host = persistResource( cloneAndSetAutoTimestamps( - new HostResource.Builder() + new Host.Builder() .setRepoId("DEADBEEF-COM") .setHostName("ns1.example.com") .setCreationRegistrarId("thisRegistrar") @@ -87,15 +87,15 @@ class HostResourceTest extends EntityTestCase { } @Test - void testHostBaseToHostResource() { + void testHostBaseToHost() { ImmutableObjectSubject.assertAboutImmutableObjects() - .that(new HostResource.Builder().copyFrom(host).build()) + .that(new Host.Builder().copyFrom(host).build()) .isEqualExceptFields(host, "updateTimestamp", "revisions"); } @Test void testPersistence() { - HostResource newHost = host.asBuilder().setRepoId("NEWHOST").build(); + Host newHost = host.asBuilder().setRepoId("NEWHOST").build(); tm().transact(() -> tm().insert(newHost)); assertThat(ImmutableList.of(tm().transact(() -> tm().loadByKey(newHost.createVKey())))) .comparingElementsUsing(immutableObjectCorrespondence("revisions")) @@ -104,28 +104,28 @@ class HostResourceTest extends EntityTestCase { @Test void testSerializable() { - HostResource newHost = host.asBuilder().setRepoId("NEWHOST").build(); + Host newHost = host.asBuilder().setRepoId("NEWHOST").build(); tm().transact(() -> tm().insert(newHost)); - HostResource persisted = tm().transact(() -> tm().loadByEntity(newHost)); + Host persisted = tm().transact(() -> tm().loadByEntity(newHost)); assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted); } @Test void testEmptyStringsBecomeNull() { assertThat( - new HostResource.Builder() + new Host.Builder() .setPersistedCurrentSponsorRegistrarId(null) .build() .getPersistedCurrentSponsorRegistrarId()) .isNull(); assertThat( - new HostResource.Builder() + new Host.Builder() .setPersistedCurrentSponsorRegistrarId("") .build() .getPersistedCurrentSponsorRegistrarId()) .isNull(); assertThat( - new HostResource.Builder() + new Host.Builder() .setPersistedCurrentSponsorRegistrarId(" ") .build() .getPersistedCurrentSponsorRegistrarId()) @@ -134,11 +134,11 @@ class HostResourceTest extends EntityTestCase { @Test void testEmptySetsBecomeNull() { - assertThat(new HostResource.Builder().setInetAddresses(null).build().inetAddresses).isNull(); - assertThat(new HostResource.Builder().setInetAddresses(ImmutableSet.of()).build().inetAddresses) + assertThat(new Host.Builder().setInetAddresses(null).build().inetAddresses).isNull(); + assertThat(new Host.Builder().setInetAddresses(ImmutableSet.of()).build().inetAddresses) .isNull(); assertThat( - new HostResource.Builder() + new Host.Builder() .setInetAddresses(ImmutableSet.of(InetAddresses.forString("127.0.0.1"))) .build() .inetAddresses) @@ -148,20 +148,15 @@ class HostResourceTest extends EntityTestCase { @Test void testImplicitStatusValues() { // OK is implicit if there's no other statuses. - assertAboutHosts() - .that(new HostResource.Builder().build()) - .hasExactlyStatusValues(StatusValue.OK); + assertAboutHosts().that(new Host.Builder().build()).hasExactlyStatusValues(StatusValue.OK); // If there are other status values, OK should be suppressed. assertAboutHosts() - .that( - new HostResource.Builder() - .setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)) - .build()) + .that(new Host.Builder().setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD)).build()) .hasExactlyStatusValues(StatusValue.CLIENT_HOLD); // When OK is suppressed, it should be removed even if it was originally there. assertAboutHosts() .that( - new HostResource.Builder() + new Host.Builder() .setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD)) .build()) .hasExactlyStatusValues(StatusValue.CLIENT_HOLD); @@ -223,7 +218,7 @@ class HostResourceTest extends EntityTestCase { host = persistResource( cloneAndSetAutoTimestamps( - new HostResource.Builder() + new Host.Builder() .setCreationTime(day2) .setRepoId("DEADBEEF-COM") .setHostName("ns1.example.com") diff --git a/core/src/test/java/google/registry/model/index/ForeignKeyIndexTest.java b/core/src/test/java/google/registry/model/index/ForeignKeyIndexTest.java index df0329c85..6ba5020d5 100644 --- a/core/src/test/java/google/registry/model/index/ForeignKeyIndexTest.java +++ b/core/src/test/java/google/registry/model/index/ForeignKeyIndexTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistResource; import com.google.common.collect.ImmutableList; import google.registry.model.EntityTestCase; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex; import google.registry.testing.DatabaseHelper; import google.registry.testing.TestCacheExtension; @@ -56,25 +56,23 @@ class ForeignKeyIndexTest extends EntityTestCase { @Test void testLoadForNonexistentForeignKey_returnsNull() { - assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc())) - .isNull(); + assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull(); } @Test void testLoadForDeletedForeignKey_returnsNull() { - HostResource host = persistActiveHost("ns1.example.com"); + Host host = persistActiveHost("ns1.example.com"); if (tm().isOfy()) { persistResource(ForeignKeyIndex.create(host, fakeClock.nowUtc().minusDays(1))); } else { persistResource(host.asBuilder().setDeletionTime(fakeClock.nowUtc().minusDays(1)).build()); } - assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc())) - .isNull(); + assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull(); } @Test void testLoad_newerKeyHasBeenSoftDeleted() { - HostResource host1 = persistActiveHost("ns1.example.com"); + Host host1 = persistActiveHost("ns1.example.com"); fakeClock.advanceOneMilli(); if (tm().isOfy()) { ForeignKeyHostIndex fki = new ForeignKeyHostIndex(); @@ -85,14 +83,13 @@ class ForeignKeyIndexTest extends EntityTestCase { } else { persistResource(host1.asBuilder().setDeletionTime(fakeClock.nowUtc()).build()); } - assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", fakeClock.nowUtc())) - .isNull(); + assertThat(ForeignKeyIndex.load(Host.class, "ns1.example.com", fakeClock.nowUtc())).isNull(); } @Test void testBatchLoad_skipsDeletedAndNonexistent() { persistActiveHost("ns1.example.com"); - HostResource host = persistActiveHost("ns2.example.com"); + Host host = persistActiveHost("ns2.example.com"); if (tm().isOfy()) { persistResource(ForeignKeyIndex.create(host, fakeClock.nowUtc().minusDays(1))); } else { @@ -100,7 +97,7 @@ class ForeignKeyIndexTest extends EntityTestCase { } assertThat( ForeignKeyIndex.load( - HostResource.class, + Host.class, ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"), fakeClock.nowUtc()) .keySet()) @@ -110,7 +107,7 @@ class ForeignKeyIndexTest extends EntityTestCase { @Test void testDeadCodeThatDeletedScrapCommandsReference() { persistActiveHost("omg"); - assertThat(ForeignKeyIndex.load(HostResource.class, "omg", fakeClock.nowUtc()).getForeignKey()) + assertThat(ForeignKeyIndex.load(Host.class, "omg", fakeClock.nowUtc()).getForeignKey()) .isEqualTo("omg"); } } diff --git a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java index 966afd10d..b41770587 100644 --- a/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java +++ b/core/src/test/java/google/registry/model/reporting/Spec11ThreatMatchTest.java @@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableSet; import google.registry.model.EntityTestCase; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.transfer.ContactTransferData; import google.registry.persistence.VKey; import org.joda.time.LocalDate; @@ -45,7 +45,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase { private Spec11ThreatMatch threat; private Domain domain; - private HostResource host; + private Host host; private ContactResource registrantContact; Spec11ThreatMatchTest() { @@ -54,7 +54,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase { @BeforeEach void setUp() { - VKey hostVKey = VKey.createSql(HostResource.class, "host"); + VKey hostVKey = VKey.createSql(Host.class, "host"); VKey registrantContactVKey = VKey.createSql(ContactResource.class, "contact_id"); String domainRepoId = "4-TLD"; @@ -84,7 +84,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase { // Create a host for the purpose of testing a foreign key reference in the Domain table. */ host = - new HostResource.Builder() + new Host.Builder() .setRepoId("host") .setHostName("ns1.example.com") .setCreationRegistrarId(REGISTRAR_ID) diff --git a/core/src/test/java/google/registry/model/translators/StatusValueAdapterTest.java b/core/src/test/java/google/registry/model/translators/StatusValueAdapterTest.java index f8f652948..d78a4c4a0 100644 --- a/core/src/test/java/google/registry/model/translators/StatusValueAdapterTest.java +++ b/core/src/test/java/google/registry/model/translators/StatusValueAdapterTest.java @@ -36,7 +36,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; public class StatusValueAdapterTest { - // Needed to create HostResources. + // Needed to create Hosts. @RegisterExtension public AppEngineExtension appEngine = new AppEngineExtension.Builder().withCloudSql().build(); diff --git a/core/src/test/java/google/registry/persistence/VKeyTest.java b/core/src/test/java/google/registry/persistence/VKeyTest.java index 668df40da..f254ddd62 100644 --- a/core/src/test/java/google/registry/persistence/VKeyTest.java +++ b/core/src/test/java/google/registry/persistence/VKeyTest.java @@ -24,7 +24,7 @@ import com.googlecode.objectify.annotation.Entity; import google.registry.model.billing.BillingEvent.OneTime; import google.registry.model.common.ClassPathManager; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.RegistrarPoc; import google.registry.testing.AppEngineExtension; import google.registry.testing.TestObject; @@ -185,25 +185,15 @@ class VKeyTest { @Test void testCreate_stringifiedVKey_resourceKeyFromTaskQueue() throws Exception { - VKey vkeyFromNewWebsafeKey = + VKey vkeyFromNewWebsafeKey = VKey.create( - "kind:HostResource@sql:rO0ABXQADzZCQjJGNDc2LUdPT0dMRQ@ofy:ahdzfm" + "kind:Host@sql:rO0ABXQADzZCQjJGNDc2LUdPT0dMRQ@ofy:ahdzfm" + "RvbWFpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM"); assertThat(vkeyFromNewWebsafeKey.getSqlKey()).isEqualTo("6BB2F476-GOOGLE"); assertThat(vkeyFromNewWebsafeKey.getOfyKey().getString()) .isEqualTo( - "ahdzfmRvbWFpb" - + "i1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM"); - - // the ofy portion of the new vkey string representation was the old vkey string representation - VKey vkeyFromOldWebsafeString = - VKey.fromWebsafeKey( - "ahdzfmRvbW" - + "Fpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM"); - - // the following is assertion is ensure backwork compatibility - assertThat(vkeyFromNewWebsafeKey).isEqualTo(vkeyFromOldWebsafeString); + "ahdzfmRvbWFpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM"); } @Test diff --git a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java index ec3525440..7c6bb45e7 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainActionTest.java @@ -20,7 +20,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; @@ -31,7 +31,7 @@ import com.google.gson.JsonObject; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.Period; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; @@ -85,10 +85,10 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { "bog@cat.lol", clock.nowUtc().minusYears(3), registrarLol); - HostResource host1 = makeAndPersistHostResource( - "ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1)); - HostResource host2 = makeAndPersistHostResource( - "ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)); + Host host1 = makeAndPersistHost("ns1.cat.lol", "1.2.3.4", null, clock.nowUtc().minusYears(1)); + Host host2 = + makeAndPersistHost( + "ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)); persistResource( makeDomain( "cat.lol", @@ -104,8 +104,9 @@ class RdapDomainActionTest extends RdapActionBaseTestCase { .build()); // deleted domain in lol - HostResource hostDodo2 = makeAndPersistHostResource( - "ns2.dodo.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)); + Host hostDodo2 = + makeAndPersistHost( + "ns2.dodo.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)); Domain domainDeleted = persistResource( makeDomain( diff --git a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java index d56695be7..13c6568de 100644 --- a/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapDomainSearchActionTest.java @@ -24,7 +24,6 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; @@ -40,7 +39,7 @@ import com.google.gson.JsonObject; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.domain.Period; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; @@ -50,6 +49,7 @@ import google.registry.rdap.RdapMetrics.SearchType; import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.testing.FakeResponse; +import google.registry.testing.FullFieldsTestEntityHelper; import java.net.URLDecoder; import java.util.HashMap; import java.util.Optional; @@ -73,9 +73,9 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase hostNameToHostMap = new HashMap<>(); + private Host hostNs1CatLol; + private Host hostNs2CatLol; + private HashMap hostNameToHostMap = new HashMap<>(); enum RequestType { NONE, @@ -120,7 +120,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase> hostKeysBuilder = new ImmutableSet.Builder<>(); + ImmutableSet.Builder> hostKeysBuilder = new ImmutableSet.Builder<>(); ImmutableSet.Builder subordinateHostnamesBuilder = new ImmutableSet.Builder<>(); String mainDomainName = String.format("domain%d.lol", numTotalDomainsPerActiveDomain); for (int i = numHosts; i >= 1; i--) { String hostName = String.format("ns%d.%s", i, mainDomainName); subordinateHostnamesBuilder.add(hostName); - HostResource host = - makeAndPersistHostResource( + Host host = + FullFieldsTestEntityHelper.makeAndPersistHost( hostName, String.format("5.5.%d.%d", 5 + i / 250, i % 250), clock.nowUtc().minusYears(1)); hostKeysBuilder.add(host.createVKey()); } - ImmutableSet> hostKeys = hostKeysBuilder.build(); + ImmutableSet> hostKeys = hostKeysBuilder.build(); // Create all the domains at once, then persist them in parallel, for increased efficiency. ImmutableList.Builder domainsBuilder = new ImmutableList.Builder<>(); for (int i = numActiveDomains * numTotalDomainsPerActiveDomain; i >= 1; i--) { diff --git a/core/src/test/java/google/registry/rdap/RdapEntityActionTest.java b/core/src/test/java/google/registry/rdap/RdapEntityActionTest.java index 10e018cf0..1500847d4 100644 --- a/core/src/test/java/google/registry/rdap/RdapEntityActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapEntityActionTest.java @@ -23,7 +23,7 @@ import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistDeletedContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; -import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static org.mockito.Mockito.verify; @@ -31,7 +31,7 @@ import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; import com.google.gson.JsonObject; import google.registry.model.contact.ContactResource; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.SearchType; @@ -85,10 +85,8 @@ class RdapEntityActionTest extends RdapActionBaseTestCase { ImmutableList.of("1 Smiley Row", "Suite みんな"), clock.nowUtc(), registrarLol); - HostResource host1 = - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); - HostResource host2 = - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef")); + Host host1 = persistResource(makeHost("ns1.cat.lol", "1.2.3.4")); + Host host2 = persistResource(makeHost("ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef")); persistResource( makeDomain("cat.lol", registrant, adminContact, techContact, host1, host2, registrarLol)); // xn--q9jyb4c diff --git a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java index a995db723..a3607c32c 100644 --- a/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java +++ b/core/src/test/java/google/registry/rdap/RdapJsonFormatterTest.java @@ -21,7 +21,7 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistContactResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; +import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHost; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; @@ -37,7 +37,7 @@ import com.google.gson.JsonObject; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarPoc; @@ -72,12 +72,12 @@ class RdapJsonFormatterTest { private Registrar registrar; private Domain domainFull; private Domain domainNoNameserversNoTransfers; - private HostResource hostResourceIpv4; - private HostResource hostResourceIpv6; - private HostResource hostResourceBoth; - private HostResource hostResourceNoAddresses; - private HostResource hostResourceNotLinked; - private HostResource hostResourceSuperordinatePendingTransfer; + private Host hostIpv4; + private Host hostIpv6; + private Host hostBoth; + private Host hostNoAddresses; + private Host hostNotLinked; + private Host hostSuperordinatePendingTransfer; private ContactResource contactResourceRegistrant; private ContactResource contactResourceAdmin; private ContactResource contactResourceTech; @@ -128,32 +128,32 @@ class RdapJsonFormatterTest { ImmutableList.of("Somewhere", "Over the Rainbow"), clock.nowUtc().minusYears(4), registrar); - hostResourceIpv4 = - makeAndPersistHostResource( + hostIpv4 = + makeAndPersistHost( "ns1.cat.みんな", "1.2.3.4", null, clock.nowUtc().minusYears(1), "unicoderegistrar"); - hostResourceIpv6 = - makeAndPersistHostResource( + hostIpv6 = + makeAndPersistHost( "ns2.cat.みんな", "bad:f00d:cafe:0:0:0:15:beef", null, clock.nowUtc().minusYears(2), "unicoderegistrar"); - hostResourceBoth = - makeAndPersistHostResource( + hostBoth = + makeAndPersistHost( "ns3.cat.みんな", "1.2.3.4", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(3), "unicoderegistrar"); - hostResourceNoAddresses = - makeAndPersistHostResource( + hostNoAddresses = + makeAndPersistHost( "ns4.cat.みんな", null, null, clock.nowUtc().minusYears(4), "unicoderegistrar"); - hostResourceNotLinked = - makeAndPersistHostResource( + hostNotLinked = + makeAndPersistHost( "ns5.cat.みんな", null, null, clock.nowUtc().minusYears(5), "unicoderegistrar"); - hostResourceSuperordinatePendingTransfer = + hostSuperordinatePendingTransfer = persistResource( - makeAndPersistHostResource( + makeAndPersistHost( "ns1.dog.みんな", null, null, clock.nowUtc().minusYears(6), "unicoderegistrar") .asBuilder() .setSuperordinateDomain( @@ -189,8 +189,8 @@ class RdapJsonFormatterTest { contactResourceRegistrant, contactResourceAdmin, contactResourceTech, - hostResourceIpv4, - hostResourceIpv6, + hostIpv4, + hostIpv6, registrar) .asBuilder() .setCreationTimeForTest(clock.nowUtc().minusMonths(4)) @@ -210,7 +210,7 @@ class RdapJsonFormatterTest { .setCreationTimeForTest(clock.nowUtc()) .setLastEppUpdateTime(null) .build()); - // Create an unused domain that references hostResourceBoth and hostResourceNoAddresses so that + // Create an unused domain that references hostBoth and hostNoAddresses so that // they will have "associated" (ie, StatusValue.LINKED) status. persistResource( makeDomain( @@ -218,8 +218,8 @@ class RdapJsonFormatterTest { contactResourceRegistrant, contactResourceAdmin, contactResourceTech, - hostResourceBoth, - hostResourceNoAddresses, + hostBoth, + hostNoAddresses, registrar)); // history entries @@ -317,49 +317,38 @@ class RdapJsonFormatterTest { @Test void testHost_ipv4() { - assertThat( - rdapJsonFormatter.createRdapNameserver(hostResourceIpv4, OutputDataType.FULL).toJson()) + assertThat(rdapJsonFormatter.createRdapNameserver(hostIpv4, OutputDataType.FULL).toJson()) .isEqualTo(loadJson("rdapjson_host_ipv4.json")); } @Test void testHost_ipv6() { - assertThat( - rdapJsonFormatter.createRdapNameserver(hostResourceIpv6, OutputDataType.FULL).toJson()) + assertThat(rdapJsonFormatter.createRdapNameserver(hostIpv6, OutputDataType.FULL).toJson()) .isEqualTo(loadJson("rdapjson_host_ipv6.json")); } @Test void testHost_both() { - assertThat( - rdapJsonFormatter.createRdapNameserver(hostResourceBoth, OutputDataType.FULL).toJson()) + assertThat(rdapJsonFormatter.createRdapNameserver(hostBoth, OutputDataType.FULL).toJson()) .isEqualTo(loadJson("rdapjson_host_both.json")); } @Test void testHost_both_summary() { - assertThat( - rdapJsonFormatter - .createRdapNameserver(hostResourceBoth, OutputDataType.SUMMARY) - .toJson()) + assertThat(rdapJsonFormatter.createRdapNameserver(hostBoth, OutputDataType.SUMMARY).toJson()) .isEqualTo(loadJson("rdapjson_host_both_summary.json")); } @Test void testHost_noAddresses() { assertThat( - rdapJsonFormatter - .createRdapNameserver(hostResourceNoAddresses, OutputDataType.FULL) - .toJson()) + rdapJsonFormatter.createRdapNameserver(hostNoAddresses, OutputDataType.FULL).toJson()) .isEqualTo(loadJson("rdapjson_host_no_addresses.json")); } @Test void testHost_notLinked() { - assertThat( - rdapJsonFormatter - .createRdapNameserver(hostResourceNotLinked, OutputDataType.FULL) - .toJson()) + assertThat(rdapJsonFormatter.createRdapNameserver(hostNotLinked, OutputDataType.FULL).toJson()) .isEqualTo(loadJson("rdapjson_host_not_linked.json")); } @@ -367,7 +356,7 @@ class RdapJsonFormatterTest { void testHost_superordinateHasPendingTransfer() { assertThat( rdapJsonFormatter - .createRdapNameserver(hostResourceSuperordinatePendingTransfer, OutputDataType.FULL) + .createRdapNameserver(hostSuperordinatePendingTransfer, OutputDataType.FULL) .toJson()) .isEqualTo(loadJson("rdapjson_host_pending_transfer.json")); } diff --git a/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java b/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java index 9a62ea8ff..60d9d79db 100644 --- a/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapNameserverActionTest.java @@ -19,7 +19,6 @@ import static google.registry.rdap.RdapTestHelper.assertThat; import static google.registry.rdap.RdapTestHelper.loadJsonFile; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static org.mockito.Mockito.verify; @@ -31,6 +30,7 @@ import google.registry.rdap.RdapMetrics.SearchType; import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.request.Action; +import google.registry.testing.FullFieldsTestEntityHelper; import java.util.Optional; import javax.annotation.Nullable; import org.junit.jupiter.api.BeforeEach; @@ -47,19 +47,20 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase", Registrar.State.ACTIVE, 102L)); // external - makeAndPersistHostResource("ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1)); + FullFieldsTestEntityHelper.makeAndPersistHost( + "ns1.domain.external", "9.10.11.12", clock.nowUtc().minusYears(1)); } private JsonObject generateExpectedJson( diff --git a/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java b/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java index fdcb9946a..9ff08af5e 100644 --- a/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java +++ b/core/src/test/java/google/registry/rdap/RdapNameserverSearchActionTest.java @@ -23,10 +23,8 @@ import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistResources; import static google.registry.testing.DatabaseHelper.persistSimpleResources; -import static google.registry.testing.FullFieldsTestEntityHelper.makeAndPersistHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; -import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; @@ -37,13 +35,14 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.rdap.RdapMetrics.EndpointType; import google.registry.rdap.RdapMetrics.SearchType; import google.registry.rdap.RdapMetrics.WildcardType; import google.registry.rdap.RdapSearchResults.IncompletenessWarningType; import google.registry.testing.FakeResponse; +import google.registry.testing.FullFieldsTestEntityHelper; import java.net.URLDecoder; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; @@ -57,8 +56,8 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase", Registrar.State.ACTIVE)); persistSimpleResources(makeRegistrarContacts(registrar)); hostNs1CatLol = - makeAndPersistHostResource("ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)); + FullFieldsTestEntityHelper.makeAndPersistHost( + "ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1)); hostNs2CatLol = - makeAndPersistHostResource( + FullFieldsTestEntityHelper.makeAndPersistHost( "ns2.cat.lol", "bad:f00d:cafe::15:beef", clock.nowUtc().minusYears(1)); - makeAndPersistHostResource( + FullFieldsTestEntityHelper.makeAndPersistHost( "ns1.cat2.lol", "1.2.3.3", "bad:f00d:cafe::15:beef", clock.nowUtc().minusYears(1)); - makeAndPersistHostResource("ns1.cat.external", null, null, clock.nowUtc().minusYears(1)); + FullFieldsTestEntityHelper.makeAndPersistHost( + "ns1.cat.external", null, null, clock.nowUtc().minusYears(1)); // cat.みんな createTld("xn--q9jyb4c"); registrar = persistResource(makeRegistrar("unicoderegistrar", "みんな", Registrar.State.ACTIVE)); persistSimpleResources(makeRegistrarContacts(registrar)); - makeAndPersistHostResource("ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1)); + FullFieldsTestEntityHelper.makeAndPersistHost( + "ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1)); // cat.1.test createTld("1.test"); registrar = persistResource(makeRegistrar("multiregistrar", "1.test", Registrar.State.ACTIVE)); persistSimpleResources(makeRegistrarContacts(registrar)); - makeAndPersistHostResource("ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1)); + FullFieldsTestEntityHelper.makeAndPersistHost( + "ns1.cat.1.test", "1.2.3.6", clock.nowUtc().minusYears(1)); // create a domain so that we can use it as a test nameserver search string suffix domainCatLol = @@ -178,12 +181,12 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase hostsBuilder = new ImmutableList.Builder<>(); + ImmutableList.Builder hostsBuilder = new ImmutableList.Builder<>(); ImmutableSet.Builder subordinateHostsBuilder = new ImmutableSet.Builder<>(); for (int i = 1; i <= numHosts; i++) { String hostName = String.format("nsx%d.cat.lol", i); subordinateHostsBuilder.add(hostName); - hostsBuilder.add(makeHostResource(hostName, "5.5.5.1", "5.5.5.2")); + hostsBuilder.add(FullFieldsTestEntityHelper.makeHost(hostName, "5.5.5.1", "5.5.5.2")); } persistResources(hostsBuilder.build()); domainCatLol = @@ -193,7 +196,8 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCaseThis tests the mapping between {@link HostResource} and {@link XjcRdeHost} as well as some - * exceptional conditions. + *

This tests the mapping between {@link Host} and {@link XjcRdeHost} as well as some exceptional + * conditions. */ -public class HostResourceToXjcConverterTest { +public class HostToXjcConverterTest { @RegisterExtension public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build(); @@ -63,8 +63,8 @@ public class HostResourceToXjcConverterTest { .addStatusValue(StatusValue.PENDING_TRANSFER) .build(); XjcRdeHost bean = - HostResourceToXjcConverter.convertSubordinateHost( - new HostResource.Builder() + HostToXjcConverter.convertSubordinateHost( + new Host.Builder() .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") @@ -119,8 +119,8 @@ public class HostResourceToXjcConverterTest { @Test void testConvertExternalHost() { XjcRdeHost bean = - HostResourceToXjcConverter.convertExternalHost( - new HostResource.Builder() + HostToXjcConverter.convertExternalHost( + new Host.Builder() .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") @@ -168,8 +168,8 @@ public class HostResourceToXjcConverterTest { @Test void testConvertExternalHost_ipv6() { XjcRdeHost bean = - HostResourceToXjcConverter.convertExternalHost( - new HostResource.Builder() + HostToXjcConverter.convertExternalHost( + new Host.Builder() .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") @@ -191,8 +191,8 @@ public class HostResourceToXjcConverterTest { assertThrows( IllegalArgumentException.class, () -> - HostResourceToXjcConverter.convertExternalHost( - new HostResource.Builder() + HostToXjcConverter.convertExternalHost( + new Host.Builder() .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") @@ -210,8 +210,8 @@ public class HostResourceToXjcConverterTest { void testMarshal() throws Exception { // Bean! Bean! Bean! XjcRdeHostElement bean = - HostResourceToXjcConverter.convertExternal( - new HostResource.Builder() + HostToXjcConverter.convertExternal( + new Host.Builder() .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z")) .setPersistedCurrentSponsorRegistrarId("BusinessCat") diff --git a/core/src/test/java/google/registry/rde/RdeFixtures.java b/core/src/test/java/google/registry/rde/RdeFixtures.java index 356ba5738..42a4ecbf5 100644 --- a/core/src/test/java/google/registry/rde/RdeFixtures.java +++ b/core/src/test/java/google/registry/rde/RdeFixtures.java @@ -42,7 +42,7 @@ import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.poll.PollMessage; import google.registry.model.poll.PollMessage.Autorenew; import google.registry.model.reporting.HistoryEntry; @@ -121,8 +121,8 @@ final class RdeFixtures { .setIdnTableName("extended_latin") .setNameservers( ImmutableSet.of( - makeHostResource(clock, "bird.or.devil.みんな", "1.2.3.4").createVKey(), - makeHostResource(clock, "ns2.cat.みんな", "bad:f00d:cafe::15:beef").createVKey())) + makeHost(clock, "bird.or.devil.みんな", "1.2.3.4").createVKey(), + makeHost(clock, "ns2.cat.みんな", "bad:f00d:cafe::15:beef").createVKey())) .setRegistrationExpirationTime(DateTime.parse("1994-01-01T00:00:00Z")) .setGracePeriods( ImmutableSet.of( @@ -253,10 +253,10 @@ final class RdeFixtures { .build()); } - static HostResource makeHostResource(FakeClock clock, String fqhn, String ip) { + static Host makeHost(FakeClock clock, String fqhn, String ip) { clock.advanceOneMilli(); return persistResource( - new HostResource.Builder() + new Host.Builder() .setRepoId(generateNewContactHostRoid()) .setCreationRegistrarId("LawyerCat") .setCreationTimeForTest(clock.nowUtc()) diff --git a/core/src/test/java/google/registry/rde/RdeTestSuite.java b/core/src/test/java/google/registry/rde/RdeTestSuite.java index 33dcfe70e..417b0a993 100644 --- a/core/src/test/java/google/registry/rde/RdeTestSuite.java +++ b/core/src/test/java/google/registry/rde/RdeTestSuite.java @@ -26,7 +26,7 @@ import org.junit.runner.RunWith; DomainToXjcConverterTest.class, GhostrydeGpgIntegrationTest.class, GhostrydeTest.class, - HostResourceToXjcConverterTest.class, + HostToXjcConverterTest.class, RdeStagingActionTest.class, RdeUploadActionTest.class, RdeReportActionTest.class, diff --git a/core/src/test/java/google/registry/reporting/spec11/Spec11EmailUtilsTest.java b/core/src/test/java/google/registry/reporting/spec11/Spec11EmailUtilsTest.java index 0c5bdba12..4da3c1e0b 100644 --- a/core/src/test/java/google/registry/reporting/spec11/Spec11EmailUtilsTest.java +++ b/core/src/test/java/google/registry/reporting/spec11/Spec11EmailUtilsTest.java @@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.MediaType; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -121,7 +121,7 @@ class Spec11EmailUtilsTest { "Super Cool Registry"); createTld("com"); - HostResource host = persistActiveHost("ns1.example.com"); + Host host = persistActiveHost("ns1.example.com"); aDomain = persistDomainWithHost("a.com", host); bDomain = persistDomainWithHost("b.com", host); persistDomainWithHost("c.com", host); @@ -238,7 +238,7 @@ class Spec11EmailUtilsTest { void testSuccess_dealsWithDeletedDomains() throws Exception { // Create an inactive domain and an active domain with the same name. persistResource(loadByEntity(aDomain).asBuilder().addStatusValue(SERVER_HOLD).build()); - HostResource host = persistActiveHost("ns1.example.com"); + Host host = persistActiveHost("ns1.example.com"); aDomain = persistDomainWithHost("a.com", host); emailUtils.emailSpec11Reports( @@ -408,7 +408,7 @@ class Spec11EmailUtilsTest { assertThat(message).isEqualTo(expectedContentBuilder.build()); } - private static Domain persistDomainWithHost(String domainName, HostResource host) { + private static Domain persistDomainWithHost(String domainName, Host host) { return persistResource( DatabaseHelper.newDomain(domainName) .asBuilder() diff --git a/core/src/test/java/google/registry/testing/DatabaseHelper.java b/core/src/test/java/google/registry/testing/DatabaseHelper.java index 46e42f4b8..4b75e9fa9 100644 --- a/core/src/test/java/google/registry/testing/DatabaseHelper.java +++ b/core/src/test/java/google/registry/testing/DatabaseHelper.java @@ -88,7 +88,7 @@ import google.registry.model.domain.token.AllocationToken; import google.registry.model.eppcommon.AuthInfo.PasswordAuth; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.index.EppResourceIndex; import google.registry.model.index.EppResourceIndexBucket; import google.registry.model.index.ForeignKeyIndex; @@ -154,12 +154,12 @@ public class DatabaseHelper { } } - public static HostResource newHostResource(String hostName) { - return newHostResourceWithRoid(hostName, generateNewContactHostRoid()); + public static Host newHost(String hostName) { + return newHostWithRoid(hostName, generateNewContactHostRoid()); } - public static HostResource newHostResourceWithRoid(String hostName, String repoId) { - return new HostResource.Builder() + public static Host newHostWithRoid(String hostName, String repoId) { + return new Host.Builder() .setHostName(hostName) .setCreationRegistrarId("TheRegistrar") .setPersistedCurrentSponsorRegistrarId("TheRegistrar") @@ -177,9 +177,9 @@ public class DatabaseHelper { return newDomain(domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact); } - public static Domain newDomain(String domainName, HostResource... hosts) { - ImmutableSet> hostKeys = - Arrays.stream(hosts).map(HostResource::createVKey).collect(toImmutableSet()); + public static Domain newDomain(String domainName, Host... hosts) { + ImmutableSet> hostKeys = + Arrays.stream(hosts).map(Host::createVKey).collect(toImmutableSet()); return newDomain(domainName).asBuilder().setNameservers(hostKeys).build(); } @@ -269,15 +269,14 @@ public class DatabaseHelper { newContactResource(contactId).asBuilder().setDeletionTime(deletionTime).build()); } - public static HostResource persistActiveHost(String hostName) { - return persistResource(newHostResource(hostName)); + public static Host persistActiveHost(String hostName) { + return persistResource(newHost(hostName)); } - public static HostResource persistActiveSubordinateHost( - String hostName, Domain superordinateDomain) { + public static Host persistActiveSubordinateHost(String hostName, Domain superordinateDomain) { checkNotNull(superordinateDomain); return persistResource( - newHostResource(hostName) + newHost(hostName) .asBuilder() .setSuperordinateDomain(superordinateDomain.createVKey()) .setInetAddresses( @@ -286,9 +285,8 @@ public class DatabaseHelper { } /** Persists a host resource with the given hostname deleted at the specified time. */ - public static HostResource persistDeletedHost(String hostName, DateTime deletionTime) { - return persistResource( - newHostResource(hostName).asBuilder().setDeletionTime(deletionTime).build()); + public static Host persistDeletedHost(String hostName, DateTime deletionTime) { + return persistResource(newHost(hostName).asBuilder().setDeletionTime(deletionTime).build()); } public static Domain persistActiveDomain(String domainName) { @@ -484,8 +482,7 @@ public class DatabaseHelper { .forEach( hostname -> deleteResource( - EppResourceUtils.loadByForeignKey(HostResource.class, hostname, now) - .get())); + EppResourceUtils.loadByForeignKey(Host.class, hostname, now).get())); for (HistoryEntry hist : historyEntries) { deleteResource(hist); } @@ -1158,7 +1155,7 @@ public class DatabaseHelper { return resource.getRepoId() != null ? HistoryEntry.Type.CONTACT_CREATE : HistoryEntry.Type.CONTACT_UPDATE; - } else if (resource instanceof HostResource) { + } else if (resource instanceof Host) { return resource.getRepoId() != null ? HistoryEntry.Type.HOST_CREATE : HistoryEntry.Type.HOST_UPDATE; diff --git a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java index 449fbde93..81b36a1a4 100644 --- a/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java +++ b/core/src/test/java/google/registry/testing/FullFieldsTestEntityHelper.java @@ -34,7 +34,7 @@ import google.registry.model.domain.Period; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarAddress; import google.registry.model.registrar.RegistrarPoc; @@ -125,19 +125,18 @@ public final class FullFieldsTestEntityHelper { .build()); } - public static HostResource makeHostResource(String fqhn, String ip) { - return makeHostResource(fqhn, ip, null); + public static Host makeHost(String fqhn, String ip) { + return makeHost(fqhn, ip, null); } - public static HostResource makeHostResource( - String fqhn, @Nullable String ip1, @Nullable String ip2) { - return makeHostResource(fqhn, ip1, ip2, "TheRegistrar"); + public static Host makeHost(String fqhn, @Nullable String ip1, @Nullable String ip2) { + return makeHost(fqhn, ip1, ip2, "TheRegistrar"); } - public static HostResource makeHostResource( + public static Host makeHost( String fqhn, @Nullable String ip1, @Nullable String ip2, String registrarClientId) { - HostResource.Builder builder = - new HostResource.Builder() + Host.Builder builder = + new Host.Builder() .setRepoId(generateNewContactHostRoid()) .setHostName(Idn.toASCII(fqhn)) .setCreationTimeForTest(DateTime.parse("2000-10-08T00:45:00Z")) @@ -155,29 +154,28 @@ public final class FullFieldsTestEntityHelper { return builder.build(); } - public static HostResource makeAndPersistHostResource( + public static Host makeAndPersistHost( String fqhn, @Nullable String ip, @Nullable DateTime creationTime) { - return makeAndPersistHostResource(fqhn, ip, null, creationTime); + return makeAndPersistHost(fqhn, ip, null, creationTime); } - public static HostResource makeAndPersistHostResource( + public static Host makeAndPersistHost( String fqhn, @Nullable String ip1, @Nullable String ip2, @Nullable DateTime creationTime) { - return makeAndPersistHostResource(fqhn, ip1, ip2, creationTime, "TheRegistrar"); + return makeAndPersistHost(fqhn, ip1, ip2, creationTime, "TheRegistrar"); } - public static HostResource makeAndPersistHostResource( + public static Host makeAndPersistHost( String fqhn, @Nullable String ip1, @Nullable String ip2, @Nullable DateTime creationTime, String registrarClientId) { - HostResource hostResource = - persistResource(makeHostResource(fqhn, ip1, ip2, registrarClientId)); + Host host = persistResource(makeHost(fqhn, ip1, ip2, registrarClientId)); if (creationTime != null) { - persistResource(makeHistoryEntry( - hostResource, HistoryEntry.Type.HOST_CREATE, null, "created", creationTime)); + persistResource( + makeHistoryEntry(host, HistoryEntry.Type.HOST_CREATE, null, "created", creationTime)); } - return hostResource; + return host; } public static ContactResource makeContactResource( @@ -335,8 +333,8 @@ public final class FullFieldsTestEntityHelper { @Nullable ContactResource registrant, @Nullable ContactResource admin, @Nullable ContactResource tech, - @Nullable HostResource ns1, - @Nullable HostResource ns2, + @Nullable Host ns1, + @Nullable Host ns2, Registrar registrar) { Domain.Builder builder = new Domain.Builder() @@ -370,7 +368,7 @@ public final class FullFieldsTestEntityHelper { builder.setContacts(contactsBuilder.build()); } if ((ns1 != null) || (ns2 != null)) { - ImmutableSet.Builder> nsBuilder = new ImmutableSet.Builder<>(); + ImmutableSet.Builder> nsBuilder = new ImmutableSet.Builder<>(); if (ns1 != null) { nsBuilder.add(ns1.createVKey()); } diff --git a/core/src/test/java/google/registry/testing/HostResourceSubject.java b/core/src/test/java/google/registry/testing/HostSubject.java similarity index 64% rename from core/src/test/java/google/registry/testing/HostResourceSubject.java rename to core/src/test/java/google/registry/testing/HostSubject.java index e9413ee41..a9129b09a 100644 --- a/core/src/test/java/google/registry/testing/HostResourceSubject.java +++ b/core/src/test/java/google/registry/testing/HostSubject.java @@ -20,44 +20,42 @@ import static com.google.common.truth.Truth.assertAbout; import com.google.common.truth.FailureMetadata; import com.google.common.truth.SimpleSubjectBuilder; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.testing.TruthChainer.And; import javax.annotation.Nullable; import org.joda.time.DateTime; -/** Truth subject for asserting things about {@link HostResource} instances. */ -public final class HostResourceSubject - extends AbstractEppResourceSubject { +/** Truth subject for asserting things about {@link Host} instances. */ +public final class HostSubject extends AbstractEppResourceSubject { - private final HostResource actual; + private final Host actual; - public HostResourceSubject(FailureMetadata failureMetadata, HostResource subject) { + public HostSubject(FailureMetadata failureMetadata, Host subject) { super(failureMetadata, checkNotNull(subject)); this.actual = subject; } - public static SimpleSubjectBuilder assertAboutHosts() { - return assertAbout(HostResourceSubject::new); + public static SimpleSubjectBuilder assertAboutHosts() { + return assertAbout(HostSubject::new); } - public And hasLastTransferTime(DateTime lastTransferTime) { + public And hasLastTransferTime(DateTime lastTransferTime) { return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime"); } - public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { + public And hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) { return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime"); } - public And hasLastSuperordinateChange(DateTime lastSuperordinateChange) { + public And hasLastSuperordinateChange(DateTime lastSuperordinateChange) { return hasValue( lastSuperordinateChange, actual.getLastSuperordinateChange(), "has lastSuperordinateChange"); } - public And hasSuperordinateDomain( - @Nullable VKey superordinateDomain) { + public And hasSuperordinateDomain(@Nullable VKey superordinateDomain) { return hasValue( superordinateDomain, actual.getSuperordinateDomain(), "has superordinateDomain"); } diff --git a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java index d8df821fa..0e0b2e0a0 100644 --- a/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java +++ b/core/src/test/java/google/registry/tools/DomainLockUtilsTest.java @@ -40,7 +40,7 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.RegistryLock; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; import google.registry.testing.AppEngineExtension; @@ -87,7 +87,7 @@ public final class DomainLockUtilsTest { @BeforeEach void setup() { createTlds("tld", "net"); - HostResource host = persistActiveHost("ns1.example.net"); + Host host = persistActiveHost("ns1.example.net"); domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host)); domainLockUtils = diff --git a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java index 40f04da57..3106d0c8f 100644 --- a/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java +++ b/core/src/test/java/google/registry/tools/GenerateDnsReportCommandTest.java @@ -17,7 +17,7 @@ package google.registry.tools; import static com.google.common.io.BaseEncoding.base16; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; import static google.registry.testing.DatabaseHelper.persistResource; @@ -34,7 +34,7 @@ import com.google.common.net.InetAddresses; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.testing.DatabaseHelper; import google.registry.testing.FakeClock; import java.io.IOException; @@ -61,10 +61,10 @@ class GenerateDnsReportCommandTest extends CommandTestCase DS_DATA_OUTPUT = ImmutableList.of( @@ -121,20 +121,24 @@ class GenerateDnsReportCommandTest extends CommandTestCase { assertInStdout("fullyQualifiedHostName=ns1.example.tld"); assertInStdout( "Websafe key: " - + "kind:HostResource" + + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA" - + "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw"); + + "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM"); } @Test @@ -56,9 +56,9 @@ class GetHostCommandTest extends CommandTestCase { assertInStdout("fullyQualifiedHostName=ns1.example.tld"); assertInStdout( "Websafe key: " - + "kind:HostResource" + + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA" - + "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw"); + + "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM"); assertNotInStdout("LiveRef"); } @@ -71,14 +71,14 @@ class GetHostCommandTest extends CommandTestCase { assertInStdout("fullyQualifiedHostName=ns2.example.tld"); assertInStdout( "Websafe key: " - + "kind:HostResource" + + "kind:Host" + "@sql:rO0ABXQABjItUk9JRA" - + "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw"); + + "@ofy:agR0ZXN0chALEgRIb3N0IgYyLVJPSUQM"); assertInStdout( "Websafe key: " - + "kind:HostResource" - + "@sql:rO0ABXQABjItUk9JRA" - + "@ofy:agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjItUk9JRAw"); + + "kind:Host" + + "@sql:rO0ABXQABjMtUk9JRA" + + "@ofy:agR0ZXN0chALEgRIb3N0IgYzLVJPSUQM"); } @Test @@ -107,9 +107,7 @@ class GetHostCommandTest extends CommandTestCase { @Test void testSuccess_hostDeletedInFuture() throws Exception { persistResource( - newHostResource("ns1.example.tld").asBuilder() - .setDeletionTime(now.plusDays(1)) - .build()); + newHost("ns1.example.tld").asBuilder().setDeletionTime(now.plusDays(1)).build()); runCommand("ns1.example.tld", "--read_timestamp=" + now.plusMonths(1)); assertInStdout("Host 'ns1.example.tld' does not exist or is deleted"); } diff --git a/core/src/test/java/google/registry/tools/MutatingCommandTest.java b/core/src/test/java/google/registry/tools/MutatingCommandTest.java index 99d6636c0..c8f66063f 100644 --- a/core/src/test/java/google/registry/tools/MutatingCommandTest.java +++ b/core/src/test/java/google/registry/tools/MutatingCommandTest.java @@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import com.google.common.collect.ImmutableList; import com.googlecode.objectify.Key; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.persistence.VKey; import google.registry.testing.AppEngineExtension; @@ -50,10 +50,10 @@ public class MutatingCommandTest { private Registrar registrar2; private Registrar newRegistrar1; private Registrar newRegistrar2; - private HostResource host1; - private HostResource host2; - private HostResource newHost1; - private HostResource newHost2; + private Host host1; + private Host host2; + private Host newHost1; + private Host newHost2; @BeforeEach void beforeEach() { @@ -97,10 +97,10 @@ public class MutatingCommandTest { String changes = command.prompt(); assertThat(changes) .isEqualTo( - "Update HostResource@2-ROID\n" + "Update Host@2-ROID\n" + "lastEppUpdateTime: null -> 2014-09-09T09:09:09.000Z\n" + "\n" - + "Update HostResource@3-ROID\n" + + "Update Host@3-ROID\n" + "currentSponsorClientId: TheRegistrar -> Registrar2\n" + "\n" + "Update Registrar@Registrar1\n" @@ -134,18 +134,23 @@ public class MutatingCommandTest { }; command.init(); String changes = command.prompt(); - assertThat(changes).isEqualTo( - "Create HostResource@2-ROID\n" - + newHost1 + "\n" - + "\n" - + "Create HostResource@3-ROID\n" - + newHost2 + "\n" - + "\n" - + "Create Registrar@Registrar1\n" - + newRegistrar1 + "\n" - + "\n" - + "Create Registrar@Registrar2\n" - + newRegistrar2 + "\n"); + assertThat(changes) + .isEqualTo( + "Create Host@2-ROID\n" + + newHost1 + + "\n" + + "\n" + + "Create Host@3-ROID\n" + + newHost2 + + "\n" + + "\n" + + "Create Registrar@Registrar1\n" + + newRegistrar1 + + "\n" + + "\n" + + "Create Registrar@Registrar2\n" + + newRegistrar2 + + "\n"); String results = command.execute(); assertThat(results).isEqualTo("Updated 4 entities.\n"); assertThat(loadByEntity(newHost1)).isEqualTo(newHost1); @@ -167,18 +172,23 @@ public class MutatingCommandTest { }; command.init(); String changes = command.prompt(); - assertThat(changes).isEqualTo( - "Delete HostResource@2-ROID\n" - + host1 + "\n" - + "\n" - + "Delete HostResource@3-ROID\n" - + host2 + "\n" - + "\n" - + "Delete Registrar@Registrar1\n" - + registrar1 + "\n" - + "\n" - + "Delete Registrar@Registrar2\n" - + registrar2 + "\n"); + assertThat(changes) + .isEqualTo( + "Delete Host@2-ROID\n" + + host1 + + "\n" + + "\n" + + "Delete Host@3-ROID\n" + + host2 + + "\n" + + "\n" + + "Delete Registrar@Registrar1\n" + + registrar1 + + "\n" + + "\n" + + "Delete Registrar@Registrar2\n" + + registrar2 + + "\n"); String results = command.execute(); assertThat(results).isEqualTo("Updated 4 entities.\n"); assertThat(existsInDb(host1)).isFalse(); @@ -199,12 +209,13 @@ public class MutatingCommandTest { command.init(); String changes = command.prompt(); System.out.println(changes); - assertThat(changes).isEqualTo( - "Update HostResource@2-ROID\n" - + "[no changes]\n" - + "\n" - + "Update Registrar@Registrar1\n" - + "[no changes]\n"); + assertThat(changes) + .isEqualTo( + "Update Host@2-ROID\n" + + "[no changes]\n" + + "\n" + + "Update Registrar@Registrar1\n" + + "[no changes]\n"); String results = command.execute(); assertThat(results).isEqualTo("Updated 2 entities.\n"); assertThat(loadByEntity(host1)).isEqualTo(host1); @@ -227,18 +238,21 @@ public class MutatingCommandTest { }; command.init(); String changes = command.prompt(); - assertThat(changes).isEqualTo( - "Delete HostResource@2-ROID\n" - + host1 + "\n" - + "\n" - + "Update HostResource@3-ROID\n" - + "currentSponsorClientId: TheRegistrar -> Registrar2\n" - + "\n" - + "Delete Registrar@Registrar1\n" - + registrar1 + "\n" - + "\n" - + "Update Registrar@Registrar2\n" - + "blockPremiumNames: false -> true\n"); + assertThat(changes) + .isEqualTo( + "Delete Host@2-ROID\n" + + host1 + + "\n" + + "\n" + + "Update Host@3-ROID\n" + + "currentSponsorClientId: TheRegistrar -> Registrar2\n" + + "\n" + + "Delete Registrar@Registrar1\n" + + registrar1 + + "\n" + + "\n" + + "Update Registrar@Registrar2\n" + + "blockPremiumNames: false -> true\n"); String results = command.execute(); assertThat(results).isEqualTo("Updated 4 entities.\n"); assertThat(existsInDb(host1)).isFalse(); @@ -267,18 +281,21 @@ public class MutatingCommandTest { // resource has been updated since the command inited the resources to process. registrar2 = persistResource(registrar2.asBuilder().setContactsRequireSyncing(false).build()); String changes = command.prompt(); - assertThat(changes).isEqualTo( - "Delete HostResource@2-ROID\n" - + host1 + "\n" - + "\n" - + "Update HostResource@3-ROID\n" - + "currentSponsorClientId: TheRegistrar -> Registrar2\n" - + "\n" - + "Delete Registrar@Registrar1\n" - + registrar1 + "\n" - + "\n" - + "Update Registrar@Registrar2\n" - + "blockPremiumNames: false -> true\n"); + assertThat(changes) + .isEqualTo( + "Delete Host@2-ROID\n" + + host1 + + "\n" + + "\n" + + "Update Host@3-ROID\n" + + "currentSponsorClientId: TheRegistrar -> Registrar2\n" + + "\n" + + "Delete Registrar@Registrar1\n" + + registrar1 + + "\n" + + "\n" + + "Update Registrar@Registrar2\n" + + "blockPremiumNames: false -> true\n"); IllegalStateException thrown = assertThrows(IllegalStateException.class, command::execute); assertThat(thrown).hasMessageThat().contains("Entity changed since init() was called."); diff --git a/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java b/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java index 80a711ee0..2d232519a 100644 --- a/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java +++ b/core/src/test/java/google/registry/tools/UniformRapidSuspensionCommandTest.java @@ -27,7 +27,7 @@ import com.google.common.collect.ImmutableSet; import google.registry.model.domain.Domain; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; import javax.xml.bind.annotation.adapters.HexBinaryAdapter; @@ -39,10 +39,10 @@ import org.junit.jupiter.api.Test; class UniformRapidSuspensionCommandTest extends EppToolCommandTestCase { - private HostResource ns1; - private HostResource ns2; - private HostResource urs1; - private HostResource urs2; + private Host ns1; + private Host ns2; + private Host urs1; + private Host urs2; private Domain defaultDomain; private ImmutableSet defaultDsData; @@ -63,9 +63,9 @@ class UniformRapidSuspensionCommandTest } private void persistDomainWithHosts( - Domain domain, ImmutableSet dsData, HostResource... hosts) { - ImmutableSet.Builder> hostRefs = new ImmutableSet.Builder<>(); - for (HostResource host : hosts) { + Domain domain, ImmutableSet dsData, Host... hosts) { + ImmutableSet.Builder> hostRefs = new ImmutableSet.Builder<>(); + for (Host host : hosts) { hostRefs.add(host.createVKey()); } persistResource(domain.asBuilder().setNameservers(hostRefs.build()).setDsData(dsData).build()); diff --git a/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java b/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java index 613c04854..adbd9a641 100644 --- a/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java +++ b/core/src/test/java/google/registry/tools/UpdateDomainCommandTest.java @@ -41,7 +41,7 @@ import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.GracePeriod; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.ofy.Ofy; import google.registry.persistence.VKey; import google.registry.testing.DatabaseHelper; @@ -159,8 +159,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = - ImmutableSet.of(host1.createVKey(), host2.createVKey()); + Host host1 = persistActiveHost("ns1.zdns.google"); + Host host2 = persistActiveHost("ns2.zdns.google"); + ImmutableSet> nameservers = ImmutableSet.of(host1.createVKey(), host2.createVKey()); persistResource( DatabaseHelper.newDomain("example.tld").asBuilder().setNameservers(nameservers).build()); runCommandForced( @@ -265,8 +264,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = ImmutableSet.of(host.createVKey()); + Host host = persistActiveHost("ns1.zdns.google"); + ImmutableSet> nameservers = ImmutableSet.of(host.createVKey()); persistResource( DatabaseHelper.newDomain("example.tld") .asBuilder() @@ -398,8 +397,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = ImmutableSet.of(host.createVKey()); + Host host = persistActiveHost("ns1.zdns.google"); + ImmutableSet> nameservers = ImmutableSet.of(host.createVKey()); persistResource( DatabaseHelper.newDomain("example.tld") .asBuilder() @@ -423,8 +422,8 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase> nameservers = ImmutableSet.of(host.createVKey()); + Host host = persistActiveHost("ns1.zdns.google"); + ImmutableSet> nameservers = ImmutableSet.of(host.createVKey()); persistResource( DatabaseHelper.newDomain("example.tld") .asBuilder() diff --git a/core/src/test/java/google/registry/tools/server/GenerateZoneFilesActionTest.java b/core/src/test/java/google/registry/tools/server/GenerateZoneFilesActionTest.java index 7750312b5..7d8edb8e9 100644 --- a/core/src/test/java/google/registry/tools/server/GenerateZoneFilesActionTest.java +++ b/core/src/test/java/google/registry/tools/server/GenerateZoneFilesActionTest.java @@ -16,7 +16,7 @@ package google.registry.tools.server; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.createTlds; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.persistActiveContact; import static google.registry.testing.DatabaseHelper.persistActiveDomain; import static google.registry.testing.DatabaseHelper.persistActiveHost; @@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableSet; import google.registry.gcs.GcsUtils; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.persistence.VKey; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -63,13 +63,10 @@ class GenerateZoneFilesActionTest { ImmutableSet ips = ImmutableSet.of(InetAddress.getByName("127.0.0.1"), InetAddress.getByName("::1")); - HostResource host1 = - persistResource(newHostResource("ns.foo.tld").asBuilder().addInetAddresses(ips).build()); - HostResource host2 = - persistResource(newHostResource("ns.bar.tld").asBuilder().addInetAddresses(ips).build()); + Host host1 = persistResource(newHost("ns.foo.tld").asBuilder().addInetAddresses(ips).build()); + Host host2 = persistResource(newHost("ns.bar.tld").asBuilder().addInetAddresses(ips).build()); - ImmutableSet> nameservers = - ImmutableSet.of(host1.createVKey(), host2.createVKey()); + ImmutableSet> nameservers = ImmutableSet.of(host1.createVKey(), host2.createVKey()); // This domain will have glue records, because it has a subordinate host which is its own // nameserver. None of the other domains should have glue records, because their nameservers are // subordinate to different domains. @@ -118,7 +115,7 @@ class GenerateZoneFilesActionTest { persistActiveContact("ignored_contact"); persistActiveHost("ignored.host.tld"); // No ips. persistActiveDomain("ignored_domain.tld"); // No hosts or DS data. - persistResource(newHostResource("ignored.foo.com").asBuilder().addInetAddresses(ips).build()); + persistResource(newHost("ignored.foo.com").asBuilder().addInetAddresses(ips).build()); persistResource( DatabaseHelper.newDomain("ignored.com") .asBuilder() diff --git a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java index 79de64d27..cc42d5f0e 100644 --- a/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java +++ b/core/src/test/java/google/registry/ui/server/registrar/RegistryLockVerifyActionTest.java @@ -37,7 +37,7 @@ import google.registry.model.billing.BillingEvent.Reason; import google.registry.model.domain.Domain; import google.registry.model.domain.DomainHistory; import google.registry.model.domain.RegistryLock; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.reporting.HistoryEntry; import google.registry.model.tld.Registry; import google.registry.request.auth.AuthLevel; @@ -89,7 +89,7 @@ final class RegistryLockVerifyActionTest { @BeforeEach void beforeEach() { createTlds("tld", "net"); - HostResource host = persistActiveHost("ns1.example.net"); + Host host = persistActiveHost("ns1.example.net"); domain = persistResource(DatabaseHelper.newDomain("example.tld", host)); when(request.getRequestURI()).thenReturn("https://registry.example/registry-lock-verification"); action = createAction(lockId, true); diff --git a/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java b/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java index 5fc824ed8..495273fb2 100644 --- a/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java +++ b/core/src/test/java/google/registry/whois/DomainWhoisResponseTest.java @@ -33,7 +33,7 @@ import google.registry.model.domain.GracePeriod; import google.registry.model.domain.rgp.GracePeriodStatus; import google.registry.model.domain.secdns.DelegationSignerData; import google.registry.model.eppcommon.StatusValue; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.model.registrar.RegistrarPoc; import google.registry.persistence.VKey; @@ -51,8 +51,8 @@ class DomainWhoisResponseTest { @RegisterExtension final AppEngineExtension gae = AppEngineExtension.builder().withCloudSql().build(); - private HostResource hostResource1; - private HostResource hostResource2; + private Host host1; + private Host host2; private RegistrarPoc abuseContact; private ContactResource adminContact; private ContactResource registrant; @@ -84,16 +84,16 @@ class DomainWhoisResponseTest { createTld("tld"); - hostResource1 = + host1 = persistResource( - new HostResource.Builder() + new Host.Builder() .setHostName("ns01.exampleregistrar.tld") .setRepoId("1-ROID") .build()); - hostResource2 = + host2 = persistResource( - new HostResource.Builder() + new Host.Builder() .setHostName("ns02.exampleregistrar.tld") .setRepoId("2-ROID") .build()); @@ -239,8 +239,8 @@ class DomainWhoisResponseTest { .setEmailAddress("EMAIL@EXAMPLE.tld") .build()); - VKey hostResource1Key = hostResource1.createVKey(); - VKey hostResource2Key = hostResource2.createVKey(); + VKey host1VKey = host1.createVKey(); + VKey host2VKey = host2.createVKey(); VKey registrantResourceKey = registrant.createVKey(); VKey adminResourceKey = adminContact.createVKey(); VKey techResourceKey = techContact.createVKey(); @@ -267,7 +267,7 @@ class DomainWhoisResponseTest { ImmutableSet.of( DesignatedContact.create(DesignatedContact.Type.ADMIN, adminResourceKey), DesignatedContact.create(DesignatedContact.Type.TECH, techResourceKey))) - .setNameservers(ImmutableSet.of(hostResource1Key, hostResource2Key)) + .setNameservers(ImmutableSet.of(host1VKey, host2VKey)) .setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, "deadface"))) .setGracePeriods( ImmutableSet.of( diff --git a/core/src/test/java/google/registry/whois/NameserverWhoisResponseTest.java b/core/src/test/java/google/registry/whois/NameserverWhoisResponseTest.java index a26267585..74ee02bb6 100644 --- a/core/src/test/java/google/registry/whois/NameserverWhoisResponseTest.java +++ b/core/src/test/java/google/registry/whois/NameserverWhoisResponseTest.java @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -42,9 +42,9 @@ class NameserverWhoisResponseTest { @RegisterExtension final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build(); - private HostResource hostResource1; - private HostResource hostResource2; - private HostResource hostResource3; + private Host host1; + private Host host2; + private Host host3; private final FakeClock clock = new FakeClock(DateTime.parse("2009-05-29T20:15:00Z")); @@ -55,8 +55,8 @@ class NameserverWhoisResponseTest { createTld("tld"); Domain domain = persistResource(DatabaseHelper.newDomain("zobo.tld")); - hostResource1 = - new HostResource.Builder() + host1 = + new Host.Builder() .setHostName("ns1.example.tld") .setPersistedCurrentSponsorRegistrarId("example") .setInetAddresses( @@ -66,8 +66,8 @@ class NameserverWhoisResponseTest { .setRepoId("1-EXAMPLE") .build(); - hostResource2 = - new HostResource.Builder() + host2 = + new Host.Builder() .setHostName("ns2.example.tld") .setPersistedCurrentSponsorRegistrarId("example") .setInetAddresses( @@ -77,8 +77,8 @@ class NameserverWhoisResponseTest { .setRepoId("2-EXAMPLE") .build(); - hostResource3 = - new HostResource.Builder() + host3 = + new Host.Builder() .setHostName("ns1.zobo.tld") .setSuperordinateDomain(domain.createVKey()) .setPersistedCurrentSponsorRegistrarId("example") @@ -93,7 +93,7 @@ class NameserverWhoisResponseTest { @Test void testGetTextOutput() { NameserverWhoisResponse nameserverWhoisResponse = - new NameserverWhoisResponse(hostResource1, clock.nowUtc()); + new NameserverWhoisResponse(host1, clock.nowUtc()); assertThat( nameserverWhoisResponse.getResponse( false, @@ -104,7 +104,7 @@ class NameserverWhoisResponseTest { @Test void testGetMultipleNameserversResponse() { NameserverWhoisResponse nameserverWhoisResponse = - new NameserverWhoisResponse(ImmutableList.of(hostResource1, hostResource2), clock.nowUtc()); + new NameserverWhoisResponse(ImmutableList.of(host1, host2), clock.nowUtc()); assertThat( nameserverWhoisResponse.getResponse( false, @@ -115,7 +115,7 @@ class NameserverWhoisResponseTest { @Test void testSubordinateDomains() { NameserverWhoisResponse nameserverWhoisResponse = - new NameserverWhoisResponse(hostResource3, clock.nowUtc()); + new NameserverWhoisResponse(host3, clock.nowUtc()); assertThat( nameserverWhoisResponse.getResponse( false, diff --git a/core/src/test/java/google/registry/whois/WhoisActionTest.java b/core/src/test/java/google/registry/whois/WhoisActionTest.java index d1327382c..dc058c79e 100644 --- a/core/src/test/java/google/registry/whois/WhoisActionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisActionTest.java @@ -27,7 +27,6 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; -import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.whois.WhoisTestData.loadFile; @@ -47,7 +46,7 @@ import com.google.common.net.InetAddresses; import google.registry.model.contact.ContactResource; import google.registry.model.domain.Domain; import google.registry.model.eppcommon.Trid; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.ofy.Ofy; import google.registry.model.registrar.Registrar; import google.registry.model.tld.Registry; @@ -57,6 +56,7 @@ import google.registry.testing.AppEngineExtension; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; import google.registry.testing.FakeSleeper; +import google.registry.testing.FullFieldsTestEntityHelper; import google.registry.testing.InjectExtension; import google.registry.testing.TestCacheExtension; import google.registry.util.Retrier; @@ -125,8 +125,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), registrar); } @@ -203,8 +204,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")), - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisAction("domain cat.みんな\r\n").run(); @@ -222,8 +224,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")), - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisAction("domain cat.xn--q9jyb4c\r\n").run(); @@ -262,8 +265,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisAction("domain cat.lol\r\n").run(); @@ -280,8 +284,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), persistResource( (registrar = makeRegistrar("example", "Example Registrar", ACTIVE)))) .asBuilder() @@ -309,8 +314,10 @@ public class WhoisActionTest { persistResource( makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost( + "ns2.cat.lol", "bad:f00d:cafe::15:beef")), persistResource(makeRegistrar("example", "Example Registrar", ACTIVE))) .asBuilder() .setCreationTimeForTest(clock.nowUtc().minusDays(2)) @@ -327,8 +334,10 @@ public class WhoisActionTest { makeContactResource("5372809-IRL", "Mr. Bob Crypto", "bob@example.lol")), persistResource( makeContactResource("5372809-TRL", "Dr. Pablo", "pmy@example.lol")), - persistResource(makeHostResource("ns1.google.lol", "9.9.9.9")), - persistResource(makeHostResource("ns2.google.lol", "4311::f143")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns1.google.lol", "9.9.9.9")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.google.lol", "4311::f143")), persistResource( (registrar = makeRegistrar("example", "Example Registrar", ACTIVE)))) .asBuilder() @@ -344,7 +353,7 @@ public class WhoisActionTest { @Test void testRun_nameserverQuery_works() { persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt")); @@ -352,7 +361,7 @@ public class WhoisActionTest { @Test void testRun_ipv6_displaysInCollapsedReadableFormat() { - persistResource(makeHostResource("ns1.cat.lol", "bad:f00d:cafe::15:beef")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "bad:f00d:cafe::15:beef")); newWhoisAction("nameserver ns1.cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.lol"); @@ -363,7 +372,7 @@ public class WhoisActionTest { @Test void testRun_idnNameserver_works() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.みんな\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.xn--q9jyb4c"); @@ -372,10 +381,9 @@ public class WhoisActionTest { @Test void testRun_nameserver_usesCache() { - persistResource(makeHostResource("ns1.cat.xn--q9jyb4c", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.xn--q9jyb4c", "1.2.3.4")); // Populate the cache. - HostResource host = - loadByForeignKeyCached(HostResource.class, "ns1.cat.xn--q9jyb4c", clock.nowUtc()).get(); + Host host = loadByForeignKeyCached(Host.class, "ns1.cat.xn--q9jyb4c", clock.nowUtc()).get(); // Make a change to the persisted host that won't be seen because the cache will be hit. persistResource( host.asBuilder() @@ -389,7 +397,7 @@ public class WhoisActionTest { @Test void testRun_punycodeNameserver_works() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.xn--q9jyb4c\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.xn--q9jyb4c"); @@ -398,7 +406,7 @@ public class WhoisActionTest { @Test void testRun_nameserverNotFound_returns200AndText() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.lulz\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt")); @@ -407,8 +415,10 @@ public class WhoisActionTest { @Test void testRun_nameserverFlaggedAsDeletedInDatastore_doesntGetLeaked() { persistResource( - makeHostResource("ns1.cat.lol", "1.2.3.4").asBuilder() - .setDeletionTime(clock.nowUtc().minusDays(1)).build()); + FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4") + .asBuilder() + .setDeletionTime(clock.nowUtc().minusDays(1)) + .build()); newWhoisAction("nameserver ns1.cat.lol\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt")); @@ -416,7 +426,7 @@ public class WhoisActionTest { @Test void testRun_ipNameserverLookup_works() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver 1.2.3.4").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.lol"); @@ -424,8 +434,8 @@ public class WhoisActionTest { @Test void testRun_ipMapsToMultipleNameservers_theyAllGetReturned() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); - persistResource(makeHostResource("ns2.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "1.2.3.4")); newWhoisAction("nameserver 1.2.3.4").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.lol"); @@ -434,9 +444,8 @@ public class WhoisActionTest { @Test void testRun_ipMapsToMultipleNameserverInDifferentTlds_showsThemAll() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); - persistResource( - makeHostResource("ns1.cat.xn--q9jyb4c", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.xn--q9jyb4c", "1.2.3.4")); newWhoisAction("nameserver 1.2.3.4").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.lol"); @@ -453,7 +462,7 @@ public class WhoisActionTest { @Test void testRun_ipMapsToNameserverUnderNonAuthoritativeTld_notFound() { assertThat(getTlds()).doesNotContain("com"); - persistResource(makeHostResource("ns1.google.com", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.google.com", "1.2.3.4")); newWhoisAction("nameserver 1.2.3.4").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_ip_not_found.txt")); @@ -462,7 +471,7 @@ public class WhoisActionTest { @Test void testRun_nameserverUnderNonAuthoritativeTld_notFound() { assertThat(getTlds()).doesNotContain("com"); - persistResource(makeHostResource("ns1.google.com", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.google.com", "1.2.3.4")); newWhoisAction("nameserver ns1.google.com").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt")); @@ -473,7 +482,7 @@ public class WhoisActionTest { @Test void testRun_nameserverInTestTld_notFound() { persistResource(Registry.get("lol").asBuilder().setTldType(Registry.TldType.TEST).build()); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.lol").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver_not_found.txt")); @@ -540,8 +549,9 @@ public class WhoisActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.1.test")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.1.test")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.1.test")), - persistResource(makeHostResource("ns1.cat.1.test", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.1.test", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.1.test", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.1.test", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); @@ -552,7 +562,7 @@ public class WhoisActionTest { @Test void testRun_hostnameWithMultilevelTld_isStillConsideredHostname() { - persistResource(makeHostResource("ns1.cat.1.test", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.1.test", "1.2.3.4")); newWhoisAction("nameserver ns1.cat.1.test\r\n").run(); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getPayload()).contains("ns1.cat.1.test"); @@ -561,8 +571,8 @@ public class WhoisActionTest { @Test void testRun_metricsLoggedForSuccessfulCommand() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); - persistResource(makeHostResource("ns2.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "1.2.3.4")); WhoisAction action = newWhoisAction("nameserver 1.2.3.4"); action.whoisMetrics = mock(WhoisMetrics.class); action.run(); @@ -591,7 +601,7 @@ public class WhoisActionTest { @Test void testRun_metricsLoggedForInternalServerError() throws Exception { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); WhoisAction action = newWhoisAction("ns1.cat.lol"); action.whoisReader = mock(WhoisReader.class); when(action.whoisReader.readCommand(any(Reader.class), eq(false), any(DateTime.class))) @@ -611,7 +621,7 @@ public class WhoisActionTest { @Test void testRun_retryOnTransientFailure() throws Exception { persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); WhoisAction action = newWhoisAction("ns1.cat.lol"); WhoisResponse expectedResponse = action diff --git a/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java b/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java index 99c2577dd..e8234eceb 100644 --- a/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java +++ b/core/src/test/java/google/registry/whois/WhoisCommandFactoryTest.java @@ -16,7 +16,7 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; -import static google.registry.testing.DatabaseHelper.newHostResource; +import static google.registry.testing.DatabaseHelper.newHost; import static google.registry.testing.DatabaseHelper.newRegistry; import static google.registry.testing.DatabaseHelper.persistNewRegistrar; import static google.registry.testing.DatabaseHelper.persistResource; @@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InternetDomainName; import google.registry.config.RegistryConfig; import google.registry.model.domain.Domain; -import google.registry.model.host.HostResource; +import google.registry.model.host.Host; import google.registry.model.registrar.Registrar; import google.registry.testing.AppEngineExtension; import google.registry.testing.DatabaseHelper; @@ -53,7 +53,7 @@ class WhoisCommandFactoryTest { WhoisCommandFactory noncachedFactory = WhoisCommandFactory.createNonCached(); WhoisCommandFactory cachedFactory = WhoisCommandFactory.createCached(); Domain domain; - HostResource host; + Host host; Registrar otherRegistrar; int origSingletonCacheRefreshSeconds; @@ -62,7 +62,7 @@ class WhoisCommandFactoryTest { void setUp() throws Exception { persistResource(newRegistry("tld", "TLD")); host = - newHostResource("ns.example.tld") + newHost("ns.example.tld") .asBuilder() .setInetAddresses(ImmutableSet.of(InetAddress.getByName("1.2.3.4"))) .build(); diff --git a/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java b/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java index 1aa300f74..9c9d3be4b 100644 --- a/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisHttpActionTest.java @@ -22,7 +22,6 @@ import static google.registry.testing.DatabaseHelper.persistResource; import static google.registry.testing.DatabaseHelper.persistSimpleResources; import static google.registry.testing.FullFieldsTestEntityHelper.makeContactResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain; -import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar; import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts; import static google.registry.whois.WhoisTestData.loadFile; @@ -43,6 +42,7 @@ import google.registry.model.tld.Registry; import google.registry.testing.AppEngineExtension; import google.registry.testing.FakeClock; import google.registry.testing.FakeResponse; +import google.registry.testing.FullFieldsTestEntityHelper; import google.registry.testing.InjectExtension; import google.registry.whois.WhoisMetrics.WhoisMetric; import java.io.IOException; @@ -128,8 +128,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "Goblin Market", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisHttpAction("/domain/cat.lol").run(); @@ -148,8 +149,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")), - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisHttpAction("/domain/cat.みんな").run(); @@ -175,8 +177,9 @@ class WhoisHttpActionTest { trl, trl, trl, - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), persistResource( makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE)))); newWhoisHttpAction("/domain/cat.みんな").run(); @@ -191,8 +194,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.みんな")), persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.みんな")), - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), persistResource( makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE)))); newWhoisHttpAction("cat.みんな").run(); @@ -202,7 +206,7 @@ class WhoisHttpActionTest { @Test void testRun_hostnameOnly_works() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisHttpAction("ns1.cat.みんな").run(); assertThat(response.getPayload()).contains("Server Name: ns1.cat.みんな\r\n"); } @@ -217,8 +221,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "(◕‿◕)", "lol@cat.みんな")), persistResource(makeContactResource("5372808-IRL", "Santa Claus", "BOFH@cat.みんな")), persistResource(makeContactResource("5372808-TRL", "The Raven", "bog@cat.みんな")), - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.みんな", "bad:f00d:cafe::15:beef")), registrar)); persistSimpleResources(makeRegistrarContacts(registrar)); newWhoisHttpAction("/domain/cat.xn--q9jyb4c").run(); @@ -228,7 +233,7 @@ class WhoisHttpActionTest { @Test void testRun_nameserverQuery_works() { persistResource(loadRegistrar("TheRegistrar").asBuilder().setUrl("http://my.fake.url").build()); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.lol").run(); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt")); } @@ -237,7 +242,7 @@ class WhoisHttpActionTest { @Disabled @Test void testRun_nameserverQueryInTestTld_notFound() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.lol").run(); assertThat(response.getPayload()).isEqualTo(loadFile("whois_action_nameserver.txt")); } @@ -245,7 +250,7 @@ class WhoisHttpActionTest { @Test void testRun_lastUpdateTimestamp_isPresentInResponse() { clock.setTo(DateTime.parse("2020-07-12T23:52:43Z")); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.lol").run(); assertThat(response.getPayload()) .contains(">>> Last update of WHOIS database: 2020-07-12T23:52:43Z <<<"); @@ -253,7 +258,7 @@ class WhoisHttpActionTest { @Test void testRun_nameserverQueryIdn_works() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.みんな").run(); assertThat(response.getPayload()).contains("ns1.cat.みんな"); assertThat(response.getPayload()).contains("1.2.3.4"); @@ -261,7 +266,7 @@ class WhoisHttpActionTest { @Test void testRun_nameserverQueryPunycode_works() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.xn--q9jyb4c").run(); assertThat(response.getPayload()).contains("ns1.cat.みんな"); assertThat(response.getPayload()).contains("1.2.3.4"); @@ -269,7 +274,7 @@ class WhoisHttpActionTest { @Test void testRun_trailingSlashInPath_getsIgnored() { - persistResource(makeHostResource("ns1.cat.みんな", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.みんな", "1.2.3.4")); newWhoisHttpAction("/nameserver/ns1.cat.xn--q9jyb4c/").run(); assertThat(response.getPayload()).contains("ns1.cat.みんな"); assertThat(response.getPayload()).contains("1.2.3.4"); @@ -283,8 +288,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), persistResource( makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE)))); newWhoisHttpAction("/domain/cat.LOL").run(); @@ -299,8 +305,9 @@ class WhoisHttpActionTest { persistResource(makeContactResource("5372808-ERL", "Peter Murphy", "lol@cat.lol")), persistResource(makeContactResource("5372808-IRL", "Operator", "BOFH@cat.lol")), persistResource(makeContactResource("5372808-TRL", "Eric Schmidt", "bog@cat.lol")), - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")), - persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe::15:beef")), + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")), + persistResource( + FullFieldsTestEntityHelper.makeHost("ns2.cat.lol", "bad:f00d:cafe::15:beef")), persistResource( makeRegistrar("example", "Example Registrar", Registrar.State.ACTIVE)))); // python -c "print ''.join('%' + hex(ord(c))[2:] for c in 'cat.lol')" @@ -342,7 +349,7 @@ class WhoisHttpActionTest { @Test void testRun_metricsLoggedForSuccessfulCommand() { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); WhoisHttpAction action = newWhoisHttpAction("/nameserver/ns1.cat.lol"); action.whoisMetrics = mock(WhoisMetrics.class); action.run(); @@ -367,7 +374,7 @@ class WhoisHttpActionTest { @Test void testRun_metricsLoggedForInternalServerError() throws Exception { - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); WhoisHttpAction action = newWhoisHttpAction("ns1.cat.lol"); action.whoisReader = mock(WhoisReader.class); when(action.whoisReader.readCommand(any(Reader.class), eq(false), any(DateTime.class))) diff --git a/core/src/test/java/google/registry/whois/WhoisInjectionTest.java b/core/src/test/java/google/registry/whois/WhoisInjectionTest.java index 3897420b1..14ab68ea1 100644 --- a/core/src/test/java/google/registry/whois/WhoisInjectionTest.java +++ b/core/src/test/java/google/registry/whois/WhoisInjectionTest.java @@ -17,13 +17,13 @@ package google.registry.whois; import static com.google.common.truth.Truth.assertThat; import static google.registry.testing.DatabaseHelper.createTld; import static google.registry.testing.DatabaseHelper.persistResource; -import static google.registry.testing.FullFieldsTestEntityHelper.makeHostResource; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import google.registry.request.RequestModule; import google.registry.testing.AppEngineExtension; +import google.registry.testing.FullFieldsTestEntityHelper; import java.io.BufferedReader; import java.io.PrintWriter; import java.io.StringReader; @@ -52,7 +52,7 @@ final class WhoisInjectionTest { @Test void testWhoisAction_injectsAndWorks() throws Exception { createTld("lol"); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); when(req.getReader()).thenReturn(new BufferedReader(new StringReader("ns1.cat.lol\r\n"))); DaggerWhoisTestComponent.builder() .requestModule(new RequestModule(req, rsp)) @@ -66,7 +66,7 @@ final class WhoisInjectionTest { @Test void testWhoisHttpAction_injectsAndWorks() { createTld("lol"); - persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4")); + persistResource(FullFieldsTestEntityHelper.makeHost("ns1.cat.lol", "1.2.3.4")); when(req.getRequestURI()).thenReturn("/whois/ns1.cat.lol"); DaggerWhoisTestComponent.builder() .requestModule(new RequestModule(req, rsp)) diff --git a/core/src/test/resources/google/registry/export/backup_kinds.txt b/core/src/test/resources/google/registry/export/backup_kinds.txt index bffcd77bb..19a56fdba 100644 --- a/core/src/test/resources/google/registry/export/backup_kinds.txt +++ b/core/src/test/resources/google/registry/export/backup_kinds.txt @@ -8,7 +8,7 @@ ForeignKeyContactIndex ForeignKeyDomainIndex ForeignKeyHostIndex HistoryEntry -HostResource +Host Modification OneTime PollMessage diff --git a/core/src/test/resources/google/registry/export/reporting_kinds.txt b/core/src/test/resources/google/registry/export/reporting_kinds.txt index c53895796..baf8eec4e 100644 --- a/core/src/test/resources/google/registry/export/reporting_kinds.txt +++ b/core/src/test/resources/google/registry/export/reporting_kinds.txt @@ -7,7 +7,7 @@ ForeignKeyContactIndex ForeignKeyDomainIndex ForeignKeyHostIndex HistoryEntry -HostResource +Host Modification OneTime PollMessage diff --git a/core/src/test/resources/google/registry/model/schema.txt b/core/src/test/resources/google/registry/model/schema.txt index 0122df176..6081c3c49 100644 --- a/core/src/test/resources/google/registry/model/schema.txt +++ b/core/src/test/resources/google/registry/model/schema.txt @@ -118,7 +118,7 @@ class google.registry.model.domain.Domain { java.util.Set gracePeriods; java.util.Set dsData; java.util.Set status; - java.util.Set> nsHosts; + java.util.Set> nsHosts; java.util.Set subordinateHosts; org.joda.time.DateTime autorenewEndTime; org.joda.time.DateTime deletionTime; @@ -150,7 +150,7 @@ class google.registry.model.domain.DomainBase { java.util.Set gracePeriods; java.util.Set dsData; java.util.Set status; - java.util.Set> nsHosts; + java.util.Set> nsHosts; java.util.Set subordinateHosts; org.joda.time.DateTime autorenewEndTime; org.joda.time.DateTime deletionTime; @@ -174,7 +174,7 @@ class google.registry.model.domain.DomainHistory { java.util.Set gracePeriodHistories; java.util.Set dsDataHistories; java.util.Set domainTransactionRecords; - java.util.Set> nsHosts; + java.util.Set> nsHosts; org.joda.time.DateTime modificationTime; } class google.registry.model.domain.GracePeriod { @@ -289,6 +289,20 @@ class google.registry.model.eppcommon.Trid { java.lang.String clientTransactionId; java.lang.String serverTransactionId; } +class google.registry.model.host.Host { + @Id java.lang.String repoId; + google.registry.persistence.VKey superordinateDomain; + java.lang.String creationClientId; + java.lang.String currentSponsorClientId; + java.lang.String fullyQualifiedHostName; + java.lang.String lastEppUpdateClientId; + java.util.Set status; + java.util.Set inetAddresses; + org.joda.time.DateTime deletionTime; + org.joda.time.DateTime lastEppUpdateTime; + org.joda.time.DateTime lastSuperordinateChange; + org.joda.time.DateTime lastTransferTime; +} class google.registry.model.host.HostBase { @Id java.lang.String repoId; google.registry.persistence.VKey superordinateDomain; @@ -319,20 +333,6 @@ class google.registry.model.host.HostHistory { java.util.Set domainTransactionRecords; org.joda.time.DateTime modificationTime; } -class google.registry.model.host.HostResource { - @Id java.lang.String repoId; - google.registry.persistence.VKey superordinateDomain; - java.lang.String creationClientId; - java.lang.String currentSponsorClientId; - java.lang.String fullyQualifiedHostName; - java.lang.String lastEppUpdateClientId; - java.util.Set status; - java.util.Set inetAddresses; - org.joda.time.DateTime deletionTime; - org.joda.time.DateTime lastEppUpdateTime; - org.joda.time.DateTime lastSuperordinateChange; - org.joda.time.DateTime lastTransferTime; -} class google.registry.model.index.EppResourceIndex { @Id java.lang.String id; @Parent com.googlecode.objectify.Key bucket; diff --git a/docs/architecture.md b/docs/architecture.md index 3a6d55d6b..aa1dbdea3 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -333,8 +333,6 @@ registry codebase: remembering which dates have been processed. For instance, for the RDE export, Cursor entities maintain the date up to which each TLD has been exported. -* `DomainApplicationIndex` -- These hold domain applications received during - the sunrise period. * `Domain` -- These hold the ICANN domain information. * `DomainRecord` -- These are used during the DNS update process. * `EntityGroupRoot` -- There is only one EntityGroupRoot entity, which serves @@ -351,7 +349,7 @@ registry codebase: * `HistoryEntry` -- A HistoryEntry is the record of a command which mutated an EPP resource. It serves as the parent of BillingEvents and PollMessages. * `HostRecord` -- These are used during the DNS update process. -* `HostResource` -- These hold the ICANN host information. +* `Host` -- These hold the ICANN host information. * `Lock` -- Lock entities are used to control access to a shared resource such as an App Engine queue. Under ordinary circumstances, these locks will be cleaned up automatically, and should not accumulate. diff --git a/docs/code-structure.md b/docs/code-structure.md index 450e86610..0fe67b935 100644 --- a/docs/code-structure.md +++ b/docs/code-structure.md @@ -148,7 +148,7 @@ as follows: sunrise or landrush * `DomainResource`, a domain name allocated following a successful application, or registered during a general availability phase -* `HostResource` ([RFC 5732](https://tools.ietf.org/html/rfc5732)) +* `Host` ([RFC 5732](https://tools.ietf.org/html/rfc5732)) * `ContactResource` ([RFC 5733](https://tools.ietf.org/html/rfc5733)) All `EppResource` entities use a Repository Object Identifier (ROID) as its @@ -172,9 +172,9 @@ the status of a resource at a given point in time. Foreign key indexes provide a means of loading active instances of `EppResource` objects by their unique IDs: -* `DomainResource`: fully-qualified domain name +* `Domain`: fully-qualified domain name * `ContactResource`: contact id -* `HostResource`: fully-qualified host name +* `Host`: fully-qualified host name Since all `EppResource` entities are indexed on ROID (which is also unique, but not as useful as the resource's name), a `ForeignKeyIndex` provides a way to diff --git a/python/google/registry/scripts/testdata/datastore-indexes.xml b/python/google/registry/scripts/testdata/datastore-indexes.xml index 8396becda..61d3bd749 100644 --- a/python/google/registry/scripts/testdata/datastore-indexes.xml +++ b/python/google/registry/scripts/testdata/datastore-indexes.xml @@ -22,7 +22,7 @@ - + @@ -48,7 +48,7 @@ - + @@ -75,7 +75,7 @@ - + diff --git a/python/google/registry/scripts/testdata/index.yaml b/python/google/registry/scripts/testdata/index.yaml index e7e2ac7f5..5df79db08 100644 --- a/python/google/registry/scripts/testdata/index.yaml +++ b/python/google/registry/scripts/testdata/index.yaml @@ -22,7 +22,7 @@ indexes: - name: currentSponsorClientId - name: deletionTime -- kind: HostResource +- kind: Host properties: - name: currentSponsorClientId - name: deletionTime @@ -50,7 +50,7 @@ indexes: - name: nsHosts - name: deletionTime -- kind: HostResource +- kind: Host properties: - name: inetAddresses - name: deletionTime @@ -82,7 +82,7 @@ indexes: - name: tld - name: fullyQualifiedDomainName -- kind: HostResource +- kind: Host properties: - name: deletionTime - name: fullyQualifiedHostName