Rename HostResource -> Host (#1733)

* Rename HostResource -> Host
This commit is contained in:
Ben McIlwain 2022-08-05 10:28:45 -04:00 committed by GitHub
parent 4399067ddd
commit a12a716806
119 changed files with 985 additions and 1032 deletions

View file

@ -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<HostResource> hostKey = host.createVKey();
public void enqueueAsyncDnsRefresh(Host host, DateTime now) {
VKey<Host> hostKey = host.createVKey();
logger.atInfo().log("Enqueuing async DNS refresh for renamed host %s.", hostKey);
addTaskToQueueWithRetry(
asyncDnsRefreshPullQueue,

View file

@ -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.
*
* <p>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<HostResource> hostVKey = host.createVKey();
VKey<Host> hostVKey = host.createVKey();
// We can remove hosts from linked domains, so we should do so then delete the hosts
ImmutableSet<VKey<Domain>> linkedDomains =
EppResourceUtils.getLinkedDomainKeys(hostVKey, clock.nowUtc(), null);
@ -135,7 +135,7 @@ public class DeleteLoadTestDataAction implements Runnable {
.values()
.forEach(
domain -> {
ImmutableSet<VKey<HostResource>> remainingHosts =
ImmutableSet<VKey<Host>> remainingHosts =
domain.getNsHosts().stream()
.filter(vkey -> !vkey.equals(hostVKey))
.collect(toImmutableSet());

View file

@ -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.
*
* <h3>{@link HostResource}</h3>
* <h3>{@link Host}</h3>
*
* 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<String, Long>, KV<PendingDeposit, DepositFragment>>() {
@ProcessElement
@ -565,10 +564,10 @@ public class RdePipeline implements Serializable {
private PCollectionTuple processHostHistories(
PCollection<KV<String, PendingDeposit>> referencedHosts,
PCollection<KV<String, Long>> 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<String, CoGbkResult> 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<String, CoGbkResult> hostToPendingDeposits :
kv.getValue().getAll(HOST_TO_PENDING_DEPOSIT)) {
HostResource host =
(HostResource)
Host host =
(Host)
loadResourceByHistoryEntryId(
HostHistory.class,
hostToPendingDeposits.getKey(),

View file

@ -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<Class<? extends EppResource>> 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

View file

@ -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()));

View file

@ -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<HostResource> host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc());
Optional<Host> host = loadByForeignKey(Host.class, hostName, clock.nowUtc());
// Return early if the host is deleted.
if (!host.isPresent()) {

View file

@ -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<HostResource> host = loadByForeignKey(HostResource.class, hostName, clock.nowUtc());
Optional<Host> 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) {

View file

@ -26,7 +26,7 @@
<property name="creationTime" direction="desc"/>
</datastore-index>
<!-- For finding host resources by registrar. -->
<datastore-index kind="HostResource" ancestor="false" source="manual">
<datastore-index kind="Host" ancestor="false" source="manual">
<property name="currentSponsorClientId" direction="asc"/>
<property name="deletionTime" direction="asc"/>
<property name="fullyQualifiedHostName" direction="asc"/>
@ -52,7 +52,7 @@
<property name="deletionTime" direction="asc"/>
</datastore-index>
<!-- For WHOIS IP address lookup -->
<datastore-index kind="HostResource" ancestor="false" source="manual">
<datastore-index kind="Host" ancestor="false" source="manual">
<property name="inetAddresses" direction="asc"/>
<property name="deletionTime" direction="asc"/>
</datastore-index>
@ -87,7 +87,7 @@
<property name="tld" direction="asc"/>
<property name="fullyQualifiedDomainName" direction="asc"/>
</datastore-index>
<datastore-index kind="HostResource" ancestor="false" source="manual">
<datastore-index kind="Host" ancestor="false" source="manual">
<property name="deletionTime" direction="asc"/>
<property name="fullyQualifiedHostName" direction="asc"/>
</datastore-index>

View file

@ -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<DesignatedContact> contacts,
VKey<ContactResource> registrant,
Set<VKey<HostResource>> nameservers)
Set<VKey<Host>> nameservers)
throws EppException {
ImmutableList.Builder<VKey<? extends EppResource>> keysToLoad = new ImmutableList.Builder<>();
contacts.stream().map(DesignatedContact::getContactKey).forEach(keysToLoad::add);

View file

@ -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<String> hostnames = ((Check) resourceCommand).getTargetIds();
verifyTargetIdCount(hostnames, maxChecks);
ImmutableSet<String> existingIds =
checkResourcesExist(HostResource.class, hostnames, clock.nowUtc());
ImmutableSet<String> existingIds = checkResourcesExist(Host.class, hostnames, clock.nowUtc());
ImmutableList.Builder<HostCheck> checks = new ImmutableList.Builder<>();
for (String hostname : hostnames) {
boolean unused = !existingIds.contains(hostname);

View file

@ -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)

View file

@ -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(

View file

@ -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<StatusValue> statusValues = new ImmutableSet.Builder<>();
statusValues.addAll(host.getStatusValues());
if (isLinked(host.createVKey(), now)) {

View file

@ -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(

View file

@ -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 <update>} 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"))

View file

@ -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,

View file

@ -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<VKey<Domain>> getLinkedDomainKeys(
VKey<? extends EppResource> key, DateTime now, @Nullable Integer limit) {
checkArgument(
key.getKind().equals(ContactResource.class) || key.getKind().equals(HostResource.class),
"key must be either VKey<ContactResource> or VKey<HostResource>, but it is %s",
key.getKind().equals(ContactResource.class) || key.getKind().equals(Host.class),
"key must be either VKey<ContactResource> or VKey<Host>, but it is %s",
key);
boolean isContactKey = key.getKind().equals(ContactResource.class);
if (tm().isOfy()) {

View file

@ -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<GracePeriod> gracePeriods,
ImmutableSet<DelegationSignerData> delegationSignerData,
ImmutableSet<VKey<HostResource>> nsHosts) {
ImmutableSet<VKey<Host>> 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<DomainDsDataHistory> dsDataHistories,
ImmutableSet<VKey<HostResource>> domainHistoryHosts,
ImmutableSet<VKey<Host>> domainHistoryHosts,
ImmutableSet<GracePeriodHistory> gracePeriodHistories,
ImmutableSet<DomainTransactionRecord> transactionRecords) {
DomainHistory.Builder builder = new DomainHistory.Builder();

View file

@ -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<HostResource> getHostVKey() {
return VKey.create(HostResource.class, hostRepoId);
public VKey<Host> getHostVKey() {
return VKey.create(Host.class, hostRepoId);
}
@Override

View file

@ -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<HostResource> getHostVKey() {
return VKey.create(HostResource.class, hostRepoId);
public VKey<Host> getHostVKey() {
return VKey.create(Host.class, hostRepoId);
}
@Override

View file

@ -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<VKey<HostResource>> getNsHosts() {
public Set<VKey<Host>> getNsHosts() {
return super.nsHosts;
}

View file

@ -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<VKey<HostResource>> nsHosts;
@EmptySetToNull @Index @Transient Set<VKey<Host>> nsHosts;
/** Contacts. */
VKey<ContactResource> adminContact;
@ -372,13 +372,13 @@ public class DomainBase extends EppResource
return idnTableName;
}
public ImmutableSet<VKey<HostResource>> getNameservers() {
public ImmutableSet<VKey<Host>> 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<VKey<HostResource>> nsHosts) {
private void setNsHosts(Set<VKey<Host>> 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<HostResource> nameserver) {
public B setNameservers(VKey<Host> nameserver) {
getInstance().nsHosts = ImmutableSet.of(nameserver);
getInstance().resetUpdateTimestamp();
return thisCastToDerived();
}
public B setNameservers(ImmutableSet<VKey<HostResource>> nameservers) {
public B setNameservers(ImmutableSet<VKey<Host>> nameservers) {
getInstance().nsHosts = forceEmptyToNull(nameservers);
getInstance().resetUpdateTimestamp();
return thisCastToDerived();
}
public B addNameserver(VKey<HostResource> nameserver) {
public B addNameserver(VKey<Host> nameserver) {
return addNameservers(ImmutableSet.of(nameserver));
}
public B addNameservers(ImmutableSet<VKey<HostResource>> nameservers) {
public B addNameservers(ImmutableSet<VKey<Host>> nameservers) {
return setNameservers(
ImmutableSet.copyOf(Sets.union(getInstance().getNameservers(), nameservers)));
}
public B removeNameserver(VKey<HostResource> nameserver) {
public B removeNameserver(VKey<Host> nameserver) {
return removeNameservers(ImmutableSet.of(nameserver));
}
public B removeNameservers(ImmutableSet<VKey<HostResource>> nameservers) {
public B removeNameservers(ImmutableSet<VKey<Host>> nameservers) {
return setNameservers(
ImmutableSet.copyOf(difference(getInstance().getNameservers(), nameservers)));
}

View file

@ -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<String> nameserverFullyQualifiedHostNames;
/** Resolved keys to hosts that are the nameservers for the domain. */
@XmlTransient Set<VKey<HostResource>> nameservers;
@XmlTransient Set<VKey<Host>> 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<VKey<HostResource>> getNameservers() {
public ImmutableSet<VKey<Host>> getNameservers() {
return nullToEmptyImmutableCopy(nameservers);
}
@ -349,7 +349,7 @@ public class DomainCommand {
Set<String> nameserverFullyQualifiedHostNames;
/** Resolved keys to hosts that are the nameservers for the domain. */
@XmlTransient Set<VKey<HostResource>> nameservers;
@XmlTransient Set<VKey<Host>> 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<VKey<HostResource>> getNameservers() {
public ImmutableSet<VKey<Host>> getNameservers() {
return nullToEmptyImmutableCopy(nameservers);
}
@ -413,13 +413,13 @@ public class DomainCommand {
}
}
private static Set<VKey<HostResource>> linkHosts(
Set<String> fullyQualifiedHostNames, DateTime now) throws InvalidReferencesException {
private static Set<VKey<Host>> linkHosts(Set<String> 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<DesignatedContact> linkContacts(

View file

@ -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<VKey<HostResource>> nsHosts;
Set<VKey<Host>> 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<VKey<HostResource>> getNsHosts() {
/** Returns keys to the {@link Host} that are the nameservers for the domain. */
public Set<VKey<Host>> getNsHosts() {
return nsHosts;
}
@ -406,7 +406,7 @@ public class DomainHistory extends HistoryEntry {
public DomainHistory buildAndAssemble(
ImmutableSet<DomainDsDataHistory> dsDataHistories,
ImmutableSet<VKey<HostResource>> domainHistoryHosts,
ImmutableSet<VKey<Host>> domainHistoryHosts,
ImmutableSet<GracePeriodHistory> gracePeriodHistories,
ImmutableSet<DomainTransactionRecord> transactionRecords) {
DomainHistory instance = super.build();

View file

@ -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);

View file

@ -27,7 +27,7 @@ import javax.persistence.AccessType;
/**
* A persistable Host resource including mutable and non-mutable fields.
*
* <p>The {@link javax.persistence.Id} of the HostResource is the repoId.
* <p>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<HostResource> createVKey() {
return VKey.create(HostResource.class, getRepoId(), Key.create(this));
public VKey<Host> 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<HostResource, Builder> {
/** A builder for constructing {@link Host}, since it is immutable. */
public static class Builder extends HostBase.Builder<Host, Builder> {
public Builder() {}
private Builder(HostResource instance) {
private Builder(Host instance) {
super(instance);
}

View file

@ -126,8 +126,7 @@ public class HostBase extends EppResource {
@Override
public VKey<? extends HostBase> 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

View file

@ -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 <a href="http://tools.ietf.org/html/rfc5732">RFC5732</a>. */
@XmlTransient
abstract static class HostCreateOrChange extends AbstractSingleResourceCommand
implements ResourceCreateOrChange<HostResource.Builder> {
implements ResourceCreateOrChange<Host.Builder> {
public String getFullyQualifiedHostName() {
return getTargetId();
}
}
/**
* A create command for a {@link HostResource}, mapping "createType" from <a
* A create command for a {@link Host}, mapping "createType" from <a
* href="http://tools.ietf.org/html/rfc5732">RFC5732</a>.
*/
@XmlType(propOrder = {"targetId", "inetAddresses"})
@XmlRootElement
public static class Create extends HostCreateOrChange
implements ResourceCreateOrChange<HostResource.Builder> {
implements ResourceCreateOrChange<Host.Builder> {
/** IP Addresses for this host. Can be null if this is an external host. */
@XmlElement(name = "addr")
Set<InetAddress> 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
<Update.AddRemove, HostResource.Builder, Update.Change> {
public static class Update extends ResourceUpdate<Update.AddRemove, Host.Builder, Update.Change> {
@XmlElement(name = "chg")
protected Change innerChange;

View file

@ -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<HostResource> getParentVKey() {
return VKey.create(HostResource.class, getHostRepoId());
/** The key to the {@link Host} this is based off of. */
public VKey<Host> 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<? extends EppResource> 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;
}
}

View file

@ -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<E extends EppResource> extends BackupGroup
@Entity
public static class ForeignKeyDomainIndex extends ForeignKeyIndex<Domain> {}
/** The {@link ForeignKeyIndex} type for {@link HostResource} entities. */
/** The {@link ForeignKeyIndex} type for {@link Host} entities. */
@ReportedOn
@Entity
public static class ForeignKeyHostIndex extends ForeignKeyIndex<HostResource> {}
public static class ForeignKeyHostIndex extends ForeignKeyIndex<Host> {}
private static final ImmutableBiMap<
Class<? extends EppResource>, Class<? extends ForeignKeyIndex<?>>>
@ -91,14 +91,14 @@ public abstract class ForeignKeyIndex<E extends EppResource> extends BackupGroup
ImmutableBiMap.of(
ContactResource.class, ForeignKeyContactIndex.class,
Domain.class, ForeignKeyDomainIndex.class,
HostResource.class, ForeignKeyHostIndex.class);
Host.class, ForeignKeyHostIndex.class);
private static final ImmutableMap<Class<? extends EppResource>, 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<E extends EppResource> extends BackupGroup
* The deletion time of this {@link ForeignKeyIndex}.
*
* <p>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;

View file

@ -33,7 +33,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
* via Objectify.
*
* <p>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"

View file

@ -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.
*
* <p>This may only be used on a HostResource poll event.
* <p>This may only be used on a Host poll event.
*/
public String getHostRepoId() {
checkArgument(getType() == Type.DOMAIN);

View file

@ -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),

View file

@ -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<Class<? extends HistoryEntry>, String> REPO_ID_FIELD_NAMES =

View file

@ -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<VKey<HostResource>> hostKeys =
getNameserverRefsByLdhName(partialStringQuery);
ImmutableCollection<VKey<Host>> 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.
*
* <p>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<VKey<HostResource>> getNameserverRefsByLdhName(
private ImmutableCollection<VKey<Host>> 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<String> desiredRegistrar = getDesiredRegistrar();
if (tm().isOfy()) {
Query<HostResource> query =
Query<Host> query =
queryItems(
HostResource.class,
Host.class,
"fullyQualifiedHostName",
partialStringQuery,
Optional.empty(),
@ -359,9 +358,9 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
return replicaJpaTm()
.transact(
() -> {
CriteriaQueryBuilder<HostResource> builder =
CriteriaQueryBuilder<Host> 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<VKey<HostResource>> getNameserverRefsByLdhNameWithoutWildcard(
/** Assembles a list of {@link Host} keys by name when the pattern has no wildcard. */
private ImmutableList<VKey<Host>> getNameserverRefsByLdhNameWithoutWildcard(
final RdapSearchPattern partialStringQuery) {
// If we need to check the sponsoring registrar, we need to load the resource rather than just
// the key.
Optional<String> desiredRegistrar = getDesiredRegistrar();
if (desiredRegistrar.isPresent()) {
Optional<HostResource> host =
Optional<Host> 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<HostResource> hostKey =
VKey<Host> 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<VKey<HostResource>> getNameserverRefsByLdhNameWithSuffix(
/** Assembles a list of {@link Host} keys by name using a superordinate domain suffix. */
private ImmutableList<VKey<Host>> 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<String> desiredRegistrar = getDesiredRegistrar();
ImmutableList.Builder<VKey<HostResource>> builder = new ImmutableList.Builder<>();
ImmutableList.Builder<VKey<Host>> 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<HostResource> host =
Optional<Host> 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<HostResource> hostKey =
VKey<Host> 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<String> desiredRegistrar = getDesiredRegistrar();
ImmutableSet<VKey<HostResource>> hostKeys;
ImmutableSet<VKey<Host>> hostKeys;
if (tm().isOfy()) {
Query<HostResource> query =
Query<Host> query =
queryItems(
HostResource.class,
Host.class,
"inetAddresses",
inetAddress.getHostAddress(),
Optional.empty(),
@ -524,7 +519,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
@SuppressWarnings("unchecked")
Stream<String> 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<VKey<HostResource>> hostKeys) {
final ImmutableCollection<VKey<Host>> 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<Domain> domainSetBuilder =
ImmutableSortedSet.orderedBy(Comparator.comparing(Domain::getDomainName));
int numHostKeysSearched = 0;
for (List<VKey<HostResource>> chunk : Iterables.partition(hostKeys, 30)) {
for (List<VKey<Host>> chunk : Iterables.partition(hostKeys, 30)) {
numHostKeysSearched += chunk.size();
if (tm().isOfy()) {
Query<Domain> query =
@ -574,7 +569,7 @@ public class RdapDomainSearchAction extends RdapSearchActionBase {
replicaJpaTm()
.transact(
() -> {
for (VKey<HostResource> hostKey : hostKeys) {
for (VKey<Host> hostKey : hostKeys) {
CriteriaQueryBuilder<Domain> queryBuilder =
CriteriaQueryBuilder.create(replicaJpaTm(), Domain.class)
.whereFieldContains("nsHosts", hostKey)

View file

@ -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<HostResource> HOST_RESOURCE_ORDERING =
Ordering.natural().onResultOf(HostResource::getHostName);
private static final Ordering<Host> 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<DesignatedContact> 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<HostResource> loadedHosts =
ImmutableSet<Host> loadedHosts =
tm().transact(() -> ImmutableSet.copyOf(tm().loadByKeys(domain.getNameservers()).values()));
// Load the registrant and other contacts and add them to the data.
ImmutableMap<VKey<? extends ContactResource>, 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<StatusValue> 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) {

View file

@ -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> hostResource =
Optional<Host> 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);
}
}

View file

@ -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> hostResource =
loadByForeignKey(
HostResource.class, partialStringQuery.getInitialString(), getRequestTime());
Optional<Host> 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<HostResource> hostList = new ArrayList<>();
List<Host> 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> hostResource =
loadByForeignKey(HostResource.class, fqhn, getRequestTime());
if (shouldBeVisible(hostResource)) {
hostList.add(hostResource.get());
Optional<Host> 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<HostResource> query =
Query<Host> query =
queryItems(
HostResource.class,
Host.class,
"fullyQualifiedHostName",
partialStringQuery,
cursorString,
@ -236,9 +234,9 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
return replicaJpaTm()
.transact(
() -> {
CriteriaQueryBuilder<HostResource> queryBuilder =
CriteriaQueryBuilder<Host> 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<HostResource> rdapResultSet;
RdapResultSet<Host> rdapResultSet;
if (tm().isOfy()) {
Query<HostResource> query =
Query<Host> 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<HostResource> resultList = query.getResultList();
List<Host> 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<HostResource> resultSet, CursorType cursorType) {
RdapResultSet<Host> 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<HostResource> hosts,
List<Host> hosts,
IncompletenessWarningType incompletenessWarningType,
int numHostsRetrieved,
CursorType cursorType) {
@ -329,7 +327,7 @@ public class RdapNameserverSearchAction extends RdapSearchActionBase {
NameserverSearchResponse.Builder builder =
NameserverSearchResponse.builder().setIncompletenessWarningType(incompletenessWarningType);
Optional<String> 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

View file

@ -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() {}
}

View file

@ -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()

View file

@ -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. */

View file

@ -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.
*
* <p>Only {@link ContactResource}s and {@link HostResource}s that are referenced by an included
* {@link Domain} will be included in the corresponding pending deposit.
* <p>Only {@link ContactResource}s and {@link Host}s that are referenced by an included {@link
* Domain} will be included in the corresponding pending deposit.
*
* <p>{@link Registrar} entities, both active and inactive, are included in all deposits. They are
* not rewinded point-in-time.

View file

@ -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<? extends EppResource> clazz;

View file

@ -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<HostResource> nameservers = tm().transact(() -> tm().loadAllOf(HostResource.class));
for (HostResource nameserver : nameservers) {
Iterable<Host> 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<String> ipAddresses =
nameserver
.getInetAddresses()

View file

@ -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)));
}
}

View file

@ -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 {

View file

@ -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<String> 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<String> getExistingNameservers(Domain domain) {
ImmutableSortedSet.Builder<String> 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();

View file

@ -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<? extends EppResource> type;

View file

@ -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<String> result) {
ImmutableSet<String> 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
* }
* </pre>
*/
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

View file

@ -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<HostResource> {
public final class ListHostsAction extends ListObjectsAction<Host> {
public static final String PATH = "/_dr/admin/list/hosts";
@ -48,10 +48,10 @@ public final class ListHostsAction extends ListObjectsAction<HostResource> {
}
@Override
public ImmutableSet<HostResource> loadObjects() {
public ImmutableSet<Host> 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)));
}
}

View file

@ -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<WhoisResponse> getResponse(InternetDomainName hostName, DateTime now) {
Optional<HostResource> hostResource =
Optional<Host> 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));
}
}

View file

@ -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<HostResource> hostsFromDb;
Iterable<Host> 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<HostResource> hosts =
ImmutableList<Host> hosts =
Streams.stream(hostsFromDb)
.filter(
host ->

View file

@ -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<HostResource> hosts;
private final ImmutableList<Host> 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<HostResource> hosts, DateTime timestamp) {
NameserverWhoisResponse(ImmutableList<Host> 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<HostResource> subordinateHosts =
hosts.stream().filter(HostResource::isSubordinate).collect(toImmutableList());
ImmutableMap<HostResource, String> hostRegistrars =
ImmutableList<Host> subordinateHosts =
hosts.stream().filter(Host::isSubordinate).collect(toImmutableList());
ImmutableMap<Host, String> 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)

View file

@ -53,7 +53,7 @@
<class>google.registry.model.domain.secdns.DomainDsDataHistory</class>
<class>google.registry.model.domain.token.AllocationToken</class>
<class>google.registry.model.host.HostHistory</class>
<class>google.registry.model.host.HostResource</class>
<class>google.registry.model.host.Host</class>
<class>google.registry.model.poll.PollMessage</class>
<class>google.registry.model.poll.PollMessage$OneTime</class>
<class>google.registry.model.poll.PollMessage$Autorenew</class>
@ -104,7 +104,7 @@
<class>google.registry.model.contact.VKeyConverter_ContactResource</class>
<class>google.registry.model.domain.VKeyConverter_Domain</class>
<class>google.registry.model.domain.token.VKeyConverter_AllocationToken</class>
<class>google.registry.model.host.VKeyConverter_HostResource</class>
<class>google.registry.model.host.VKeyConverter_Host</class>
<class>google.registry.model.poll.VKeyConverter_Autorenew</class>
<class>google.registry.model.poll.VKeyConverter_OneTime</class>

View file

@ -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);

View file

@ -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(

View file

@ -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<HostResource> nameservers, int numDsRecords) {
String domainName, ImmutableSet<Host> nameservers, int numDsRecords) {
ImmutableSet.Builder<DelegationSignerData> dsDataBuilder = new ImmutableSet.Builder<>();
for (int i = 0; i < numDsRecords; i++) {
dsDataBuilder.add(DelegationSignerData.create(i, 3, 1, base16().decode("1234567890ABCDEF")));
}
ImmutableSet.Builder<VKey<HostResource>> hostResourceRefBuilder = new ImmutableSet.Builder<>();
for (HostResource nameserver : nameservers) {
hostResourceRefBuilder.add(nameserver.createVKey());
ImmutableSet.Builder<VKey<Host>> 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)

View file

@ -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")))

View file

@ -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");

View file

@ -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<DomainCreateFlow, Domain
persistActiveHost("ns1.example.net");
persistActiveContact("jd1234");
persistActiveContact("sh8013");
persistResource(
newHostResource("ns2.example.net").asBuilder().addStatusValue(PENDING_DELETE).build());
persistResource(newHost("ns2.example.net").asBuilder().addStatusValue(PENDING_DELETE).build());
clock.advanceOneMilli();
LinkedResourceInPendingDeleteProhibitsOperationException thrown =
assertThrows(LinkedResourceInPendingDeleteProhibitsOperationException.class, this::runFlow);

View file

@ -44,7 +44,7 @@ import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadByKeyIfPresent;
import static google.registry.testing.DatabaseHelper.loadByKeysIfPresent;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
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.persistDeletedDomain;
@ -88,7 +88,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.ProtocolDefinition.ServiceExtension;
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;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
@ -732,7 +732,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
setUpGracePeriods(
GracePeriod.forBillingEvent(GracePeriodStatus.ADD, domain.getRepoId(), graceBillingEvent));
// Add a nameserver.
HostResource host = persistResource(newHostResource("ns1.example.tld"));
Host host = persistResource(newHost("ns1.example.tld"));
persistResource(
loadByForeignKey(Domain.class, getUniqueIdFromCommand(), clock.nowUtc())
.get()
@ -763,7 +763,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
void testSuccess_deletedSubordinateDomain() throws Exception {
setUpSuccessfulTest();
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand())
newHost("ns1." + getUniqueIdFromCommand())
.asBuilder()
.setSuperordinateDomain(reloadResourceByForeignKey().createVKey())
.setDeletionTime(clock.nowUtc().minusDays(1))
@ -809,9 +809,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_hasSubordinateHosts() throws Exception {
Domain domain = persistActiveDomain(getUniqueIdFromCommand());
HostResource subordinateHost =
Host subordinateHost =
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand())
newHost("ns1." + getUniqueIdFromCommand())
.asBuilder()
.setSuperordinateDomain(reloadResourceByForeignKey().createVKey())
.build());

View file

@ -64,7 +64,7 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
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.persistence.VKey;
@ -101,9 +101,9 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
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<DomainInfoFlow, Domain> {
// 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())

View file

@ -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<F extends Flow, R extends EppResource>
protected ContactResource contact;
protected Domain domain;
HostResource subordinateHost;
Host subordinateHost;
private DomainHistory historyEntryDomainCreate;
DomainTransferFlowTestCase() {
@ -111,7 +111,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
REGISTRATION_EXPIRATION_TIME);
subordinateHost =
persistResource(
new HostResource.Builder()
new Host.Builder()
.setRepoId("2-".concat(Ascii.toUpperCase(tld)))
.setHostName("ns1." + label + "." + tld)
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")

View file

@ -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;

View file

@ -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<DomainUpdateFlow, Domain
}
private Domain persistDomainWithRegistrant() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
Host host = loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get();
Domain domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@ -174,8 +173,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private Domain persistDomain() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
Host host = loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get();
Domain domain =
persistResource(
DatabaseHelper.newDomain(getUniqueIdFromCommand())
@ -289,12 +287,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
}
private void modifyDomainToHave13Nameservers() throws Exception {
ImmutableSet.Builder<VKey<HostResource>> nameservers = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> 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<DomainUpdateFlow, Domain
persistDomain();
setEppInput("domain_update_max_everything.xml");
// Create 26 hosts and 8 contacts. Start the domain with half of them.
ImmutableSet.Builder<VKey<HostResource>> nameservers = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> 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<DomainUpdateFlow, Domain
persistReferencedEntities();
Domain domain = persistDomain();
persistActiveSubordinateHost("ns1.example.tld", domain);
HostResource addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
Host addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
persistResource(
domain
.asBuilder()
@ -402,7 +399,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.addSubordinateHost("ns2.example.tld")
.setNameservers(
ImmutableSet.of(
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
loadByForeignKey(Host.class, "ns1.example.tld", clock.nowUtc())
.get()
.createVKey()))
.build());
@ -412,9 +409,8 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
domain = reloadResourceByForeignKey();
assertThat(domain.getNameservers()).containsExactly(addedHost.createVKey());
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
HostResource existingHost =
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
Host existingHost = loadByForeignKey(Host.class, "ns1.example.tld", clock.nowUtc()).get();
addedHost = loadByForeignKey(Host.class, "ns2.example.tld", clock.nowUtc()).get();
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(domain.createVKey());
}
@ -1421,7 +1417,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.asBuilder()
.setNameservers(
ImmutableSet.of(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())
loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc())
.get()
.createVKey()))
.build());
@ -1507,7 +1503,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistActiveContact("mak21");
persistActiveContact("sh8013");
persistResource(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc())
.get()
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
@ -1562,15 +1558,11 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
assertThat(reloadResourceByForeignKey().getNameservers())
.doesNotContain(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey());
runFlow();
assertThat(reloadResourceByForeignKey().getNameservers())
.contains(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey());
}
@Test
@ -1637,9 +1629,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
reloadResourceByForeignKey()
.asBuilder()
.addNameserver(
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
.get()
.createVKey())
loadByForeignKey(Host.class, "ns2.example.foo", clock.nowUtc()).get().createVKey())
.build());
persistResource(
Registry.get("tld")
@ -1649,15 +1639,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
assertThat(reloadResourceByForeignKey().getNameservers())
.contains(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())
.get()
.createVKey());
loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get().createVKey());
clock.advanceOneMilli();
runFlow();
assertThat(reloadResourceByForeignKey().getNameservers())
.doesNotContain(
Key.create(
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
Key.create(loadByForeignKey(Host.class, "ns1.example.foo", clock.nowUtc()).get()));
}
@Test

View file

@ -24,11 +24,11 @@ import google.registry.flows.EppException;
import google.registry.flows.FlowUtils.NotLoggedInException;
import google.registry.flows.ResourceCheckFlowTestCase;
import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.host.HostResource;
import google.registry.model.host.Host;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostCheckFlow}. */
class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, HostResource> {
class HostCheckFlowTest extends ResourceCheckFlowTestCase<HostCheckFlow, Host> {
HostCheckFlowTest() {
setEppInput("host_check.xml");

View file

@ -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<HostCreateFlow, HostResource> {
class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Host> {
private void setEppHostCreateInput(String hostName, String hostAddrs) {
setEppInput(
@ -83,7 +83,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("host_create_response.xml"));
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
// Check that the host was created and persisted with a history entry.
assertAboutHosts()
.that(host)
@ -124,7 +124,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
@Test
void testSuccess_internalNeverExisted() throws Exception {
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
@ -153,7 +153,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
void testSuccess_internalExistedButWasDeleted() throws Exception {
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
Host host = reloadResourceByForeignKey();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
@ -223,7 +223,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
setEppHostCreateInput("ns1.example.tld", null);
String targetId = getUniqueIdFromCommand();
persistResource(
newHostResource(targetId)
newHost(targetId)
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());

View file

@ -19,12 +19,12 @@ import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_DELETE;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.newHost;
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 google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
@ -44,7 +44,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
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.Type;
import google.registry.model.tld.Registry;
import google.registry.model.transfer.DomainTransferData;
@ -55,7 +55,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostDeleteFlow}. */
class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResource> {
class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, Host> {
@BeforeEach
void initFlowTest() {
@ -111,7 +111,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
private void doFailingStatusTest(StatusValue statusValue, Class<? extends Exception> exception) {
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(statusValue))
.build());
@ -166,7 +166,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@ -187,7 +187,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@ -220,7 +220,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.build())
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@ -254,7 +254,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
.build())
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@ -307,7 +307,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
private void assertSqlDeleteSuccess(boolean isSubordinate) throws Exception {
assertThat(reloadResourceByForeignKey()).isNull();
HostResource deletedHost = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
Host deletedHost = reloadResourceByForeignKey(clock.nowUtc().minusMillis(1));
assertAboutHosts()
.that(deletedHost)
.isNotActiveAt(clock.nowUtc())

View file

@ -35,7 +35,7 @@ import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
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.testing.DatabaseHelper;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
@ -43,7 +43,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link HostInfoFlow}. */
class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource> {
class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, Host> {
@BeforeEach
void initHostTest() {
@ -51,9 +51,9 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
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<HostInfoFlow, HostResource>
@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<HostInfoFlow, HostResource>
@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<HostInfoFlow, HostResource>
.setLastTransferTime(domainTransferTime)
.setPersistedCurrentSponsorRegistrarId("superclientid")
.build());
HostResource firstHost = persistHostResource();
Host firstHost = persistHost();
persistResource(
firstHost
.asBuilder()
@ -166,8 +166,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
@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<HostInfoFlow, HostResource>
@Test
void testIcannActivityReportField_getsLogged() throws Exception {
persistHostResource();
persistHost();
runFlow();
assertIcannReportingActivityFieldLogged("srs-host-info");
}

View file

@ -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<HostUpdateFlow, HostResource> {
class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Host> {
private void setEppHostUpdateInput(
String oldHostName, String newHostName, String ipOrStatusToAdd, String ipOrStatusToRem) {
@ -148,15 +148,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
dryRunFlowAssertResponse(loadFile("generic_success_response.xml"));
}
private HostResource doSuccessfulTest() throws Exception {
private Host doSuccessfulTest() throws Exception {
return doSuccessfulTest(false); // default to normal user privileges
}
private HostResource doSuccessfulTestAsSuperuser() throws Exception {
private Host doSuccessfulTestAsSuperuser() throws Exception {
return doSuccessfulTest(true);
}
private HostResource doSuccessfulTest(boolean isSuperuser) throws Exception {
private Host doSuccessfulTest(boolean isSuperuser) throws Exception {
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(
@ -167,8 +167,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// should now return null.
assertThat(reloadResourceByForeignKey()).isNull();
// However, it should load correctly if we use the new name (taken from the xml).
HostResource renamedHost =
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
Host renamedHost = loadByForeignKey(Host.class, "ns2.example.tld", clock.nowUtc()).get();
assertAboutHosts()
.that(renamedHost)
.hasOnlyOneHistoryEntryWhich()
@ -182,11 +181,11 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_rename_noOtherHostEverUsedTheOldName() throws Exception {
createTld("tld");
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertThat(renamedHost.isSubordinate()).isTrue();
assertDnsTasksEnqueued("ns1.example.tld", "ns2.example.tld");
ForeignKeyIndex<HostResource> oldFkiAfterRename =
ForeignKeyIndex.load(HostResource.class, oldHostName(), clock.nowUtc());
ForeignKeyIndex<Host> oldFkiAfterRename =
ForeignKeyIndex.load(Host.class, oldHostName(), clock.nowUtc());
assertThat(oldFkiAfterRename).isNull();
}
@ -194,15 +193,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_withReferencingDomain() throws Exception {
createTld("tld");
createTld("xn--q9jyb4c");
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistResource(
DatabaseHelper.newDomain("test.xn--q9jyb4c")
.asBuilder()
.setDeletionTime(END_OF_TIME)
.setNameservers(ImmutableSet.of(host.createVKey()))
.build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertThat(renamedHost.isSubordinate()).isTrue();
// Task enqueued to change the NS record of the referencing domain.
assertTasksEnqueued(
@ -217,7 +215,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
setEppInput("host_update_name_unchanged.xml");
createTld("tld");
Domain domain = persistActiveDomain("example.tld");
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
@ -243,7 +241,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
// The example xml doesn't do a host rename, so reloading the host should work.
@ -279,9 +277,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.setLastTransferTime(oneDayAgo)
.build());
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
Host oldHost = persistActiveSubordinateHost(oldHostName(), domain);
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld");
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(domain.createVKey())
@ -314,7 +312,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistActiveSubordinateHost(oldHostName(), foo);
assertThat(foo.getSubordinateHosts()).containsExactly("ns2.foo.tld");
assertThat(example.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@ -350,7 +348,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistActiveSubordinateHost(oldHostName(), fooDomain);
assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo");
assertThat(tldDomain.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@ -386,7 +384,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
DateTime oneDayAgo = clock.nowUtc().minusDays(1);
HostResource oldHost =
Host oldHost =
persistResource(
persistActiveSubordinateHost(oldHostName(), domain)
.asBuilder()
@ -395,7 +393,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertThat(oldHost.isSubordinate()).isTrue();
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.foo");
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(null)
@ -431,7 +429,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
Domain domain = persistActiveDomain("example.tld");
persistActiveHost(oldHostName());
assertThat(domain.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTestAsSuperuser();
Host renamedHost = doSuccessfulTestAsSuperuser();
DateTime now = clock.nowUtc();
assertAboutHosts()
.that(renamedHost)
@ -459,7 +457,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_superuserExternalToExternal() throws Exception {
setEppHostUpdateInput("ns1.example.foo", "ns2.example.tld", null, null);
persistActiveHost(oldHostName());
HostResource renamedHost = doSuccessfulTestAsSuperuser();
Host renamedHost = doSuccessfulTestAsSuperuser();
assertAboutHosts()
.that(renamedHost)
.hasSuperordinateDomain(null)
@ -476,7 +474,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_superuserClientUpdateProhibited() throws Exception {
setEppInput("host_update_add_status.xml");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
@ -519,14 +517,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(null)
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -555,9 +553,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.build());
HostResource host =
Host host =
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(clock.nowUtc().minusDays(20))
@ -565,7 +563,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
DateTime lastTransferTime = host.getLastTransferTime();
persistResource(domain.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -594,7 +592,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(lastTransferTime)
@ -602,7 +600,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -628,7 +626,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(lastTransferTime)
@ -636,7 +634,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -662,14 +660,14 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(foo.createVKey())
.setLastTransferTime(null)
.setLastSuperordinateChange(clock.nowUtc().minusDays(3))
.build());
persistResource(foo.asBuilder().setSubordinateHosts(ImmutableSet.of(oldHostName())).build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -688,10 +686,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.build());
newHost(oldHostName()).asBuilder().setSuperordinateDomain(domain.createVKey()).build());
DateTime lastTransferTime = clock.nowUtc().minusDays(2);
persistResource(
domain
@ -700,7 +695,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
clock.advanceOneMilli();
persistResource(domain.asBuilder().setLastTransferTime(clock.nowUtc().minusDays(1)).build());
// The last transfer time should be what was on the superordinate domain at the time of the host
@ -727,7 +722,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
Domain domain = persistActiveDomain("example.foo");
DateTime lastTransferTime = clock.nowUtc().minusDays(12);
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(lastTransferTime)
@ -740,7 +735,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
clock.advanceOneMilli();
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
// The last transfer time should be what was on the host, because the host's old superordinate
// domain wasn't transferred more recently than when the host was changed to have that
// superordinate domain.
@ -762,7 +757,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setSuperordinateDomain(domain.createVKey())
.setLastTransferTime(clock.nowUtc().minusDays(12))
@ -775,7 +770,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setLastTransferTime(clock.nowUtc().minusDays(2))
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
HostResource renamedHost = doSuccessfulTest();
Host renamedHost = doSuccessfulTest();
// The last transfer time should be what was on the superordinate domain, because the domain
// was transferred more recently than the last time the host's superordinate domain was changed.
assertAboutHosts()
@ -796,8 +791,8 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setLastTransferTime(domainTransferTime)
.build());
persistResource(
newHostResource(oldHostName()).asBuilder().setLastTransferTime(hostTransferTime).build());
HostResource renamedHost = doSuccessfulTestAsSuperuser();
newHost(oldHostName()).asBuilder().setLastTransferTime(hostTransferTime).build());
Host renamedHost = doSuccessfulTestAsSuperuser();
assertAboutHosts()
.that(renamedHost)
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
@ -1015,7 +1010,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_clientUpdateProhibited_removed() throws Exception {
setEppInput("host_update_remove_client_update_prohibited.xml");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
@ -1030,7 +1025,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_clientUpdateProhibited() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@ -1044,7 +1039,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_serverUpdateProhibited() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@ -1058,7 +1053,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_pendingDelete() throws Exception {
createTld("tld");
persistResource(
newHostResource(oldHostName())
newHost(oldHostName())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.setSuperordinateDomain(persistActiveDomain("example.tld").createVKey())
@ -1118,7 +1113,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@ -1140,7 +1135,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@ -1158,7 +1153,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't hurt.
.setSuperordinateDomain(domain.createVKey())
@ -1176,7 +1171,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
newHost("ns1.example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar") // Shouldn't help.
.setSuperordinateDomain(domain.createVKey())
@ -1199,8 +1194,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
assertAboutHosts().that(host).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
EppException thrown = assertThrows(HostDomainNotOwnedException.class, this::runFlow);
@ -1214,8 +1208,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
sessionMetadata.setRegistrarId("TheRegistrar");
createTld("foo");
createTld("tld");
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
Host host = persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
// The domain will belong to NewRegistrar after cloneProjectedAtTime is called.
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
@ -1242,7 +1235,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.build());
assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
persistResource(
newHostResource("ns1.example.foo")
newHost("ns1.example.foo")
.asBuilder()
.setSuperordinateDomain(superordinate.createVKey())
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")

View file

@ -31,8 +31,8 @@ import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.Host;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource;
import google.registry.model.poll.PendingActionNotificationResponse.DomainPendingActionNotificationResponse;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
@ -55,7 +55,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
private Domain domain;
private ContactResource contact;
private HostResource host;
private Host host;
@BeforeEach
void setUp() {

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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)

View file

@ -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))

View file

@ -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<ContactResource> contactKey;
private VKey<ContactResource> contact2Key;
private VKey<HostResource> host1VKey;
private HostResource host;
private VKey<Host> host1VKey;
private Host host;
private ContactResource contact;
private ContactResource contact2;
private ImmutableSet<GracePeriod> 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")

View file

@ -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<HostResource> hostKey = persistActiveHost("ns1.example.com").createVKey();
VKey<Host> 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<VKey<HostResource>> nameservers =
ImmutableSet.of(newHostResource("foo.example.tld").createVKey());
ImmutableSet<VKey<Host>> 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()

View file

@ -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()

View file

@ -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);

View file

@ -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")

View file

@ -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");
}
}

View file

@ -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<HostResource> hostVKey = VKey.createSql(HostResource.class, "host");
VKey<Host> hostVKey = VKey.createSql(Host.class, "host");
VKey<ContactResource> 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)

View file

@ -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();

View file

@ -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<HostResource> vkeyFromNewWebsafeKey =
VKey<Host> 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<HostResource> vkeyFromOldWebsafeString =
VKey.fromWebsafeKey(
"ahdzfmRvbW"
+ "Fpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
// the following is assertion is ensure backwork compatibility
assertThat(vkeyFromNewWebsafeKey).isEqualTo(vkeyFromOldWebsafeString);
"ahdzfmRvbWFpbi1yZWdpc3RyeS1hbHBoYXIhCxIMSG9zdFJlc291cmNlIg82QkIyRjQ3Ni1HT09HTEUM");
}
@Test

View file

@ -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<RdapDomainAction> {
"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<RdapDomainAction> {
.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(

View file

@ -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<RdapDomainSear
private ContactResource contact1;
private ContactResource contact2;
private ContactResource contact3;
private HostResource hostNs1CatLol;
private HostResource hostNs2CatLol;
private HashMap<String, HostResource> hostNameToHostMap = new HashMap<>();
private Host hostNs1CatLol;
private Host hostNs2CatLol;
private HashMap<String, Host> hostNameToHostMap = new HashMap<>();
enum RequestType {
NONE,
@ -120,7 +120,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
return parseJsonObject(response.getPayload());
}
private HostResource addHostToMap(HostResource host) {
private Host addHostToMap(Host host) {
hostNameToHostMap.put(host.getHostName(), host);
return host;
}
@ -146,10 +146,11 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
"5372808-TRL", "The Raven", "bog@cat.lol", clock.nowUtc().minusYears(3), registrar);
hostNs1CatLol =
addHostToMap(
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 =
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)));
domainCatLol =
persistResource(
@ -194,10 +195,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.example", "10.20.30.40", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.dog.lol",
"12:feed:5000:0:0:0:15:beef",
clock.nowUtc().minusYears(2))),
@ -236,7 +237,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
registrar),
hostNs1CatLol,
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.external.tld",
"bad:f00d:cafe:0:0:0:16:beef",
clock.nowUtc().minusYears(2))),
@ -272,10 +273,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.みんな", "1.2.3.5", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.みんな",
"bad:f00d:cafe:0:0:0:14:beef",
clock.nowUtc().minusYears(2))),
@ -311,10 +312,10 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
clock.nowUtc().minusYears(3),
registrar),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.1.test", "1.2.3.5", clock.nowUtc().minusYears(1))),
addHostToMap(
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns2.cat.2.test",
"bad:f00d:cafe:0:0:0:14:beef",
clock.nowUtc().minusYears(2))),
@ -400,20 +401,20 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
private void createManyDomainsAndHosts(
int numActiveDomains, int numTotalDomainsPerActiveDomain, int numHosts) {
ImmutableSet.Builder<VKey<HostResource>> hostKeysBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> hostKeysBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<String> 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<VKey<HostResource>> hostKeys = hostKeysBuilder.build();
ImmutableSet<VKey<Host>> hostKeys = hostKeysBuilder.build();
// Create all the domains at once, then persist them in parallel, for increased efficiency.
ImmutableList.Builder<Domain> domainsBuilder = new ImmutableList.Builder<>();
for (int i = numActiveDomains * numTotalDomainsPerActiveDomain; i >= 1; i--) {

View file

@ -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<RdapEntityAction> {
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

View file

@ -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"));
}

View file

@ -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<RdapNameserverActi
void beforeEach() {
// normal
createTld("lol");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1));
// idn
createTld("xn--q9jyb4c");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.cat.xn--q9jyb4c", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(1));
// multilevel
createTld("1.tld");
makeAndPersistHostResource(
FullFieldsTestEntityHelper.makeAndPersistHost(
"ns1.domain.1.tld", "5.6.7.8", clock.nowUtc().minusYears(1));
// deleted
persistResource(
makeAndPersistHostResource("nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
FullFieldsTestEntityHelper.makeAndPersistHost(
"nsdeleted.cat.lol", "1.2.3.4", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.build());
@ -67,7 +68,8 @@ class RdapNameserverActionTest extends RdapActionBaseTestCase<RdapNameserverActi
persistResource(
makeRegistrar("otherregistrar", "Yes Virginia <script>", 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(

View file

@ -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<RdapNamese
}
private Domain domainCatLol;
private HostResource hostNs1CatLol;
private HostResource hostNs2CatLol;
private Host hostNs1CatLol;
private Host hostNs2CatLol;
private JsonObject generateActualJsonWithName(String name) {
return generateActualJsonWithName(name, null);
@ -107,25 +106,29 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
makeRegistrar("evilregistrar", "Yes Virginia <script>", 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<RdapNamese
}
private void createManyHosts(int numHosts) {
ImmutableList.Builder<HostResource> hostsBuilder = new ImmutableList.Builder<>();
ImmutableList.Builder<Host> hostsBuilder = new ImmutableList.Builder<>();
ImmutableSet.Builder<String> 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 RdapSearchActionTestCase<RdapNamese
private void createDeletedHost() {
persistResource(
makeAndPersistHostResource("nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1))
FullFieldsTestEntityHelper.makeAndPersistHost(
"nsdeleted.cat.lol", "4.3.2.1", clock.nowUtc().minusYears(1))
.asBuilder()
.setDeletionTime(clock.nowUtc().minusMonths(1))
.build());

View file

@ -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.poll.PollMessage.Autorenew;
import google.registry.model.rde.RdeMode;
@ -275,9 +275,8 @@ public class DomainToXjcConverterTest {
.setLastEppUpdateTime(DateTime.parse("1920-01-01T00:00:00Z"))
.setNameservers(
ImmutableSet.of(
makeHostResource(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4")
.createVKey(),
makeHostResource(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
makeHost(clock, "3-Q9JYB4C", "bird.or.devil.みんな", "1.2.3.4").createVKey(),
makeHost(clock, "4-Q9JYB4C", "ns2.cat.みんな", "bad:f00d:cafe::15:beef")
.createVKey()))
.setRegistrant(
makeContactResource(
@ -412,11 +411,10 @@ public class DomainToXjcConverterTest {
.build());
}
private static HostResource makeHostResource(
FakeClock clock, String repoId, String fqhn, String ip) {
private static Host makeHost(FakeClock clock, String repoId, String fqhn, String ip) {
clock.advanceOneMilli();
return persistEppResource(
new HostResource.Builder()
new Host.Builder()
.setCreationRegistrarId("TheRegistrar")
.setCreationTimeForTest(DateTime.parse("1900-01-01T00:00:00Z"))
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")

View file

@ -24,7 +24,7 @@ import com.google.common.collect.ImmutableSet;
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.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.xjc.host.XjcHostStatusType;
@ -38,12 +38,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Unit tests for {@link HostResourceToXjcConverter}.
* Unit tests for {@link HostToXjcConverter}.
*
* <p>This tests the mapping between {@link HostResource} and {@link XjcRdeHost} as well as some
* exceptional conditions.
* <p>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")

View file

@ -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())

View file

@ -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,

View file

@ -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()

View file

@ -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<VKey<HostResource>> hostKeys =
Arrays.stream(hosts).map(HostResource::createVKey).collect(toImmutableSet());
public static Domain newDomain(String domainName, Host... hosts) {
ImmutableSet<VKey<Host>> 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;

View file

@ -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<VKey<HostResource>> nsBuilder = new ImmutableSet.Builder<>();
ImmutableSet.Builder<VKey<Host>> nsBuilder = new ImmutableSet.Builder<>();
if (ns1 != null) {
nsBuilder.add(ns1.createVKey());
}

View file

@ -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<HostResource, HostResourceSubject> {
/** Truth subject for asserting things about {@link Host} instances. */
public final class HostSubject extends AbstractEppResourceSubject<Host, HostSubject> {
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<HostResourceSubject, HostResource> assertAboutHosts() {
return assertAbout(HostResourceSubject::new);
public static SimpleSubjectBuilder<HostSubject, Host> assertAboutHosts() {
return assertAbout(HostSubject::new);
}
public And<HostResourceSubject> hasLastTransferTime(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTime(DateTime lastTransferTime) {
return hasValue(lastTransferTime, actual.getLastTransferTime(), "has lastTransferTime");
}
public And<HostResourceSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
public And<HostSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
return doesNotHaveValue(lastTransferTime, actual.getLastTransferTime(), "lastTransferTime");
}
public And<HostResourceSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
public And<HostSubject> hasLastSuperordinateChange(DateTime lastSuperordinateChange) {
return hasValue(
lastSuperordinateChange,
actual.getLastSuperordinateChange(),
"has lastSuperordinateChange");
}
public And<HostResourceSubject> hasSuperordinateDomain(
@Nullable VKey<Domain> superordinateDomain) {
public And<HostSubject> hasSuperordinateDomain(@Nullable VKey<Domain> superordinateDomain) {
return hasValue(
superordinateDomain, actual.getSuperordinateDomain(), "has superordinateDomain");
}

View file

@ -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 =

View file

@ -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<GenerateDnsReportComm
}
}
private HostResource nameserver1;
private HostResource nameserver2;
private HostResource nameserver3;
private HostResource nameserver4;
private Host nameserver1;
private Host nameserver2;
private Host nameserver3;
private Host nameserver4;
private Domain domain1;
private static final ImmutableList<?> DS_DATA_OUTPUT = ImmutableList.of(
@ -121,20 +121,24 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
clock.setTo(now);
createTlds("xn--q9jyb4c", "example");
nameserver1 = persistResource(
newHostResource("ns1.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("2607:f8b0:400d:c00::c0"),
InetAddresses.forString("192.168.1.2")))
.build());
nameserver2 = persistResource(
newHostResource("ns2.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(ImmutableSet.of(
InetAddresses.forString("192.168.1.1"),
InetAddresses.forString("2607:f8b0:400d:c00::c1")))
.build());
nameserver1 =
persistResource(
newHost("ns1.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
InetAddresses.forString("2607:f8b0:400d:c00::c0"),
InetAddresses.forString("192.168.1.2")))
.build());
nameserver2 =
persistResource(
newHost("ns2.example.xn--q9jyb4c")
.asBuilder()
.setInetAddresses(
ImmutableSet.of(
InetAddresses.forString("192.168.1.1"),
InetAddresses.forString("2607:f8b0:400d:c00::c1")))
.build());
nameserver3 = persistActiveHost("ns1.google.com");
nameserver4 = persistActiveHost("ns2.google.com");
domain1 =

Some files were not shown because too many files have changed in this diff Show more