Rename DomainBase -> Domain (#1725)

* Rename DomainBase -> Domain

This was a long time coming, but we couldn't do it until we left Datastore, as
the Java class name has to match the Datastore entity name.

Subsequent PRs will rename ContactResource to Contact and HostResource to Host,
so that everything matches the SQL table names (and is shorter!).

* Merge branch 'master' into rename-domainbase
This commit is contained in:
Ben McIlwain
2022-08-02 16:03:30 -04:00
committed by GitHub
parent 827b7db227
commit ede919d7dc
226 changed files with 1746 additions and 2630 deletions
@@ -21,7 +21,6 @@ import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -33,13 +32,14 @@ import google.registry.flows.EppTestComponent.FakesAndMocksModule;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.ofy.Ofy;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.transaction.QueryComposer.Comparator;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeLockHandler;
import google.registry.testing.FakeResponse;
@@ -82,21 +82,21 @@ class DeleteExpiredDomainsActionTest {
@Test
void test_deletesOnlyExpiredDomain() {
// A normal, active autorenewing domain that shouldn't be touched.
DomainBase activeDomain = persistActiveDomain("foo.tld");
Domain activeDomain = persistActiveDomain("foo.tld");
// A non-autorenewing domain that is already pending delete and shouldn't be touched.
DomainBase alreadyDeletedDomain =
Domain alreadyDeletedDomain =
persistResource(
newDomainBase("bar.tld")
DatabaseHelper.newDomain("bar.tld")
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().minusDays(10)))
.setDeletionTime(clock.nowUtc().plusDays(17))
.build());
// A non-autorenewing domain that hasn't reached its expiration time and shouldn't be touched.
DomainBase notYetExpiredDomain =
Domain notYetExpiredDomain =
persistResource(
newDomainBase("baz.tld")
DatabaseHelper.newDomain("baz.tld")
.asBuilder()
.setAutorenewEndTime(Optional.of(clock.nowUtc().plusDays(15)))
.build());
@@ -104,7 +104,7 @@ class DeleteExpiredDomainsActionTest {
// A non-autorenewing domain that is past its expiration time and should be deleted.
// (This is the only one that needs a full set of subsidiary resources, for the delete flow to
// to operate on.)
DomainBase pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld");
Domain pendingExpirationDomain = persistNonAutorenewingDomain("fizz.tld");
assertThat(loadByEntity(pendingExpirationDomain).getStatusValues())
.doesNotContain(PENDING_DELETE);
@@ -114,21 +114,21 @@ class DeleteExpiredDomainsActionTest {
clock.advanceOneMilli();
action.run();
DomainBase reloadedActiveDomain = loadByEntity(activeDomain);
Domain reloadedActiveDomain = loadByEntity(activeDomain);
assertThat(reloadedActiveDomain).isEqualTo(activeDomain);
assertThat(reloadedActiveDomain.getStatusValues()).doesNotContain(PENDING_DELETE);
assertThat(loadByEntity(alreadyDeletedDomain)).isEqualTo(alreadyDeletedDomain);
assertThat(loadByEntity(notYetExpiredDomain)).isEqualTo(notYetExpiredDomain);
DomainBase reloadedExpiredDomain = loadByEntity(pendingExpirationDomain);
Domain reloadedExpiredDomain = loadByEntity(pendingExpirationDomain);
assertThat(reloadedExpiredDomain.getStatusValues()).contains(PENDING_DELETE);
assertThat(reloadedExpiredDomain.getDeletionTime()).isEqualTo(clock.nowUtc().plusDays(35));
}
@Test
void test_deletesThreeDomainsInOneRun() throws Exception {
DomainBase domain1 = persistNonAutorenewingDomain("ecck1.tld");
DomainBase domain2 = persistNonAutorenewingDomain("veee2.tld");
DomainBase domain3 = persistNonAutorenewingDomain("tarm3.tld");
Domain domain1 = persistNonAutorenewingDomain("ecck1.tld");
Domain domain2 = persistNonAutorenewingDomain("veee2.tld");
Domain domain3 = persistNonAutorenewingDomain("tarm3.tld");
// action.run() executes an ancestor-less query which is subject to eventual consistency (it
// uses an index that is updated asynchronously). For a deterministic test outcome, we busy
@@ -139,10 +139,10 @@ class DeleteExpiredDomainsActionTest {
tm().transact(
() ->
tm()
.createQueryComposer(DomainBase.class)
.createQueryComposer(Domain.class)
.where("autorenewEndTime", Comparator.LTE, clock.nowUtc())
.stream()
.map(DomainBase::getDomainName)
.map(Domain::getDomainName)
.collect(toImmutableSet()));
if (matchingDomains.containsAll(ImmutableSet.of("ecck1.tld", "veee2.tld", "tarm3.tld"))) {
break;
@@ -164,8 +164,8 @@ class DeleteExpiredDomainsActionTest {
assertThat(loadByEntity(domain3).getStatusValues()).contains(PENDING_DELETE);
}
private DomainBase persistNonAutorenewingDomain(String domainName) {
DomainBase pendingExpirationDomain = persistActiveDomain(domainName);
private Domain persistNonAutorenewingDomain(String domainName) {
Domain pendingExpirationDomain = persistActiveDomain(domainName);
DomainHistory createHistoryEntry =
persistResource(
new DomainHistory.Builder()
@@ -22,7 +22,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntitiesIfPresent;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
@@ -42,7 +41,7 @@ import google.registry.dns.DnsQueue;
import google.registry.model.ImmutableObject;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.index.EppResourceIndex;
import google.registry.model.index.ForeignKeyIndex;
@@ -51,6 +50,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldType;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.SystemPropertyExtension;
import java.util.Optional;
@@ -173,7 +173,7 @@ class DeleteProberDataActionTest {
@Test
void testSuccess_doesntDeleteNicDomainForProbers() throws Exception {
DomainBase nic = persistActiveDomain("nic.ib-any.test");
Domain nic = persistActiveDomain("nic.ib-any.test");
Set<ImmutableObject> ibEntities = persistLotsOfDomains("ib-any.test");
action.run();
assertAllAbsent(ibEntities);
@@ -192,32 +192,32 @@ class DeleteProberDataActionTest {
@Test
void testSuccess_activeDomain_isSoftDeleted() throws Exception {
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("blah.ib-any.test")
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
action.run();
DateTime timeAfterDeletion = DateTime.now(UTC);
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty();
assertThat(loadByForeignKey(Domain.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty();
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test");
}
@Test
void testSuccess_activeDomain_doubleMapSoftDeletes() throws Exception {
DomainBase domain = persistResource(
newDomainBase("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
Domain domain =
persistResource(
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
action.run();
DateTime timeAfterDeletion = DateTime.now(UTC);
resetAction();
action.run();
assertThat(loadByForeignKey(DomainBase.class, "blah.ib-any.test", timeAfterDeletion))
.isEmpty();
assertThat(loadByForeignKey(Domain.class, "blah.ib-any.test", timeAfterDeletion)).isEmpty();
assertThat(loadByEntity(domain).getDeletionTime()).isLessThan(timeAfterDeletion);
assertDnsTasksEnqueued("blah.ib-any.test");
}
@@ -225,22 +225,21 @@ class DeleteProberDataActionTest {
@Test
void test_recentlyCreatedDomain_isntDeletedYet() throws Exception {
persistResource(
newDomainBase("blah.ib-any.test")
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1))
.build());
action.run();
Optional<DomainBase> domain =
loadByForeignKey(DomainBase.class, "blah.ib-any.test", DateTime.now(UTC));
Optional<Domain> domain = loadByForeignKey(Domain.class, "blah.ib-any.test", DateTime.now(UTC));
assertThat(domain).isPresent();
assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME);
}
@Test
void testDryRun_doesntSoftDeleteData() throws Exception {
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("blah.ib-any.test")
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
@@ -252,11 +251,11 @@ class DeleteProberDataActionTest {
@Test
void test_domainWithSubordinateHosts_isSkipped() throws Exception {
persistActiveHost("ns1.blah.ib-any.test");
DomainBase nakedDomain =
Domain nakedDomain =
persistDeletedDomain("todelete.ib-any.test", DateTime.now(UTC).minusYears(1));
DomainBase domainWithSubord =
Domain domainWithSubord =
persistDomainAsDeleted(
newDomainBase("blah.ib-any.test")
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of("ns1.blah.ib-any.test"))
.build(),
@@ -270,7 +269,7 @@ class DeleteProberDataActionTest {
@Test
void testFailure_registryAdminClientId_isRequiredForSoftDeletion() {
persistResource(
newDomainBase("blah.ib-any.test")
DatabaseHelper.newDomain("blah.ib-any.test")
.asBuilder()
.setCreationTimeForTest(DateTime.now(UTC).minusYears(1))
.build());
@@ -284,7 +283,7 @@ class DeleteProberDataActionTest {
* along with the ForeignKeyIndex and EppResourceIndex.
*/
private static Set<ImmutableObject> persistDomainAndDescendants(String fqdn) {
DomainBase domain = persistDeletedDomain(fqdn, DELETION_TIME);
Domain domain = persistDeletedDomain(fqdn, DELETION_TIME);
DomainHistory historyEntry =
persistSimpleResource(
new DomainHistory.Builder()
@@ -321,7 +320,7 @@ class DeleteProberDataActionTest {
.add(pollMessage);
if (tm().isOfy()) {
builder
.add(ForeignKeyIndex.load(DomainBase.class, fqdn, START_OF_TIME))
.add(ForeignKeyIndex.load(Domain.class, fqdn, START_OF_TIME))
.add(loadByEntity(EppResourceIndex.create(Key.create(domain))));
}
return builder.build();
@@ -26,7 +26,6 @@ import static google.registry.testing.DatabaseHelper.assertBillingEventsForResou
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getHistoryEntriesOfType;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -46,7 +45,7 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.common.Cursor;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
import google.registry.model.reporting.DomainTransactionRecord;
@@ -54,6 +53,7 @@ import google.registry.model.reporting.DomainTransactionRecord.TransactionReport
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeResponse;
import java.util.ArrayList;
@@ -76,7 +76,7 @@ public class ExpandRecurringBillingEventsActionTest {
private final FakeClock clock = new FakeClock(currentTestTime);
private ExpandRecurringBillingEventsAction action;
private DomainBase domain;
private Domain domain;
private DomainHistory historyEntry;
private BillingEvent.Recurring recurring;
@@ -91,7 +91,7 @@ public class ExpandRecurringBillingEventsActionTest {
createTld("tld");
domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("1999-01-05T00:00:00Z"))
.build());
@@ -138,7 +138,7 @@ public class ExpandRecurringBillingEventsActionTest {
}
private void assertHistoryEntryMatches(
DomainBase domain,
Domain domain,
HistoryEntry actual,
String registrarId,
DateTime billingTime,
@@ -193,7 +193,7 @@ public class ExpandRecurringBillingEventsActionTest {
@Test
void testSuccess_expandSingleEvent_deletedDomain() throws Exception {
DateTime deletionTime = DateTime.parse("2000-08-01T00:00:00Z");
DomainBase deletedDomain = persistDeletedDomain("deleted.tld", deletionTime);
Domain deletedDomain = persistDeletedDomain("deleted.tld", deletionTime);
historyEntry =
persistResource(
new DomainHistory.Builder()
@@ -641,9 +641,9 @@ public class ExpandRecurringBillingEventsActionTest {
@Test
void testSuccess_expandMultipleEvents() throws Exception {
persistResource(recurring);
DomainBase domain2 =
Domain domain2 =
persistResource(
newDomainBase("example2.tld")
DatabaseHelper.newDomain("example2.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("1999-04-05T00:00:00Z"))
.build());
@@ -666,9 +666,9 @@ public class ExpandRecurringBillingEventsActionTest {
.setRecurrenceEndTime(END_OF_TIME)
.setTargetId(domain2.getDomainName())
.build());
DomainBase domain3 =
Domain domain3 =
persistResource(
newDomainBase("example3.tld")
DatabaseHelper.newDomain("example3.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("1999-06-05T00:00:00Z"))
.build());
@@ -21,7 +21,6 @@ import static google.registry.model.eppcommon.StatusValue.PENDING_TRANSFER;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.deleteTestDomain;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -36,12 +35,13 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import com.google.cloud.tasks.v2.HttpMethod;
import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.RegistryLock;
import google.registry.model.host.HostResource;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.DeterministicStringGenerator;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeResponse;
@@ -87,7 +87,7 @@ public class RelockDomainActionTest {
.withUserService(UserInfo.create(POC_ID, "12345"))
.build();
private DomainBase domain;
private Domain domain;
private RegistryLock oldLock;
@Mock private SendEmailService sendEmailService;
private RelockDomainAction action;
@@ -96,7 +96,7 @@ public class RelockDomainActionTest {
void beforeEach() throws Exception {
createTlds("tld", "net");
HostResource host = persistActiveHost("ns1.example.net");
domain = persistResource(newDomainBase(DOMAIN_NAME, host));
domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host));
oldLock = domainLockUtils.administrativelyApplyLock(DOMAIN_NAME, CLIENT_ID, POC_ID, false);
assertThat(loadByEntity(domain).getStatusValues())
@@ -20,7 +20,7 @@ import static google.registry.batch.AsyncTaskEnqueuer.PARAM_RESOURCE_KEY;
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
@@ -31,7 +31,7 @@ import static org.mockito.Mockito.verify;
import com.google.cloud.tasks.v2.HttpMethod;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.eppcommon.StatusValue;
@@ -40,6 +40,7 @@ import google.registry.request.Response;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectExtension;
import org.joda.time.DateTime;
@@ -88,7 +89,7 @@ public class ResaveEntityActionTest {
@MockitoSettings(strictness = Strictness.LENIENT)
@Test
void test_domainPendingTransfer_isResavedAndTransferCompleted() {
DomainBase domain =
Domain domain =
persistDomainWithPendingTransfer(
persistDomainWithDependentResources(
"domain",
@@ -106,15 +107,15 @@ public class ResaveEntityActionTest {
domain.createVKey().getOfyKey().getString(),
DateTime.parse("2016-02-06T10:00:01Z"),
ImmutableSortedSet.of());
DomainBase resavedDomain = loadByEntity(domain);
Domain resavedDomain = loadByEntity(domain);
assertThat(resavedDomain.getCurrentSponsorRegistrarId()).isEqualTo("NewRegistrar");
verify(response).setPayload("Entity re-saved.");
}
@Test
void test_domainPendingDeletion_isResavedAndReenqueued() {
DomainBase newDomain = newDomainBase("domain.tld");
DomainBase domain =
Domain newDomain = DatabaseHelper.newDomain("domain.tld");
Domain domain =
persistResource(
newDomain
.asBuilder()
@@ -136,7 +137,7 @@ public class ResaveEntityActionTest {
domain.createVKey().getOfyKey().getString(),
requestedTime,
ImmutableSortedSet.of(requestedTime.plusDays(5)));
DomainBase resavedDomain = loadByEntity(domain);
Domain resavedDomain = loadByEntity(domain);
assertThat(resavedDomain.getGracePeriods()).isEmpty();
cloudTasksHelper.assertTasksEnqueued(
@@ -27,8 +27,8 @@ import google.registry.beam.TestPipelineExtension;
import google.registry.beam.common.RegistryJpaIO.Read;
import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -116,9 +116,9 @@ public class RegistryJpaReadTest {
ImmutableMap.of("type", Registrar.Type.REAL),
false,
(Object[] row) -> {
DomainBase domainBase = (DomainBase) row[0];
Domain domain = (Domain) row[0];
String emailAddress = (String) row[1];
return domainBase.getRepoId() + "-" + emailAddress;
return domain.getRepoId() + "-" + emailAddress;
});
PCollection<String> joinedStrings = testPipeline.apply(read);
@@ -150,14 +150,14 @@ public class RegistryJpaReadTest {
@Test
void readWithStringTypedQuery() {
setupForJoinQuery();
Read<DomainBase, String> read =
Read<Domain, String> read =
RegistryJpaIO.read(
"select d from Domain d join Registrar r on"
+ " d.currentSponsorClientId = r.clientIdentifier where r.type = :type"
+ " and d.deletionTime > now()",
ImmutableMap.of("type", Registrar.Type.REAL),
DomainBase.class,
DomainBase::getRepoId);
Domain.class,
Domain::getRepoId);
PCollection<String> repoIds = testPipeline.apply(read);
PAssert.that(repoIds).containsInAnyOrder("4-COM");
@@ -179,8 +179,8 @@ public class RegistryJpaReadTest {
.setTransferData(new ContactTransferData.Builder().build())
.setPersistedCurrentSponsorRegistrarId(registrar.getRegistrarId())
.build();
DomainBase domain =
new DomainBase.Builder()
Domain domain =
new Domain.Builder()
.setDomainName("example.com")
.setRepoId("4-COM")
.setCreationRegistrarId(registrar.getRegistrarId())
@@ -41,7 +41,7 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.HistoryEntry;
@@ -303,7 +303,7 @@ class InvoicingPipelineTest {
.setInvoicingEnabled(true)
.build();
persistResource(test);
DomainBase domain = persistActiveDomain("mycanadiandomain.test");
Domain domain = persistActiveDomain("mycanadiandomain.test");
persistOneTimeBillingEvent(25, domain, registrar, Reason.RENEW, 3, Money.of(CAD, 20.5));
PCollection<BillingEvent> billingEvents = InvoicingPipeline.readFromCloudSql(options, pipeline);
@@ -415,13 +415,13 @@ class InvoicingPipelineTest {
.build();
persistResource(hello);
DomainBase domain1 = persistActiveDomain("mydomain.test");
DomainBase domain2 = persistActiveDomain("mydomain2.test");
DomainBase domain3 = persistActiveDomain("mydomain3.hello");
DomainBase domain4 = persistActiveDomain("mydomain4.test");
DomainBase domain5 = persistActiveDomain("mydomain5.test");
DomainBase domain6 = persistActiveDomain("locked.test");
DomainBase domain7 = persistActiveDomain("update-prohibited.test");
Domain domain1 = persistActiveDomain("mydomain.test");
Domain domain2 = persistActiveDomain("mydomain2.test");
Domain domain3 = persistActiveDomain("mydomain3.hello");
Domain domain4 = persistActiveDomain("mydomain4.test");
Domain domain5 = persistActiveDomain("mydomain5.test");
Domain domain6 = persistActiveDomain("locked.test");
Domain domain7 = persistActiveDomain("update-prohibited.test");
persistOneTimeBillingEvent(1, domain1, registrar1, Reason.RENEW, 3, Money.of(USD, 20.5));
persistOneTimeBillingEvent(2, domain2, registrar1, Reason.RENEW, 3, Money.of(USD, 20.5));
@@ -453,7 +453,7 @@ class InvoicingPipelineTest {
Registrar registrar4 = persistNewRegistrar("noBillRegistrar");
registrar4 = registrar4.asBuilder().setBillingAccountMap(null).build();
persistResource(registrar4);
DomainBase domain8 = persistActiveDomain("non-billable.test");
Domain domain8 = persistActiveDomain("non-billable.test");
persistOneTimeBillingEvent(8, domain8, registrar4, Reason.RENEW, 3, Money.of(USD, 20.5));
// Add billing event for a non-real registrar
@@ -466,16 +466,16 @@ class InvoicingPipelineTest {
.setType(Registrar.Type.OTE)
.build();
persistResource(registrar5);
DomainBase domain9 = persistActiveDomain("not-real.test");
Domain domain9 = persistActiveDomain("not-real.test");
persistOneTimeBillingEvent(9, domain9, registrar5, Reason.RENEW, 3, Money.of(USD, 20.5));
// Add billing event for a non-invoicing TLD
createTld("nobill");
DomainBase domain10 = persistActiveDomain("test.nobill");
Domain domain10 = persistActiveDomain("test.nobill");
persistOneTimeBillingEvent(10, domain10, registrar1, Reason.RENEW, 3, Money.of(USD, 20.5));
// Add billing event before October 2017
DomainBase domain11 = persistActiveDomain("july.test");
Domain domain11 = persistActiveDomain("july.test");
persistOneTimeBillingEvent(
11,
domain11,
@@ -487,7 +487,7 @@ class InvoicingPipelineTest {
DateTime.parse("2017-07-02T00:00:00.0Z"));
// Add a billing event with a corresponding cancellation
DomainBase domain12 = persistActiveDomain("cancel.test");
Domain domain12 = persistActiveDomain("cancel.test");
OneTime oneTime =
persistOneTimeBillingEvent(12, domain12, registrar1, Reason.RENEW, 3, Money.of(USD, 20.5));
DomainHistory domainHistory = persistDomainHistory(domain12, registrar1);
@@ -507,7 +507,7 @@ class InvoicingPipelineTest {
persistResource(cancellation);
// Add billing event with a corresponding recurring billing event and cancellation
DomainBase domain13 = persistActiveDomain("cancel-recurring.test");
Domain domain13 = persistActiveDomain("cancel-recurring.test");
DomainHistory domainHistoryRecurring = persistDomainHistory(domain13, registrar1);
Recurring recurring =
@@ -548,22 +548,22 @@ class InvoicingPipelineTest {
persistResource(cancellationRecurring);
}
private static DomainHistory persistDomainHistory(DomainBase domainBase, Registrar registrar) {
private static DomainHistory persistDomainHistory(Domain domain, Registrar registrar) {
DomainHistory domainHistory =
new DomainHistory.Builder()
.setType(HistoryEntry.Type.DOMAIN_RENEW)
.setModificationTime(DateTime.parse("2017-10-04T00:00:00.0Z"))
.setDomain(domainBase)
.setDomain(domain)
.setRegistrarId(registrar.getRegistrarId())
.build();
return persistResource(domainHistory);
}
private static OneTime persistOneTimeBillingEvent(
int id, DomainBase domainBase, Registrar registrar, Reason reason, int years, Money money) {
int id, Domain domain, Registrar registrar, Reason reason, int years, Money money) {
return persistOneTimeBillingEvent(
id,
domainBase,
domain,
registrar,
reason,
years,
@@ -574,7 +574,7 @@ class InvoicingPipelineTest {
private static OneTime persistOneTimeBillingEvent(
int id,
DomainBase domainBase,
Domain domain,
Registrar registrar,
Reason reason,
int years,
@@ -590,10 +590,10 @@ class InvoicingPipelineTest {
.setEventTime(eventTime)
.setRegistrarId(registrar.getRegistrarId())
.setReason(reason)
.setTargetId(domainBase.getDomainName())
.setTargetId(domain.getDomainName())
.setCost(money)
.setFlags(Arrays.stream(flags).collect(toImmutableSet()))
.setDomainHistory(persistDomainHistory(domainBase, registrar));
.setDomainHistory(persistDomainHistory(domain, registrar));
if (years > 0) {
billingEventBuilder.setPeriodYears(years);
@@ -31,7 +31,6 @@ import static google.registry.testing.AppEngineExtension.makeRegistrar1;
import static google.registry.testing.AppEngineExtension.makeRegistrar2;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertSimpleResources;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -58,7 +57,7 @@ import google.registry.model.contact.ContactBase;
import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
@@ -84,6 +83,7 @@ import google.registry.rde.PendingDeposit;
import google.registry.rde.RdeResourceType;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.DatastoreEntityExtension;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeKeyringModule;
@@ -274,9 +274,9 @@ public class RdePipelineTest {
persistHostHistory(persistActiveHost("ns0.domain.tld"));
HostResource host1 = persistActiveHost("ns1.external.tld");
persistHostHistory(host1);
DomainBase helloDomain =
Domain helloDomain =
persistEppResource(
newDomainBase("hello.soy", contact1)
DatabaseHelper.newDomain("hello.soy", contact1)
.asBuilder()
.addNameserver(host1.createVKey())
.build());
@@ -284,17 +284,17 @@ public class RdePipelineTest {
persistHostHistory(persistActiveHost("not-used-subordinate.hello.soy"));
HostResource host2 = persistActiveHost("ns1.hello.soy");
persistHostHistory(host2);
DomainBase kittyDomain =
Domain kittyDomain =
persistEppResource(
newDomainBase("kitty.fun", contact2)
DatabaseHelper.newDomain("kitty.fun", contact2)
.asBuilder()
.addNameservers(ImmutableSet.of(host1.createVKey(), host2.createVKey()))
.build());
persistDomainHistory(kittyDomain);
// Should not appear because the TLD is not included in a pending deposit.
persistDomainHistory(persistEppResource(newDomainBase("lol.cat", contact1)));
persistDomainHistory(persistEppResource(DatabaseHelper.newDomain("lol.cat", contact1)));
// To be deleted.
DomainBase deletedDomain = persistActiveDomain("deleted.soy");
Domain deletedDomain = persistActiveDomain("deleted.soy");
persistDomainHistory(deletedDomain);
// Advance time
@@ -335,7 +335,7 @@ public class RdePipelineTest {
persistHostHistory(futureHost);
persistDomainHistory(
persistEppResource(
newDomainBase("future.soy", futureContact)
DatabaseHelper.newDomain("future.soy", futureContact)
.asBuilder()
.setNameservers(futureHost.createVKey())
.build()));
@@ -33,7 +33,7 @@ import static org.mockito.Mockito.verify;
import google.registry.beam.TestPipelineExtension;
import google.registry.model.EppResource;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.StatusValue;
import google.registry.persistence.transaction.JpaTestExtensions;
@@ -106,7 +106,7 @@ public class ResaveAllEppResourcesPipelineTest {
void testPipeline_fulfilledDomainTransfer() {
options.setFast(true);
DateTime now = fakeClock.nowUtc();
DomainBase domain =
Domain domain =
persistDomainWithPendingTransfer(
persistDomainWithDependentResources(
"domain",
@@ -122,7 +122,7 @@ public class ResaveAllEppResourcesPipelineTest {
assertThat(domain.getUpdateTimestamp().getTimestamp()).isEqualTo(now);
fakeClock.advanceOneMilli();
runPipeline();
DomainBase postPipeline = loadByEntity(domain);
Domain postPipeline = loadByEntity(domain);
assertThat(postPipeline.getStatusValues()).doesNotContain(StatusValue.PENDING_TRANSFER);
assertThat(postPipeline.getUpdateTimestamp().getTimestamp()).isEqualTo(fakeClock.nowUtc());
}
@@ -130,13 +130,13 @@ public class ResaveAllEppResourcesPipelineTest {
@Test
void testPipeline_autorenewedDomain() {
DateTime now = fakeClock.nowUtc();
DomainBase domain =
Domain domain =
persistDomainWithDependentResources(
"domain", "tld", persistActiveContact("jd1234"), now, now, now.plusYears(1));
assertThat(domain.getRegistrationExpirationTime()).isEqualTo(now.plusYears(1));
fakeClock.advanceBy(Duration.standardDays(500));
runPipeline();
DomainBase postPipeline = loadByEntity(domain);
Domain postPipeline = loadByEntity(domain);
assertThat(postPipeline.getRegistrationExpirationTime()).isEqualTo(now.plusYears(2));
}
@@ -160,7 +160,7 @@ public class ResaveAllEppResourcesPipelineTest {
// Spy the transaction manager so we can be sure we're only saving the renewed domain
JpaTransactionManager spy = spy(jpaTm());
TransactionManagerFactory.setJpaTm(() -> spy);
ArgumentCaptor<DomainBase> domainPutCaptor = ArgumentCaptor.forClass(DomainBase.class);
ArgumentCaptor<Domain> domainPutCaptor = ArgumentCaptor.forClass(Domain.class);
runPipeline();
// We should only be attempting to put the one changed domain into the DB
verify(spy).put(domainPutCaptor.capture());
@@ -172,9 +172,9 @@ public class ResaveAllEppResourcesPipelineTest {
options.setFast(false);
DateTime now = fakeClock.nowUtc();
ContactResource contact = persistActiveContact("jd1234");
DomainBase renewed =
Domain renewed =
persistDomainWithDependentResources("renewed", "tld", contact, now, now, now.plusYears(1));
DomainBase nonRenewed =
Domain nonRenewed =
persistDomainWithDependentResources(
"nonrenewed", "tld", contact, now, now, now.plusYears(20));
// Spy the transaction manager so we can be sure we're attempting to save everything
@@ -38,8 +38,8 @@ import google.registry.beam.TestPipelineExtension;
import google.registry.beam.spec11.SafeBrowsingTransforms.EvaluateSafeBrowsingFn;
import google.registry.beam.spec11.SafeBrowsingTransformsTest.HttpResponder;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.registrar.Registrar;
import google.registry.model.reporting.Spec11ThreatMatch;
@@ -296,9 +296,9 @@ class Spec11PipelineTest {
});
}
private DomainBase createDomain(
private Domain createDomain(
String domainName, String repoId, Registrar registrar, ContactResource contact) {
return new DomainBase.Builder()
return new Domain.Builder()
.setDomainName(domainName)
.setRepoId(repoId)
.setCreationRegistrarId(registrar.getRegistrarId())
@@ -44,7 +44,7 @@ import google.registry.dns.DnsMetrics.ActionStatus;
import google.registry.dns.DnsMetrics.CommitStatus;
import google.registry.dns.DnsMetrics.PublishStatus;
import google.registry.dns.writer.DnsWriter;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.ofy.Ofy;
import google.registry.model.tld.Registry;
import google.registry.request.HttpException.ServiceUnavailableException;
@@ -90,10 +90,10 @@ public class PublishDnsUpdatesActionTest {
.asBuilder()
.setDnsWriters(ImmutableSet.of("correctWriter"))
.build());
DomainBase domain1 = persistActiveDomain("example.xn--q9jyb4c");
Domain domain1 = persistActiveDomain("example.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain1);
persistActiveSubordinateHost("ns2.example.xn--q9jyb4c", domain1);
DomainBase domain2 = persistActiveDomain("example2.xn--q9jyb4c");
Domain domain2 = persistActiveDomain("example2.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain2);
clock.advanceOneMilli();
}
@@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import google.registry.dns.DnsConstants.TargetType;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.request.HttpException.BadRequestException;
import google.registry.request.HttpException.NotFoundException;
import google.registry.testing.AppEngineExtension;
@@ -55,7 +55,7 @@ public class RefreshDnsActionTest {
@Test
void testSuccess_host() {
DomainBase domain = persistActiveDomain("example.xn--q9jyb4c");
Domain domain = persistActiveDomain("example.xn--q9jyb4c");
persistActiveSubordinateHost("ns1.example.xn--q9jyb4c", domain);
run(TargetType.HOST, "ns1.example.xn--q9jyb4c");
verify(dnsQueue).addHostRefreshTask("ns1.example.xn--q9jyb4c");
@@ -18,7 +18,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.mockito.ArgumentMatchers.anyString;
@@ -39,12 +38,13 @@ import com.google.common.collect.Sets;
import com.google.common.net.InetAddresses;
import com.google.common.util.concurrent.RateLimiter;
import google.registry.dns.writer.clouddns.CloudDnsWriter.ZoneStateException;
import google.registry.model.domain.DomainBase;
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.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.util.Retrier;
import google.registry.util.SystemClock;
import google.registry.util.SystemSleeper;
@@ -282,7 +282,7 @@ public class CloudDnsWriterTest {
}
/** Returns a domain to be persisted in Datastore. */
private static DomainBase fakeDomain(
private static Domain fakeDomain(
String domainName, ImmutableSet<HostResource> nameservers, int numDsRecords) {
ImmutableSet.Builder<DelegationSignerData> dsDataBuilder = new ImmutableSet.Builder<>();
@@ -295,7 +295,7 @@ public class CloudDnsWriterTest {
hostResourceRefBuilder.add(nameserver.createVKey());
}
return newDomainBase(domainName)
return DatabaseHelper.newDomain(domainName)
.asBuilder()
.setNameservers(hostResourceRefBuilder.build())
.setDsData(dsDataBuilder.build())
@@ -18,7 +18,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -36,12 +35,13 @@ import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import google.registry.model.domain.DomainBase;
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.ofy.Ofy;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectExtension;
import java.util.ArrayList;
@@ -100,7 +100,7 @@ public class DnsUpdateWriterTest {
void testPublishDomainCreate_publishesNameServers() throws Exception {
HostResource host1 = persistActiveHost("ns1.example.tld");
HostResource host2 = persistActiveHost("ns2.example.tld");
DomainBase domain =
Domain domain =
persistActiveDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host1.createVKey(), host2.createVKey()))
@@ -122,7 +122,7 @@ public class DnsUpdateWriterTest {
@Test
void testPublishAtomic_noCommit() {
HostResource host1 = persistActiveHost("ns.example1.tld");
DomainBase domain1 =
Domain domain1 =
persistActiveDomain("example1.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host1.createVKey()))
@@ -130,7 +130,7 @@ public class DnsUpdateWriterTest {
persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld");
DomainBase domain2 =
Domain domain2 =
persistActiveDomain("example2.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host2.createVKey()))
@@ -146,7 +146,7 @@ public class DnsUpdateWriterTest {
@Test
void testPublishAtomic_oneUpdate() throws Exception {
HostResource host1 = persistActiveHost("ns.example1.tld");
DomainBase domain1 =
Domain domain1 =
persistActiveDomain("example1.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host1.createVKey()))
@@ -154,7 +154,7 @@ public class DnsUpdateWriterTest {
persistResource(domain1);
HostResource host2 = persistActiveHost("ns.example2.tld");
DomainBase domain2 =
Domain domain2 =
persistActiveDomain("example2.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host2.createVKey()))
@@ -177,7 +177,7 @@ public class DnsUpdateWriterTest {
@Test
void testPublishDomainCreate_publishesDelegationSigner() throws Exception {
DomainBase domain =
Domain domain =
persistActiveDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(persistActiveHost("ns1.example.tld").createVKey()))
@@ -201,7 +201,7 @@ public class DnsUpdateWriterTest {
@Test
void testPublishDomainWhenNotActive_removesDnsRecords() throws Exception {
DomainBase domain =
Domain domain =
persistActiveDomain("example.tld")
.asBuilder()
.addStatusValue(StatusValue.SERVER_HOLD)
@@ -246,7 +246,7 @@ public class DnsUpdateWriterTest {
InetAddresses.forString("fd0e:a5c8:6dfb:6a5e:0:0:0:1")))
.build());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.addSubordinateHost("ns1.example.tld")
.addNameserver(host.createVKey())
@@ -318,7 +318,7 @@ public class DnsUpdateWriterTest {
.build());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.addSubordinateHost("ns1.example.tld")
.addNameservers(
@@ -354,7 +354,7 @@ public class DnsUpdateWriterTest {
.build());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.addSubordinateHost("ns1.example.tld")
.addSubordinateHost("foo.example.tld")
@@ -380,7 +380,7 @@ public class DnsUpdateWriterTest {
@SuppressWarnings("AssertThrowsMultipleStatements")
@Test
void testPublishDomainFails_whenDnsUpdateReturnsError() throws Exception {
DomainBase domain =
Domain domain =
persistActiveDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(persistActiveHost("ns1.example.tld").createVKey()))
@@ -27,7 +27,7 @@ import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppMetricSubject.assertThat;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static org.joda.money.CurrencyUnit.USD;
@@ -41,7 +41,7 @@ import com.google.re2j.Pattern;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.reporting.HistoryEntry.Type;
import google.registry.model.tld.Registry;
@@ -334,9 +334,8 @@ class EppLifecycleDomainTest extends EppTestCase {
// This is the time of the renew.
"UPDATE", "2000-06-03T00:00:00Z"));
DomainBase domain =
loadByForeignKey(DomainBase.class, "example.tld", DateTime.parse("2000-06-03T04:00:00Z"))
.get();
Domain domain =
loadByForeignKey(Domain.class, "example.tld", DateTime.parse("2000-06-03T04:00:00Z")).get();
DateTime deleteTime = DateTime.parse("2000-06-04T00:00:00Z");
// Delete domain example.tld during both grace periods.
@@ -376,7 +375,7 @@ class EppLifecycleDomainTest extends EppTestCase {
// entire cost of registration was refunded. We have to do this through the DB instead of EPP
// because domains deleted during the add grace period vanish immediately as far as the world
// outside our system is concerned.
DomainBase deletedDomain = loadByEntity(domain);
Domain deletedDomain = loadByEntity(domain);
assertAboutDomains().that(deletedDomain).hasRegistrationExpirationTime(createTime);
assertThatLogoutSucceeds();
@@ -399,8 +398,7 @@ class EppLifecycleDomainTest extends EppTestCase {
"CRDATE", "2000-06-01T00:02:00.0Z",
"EXDATE", "2002-06-01T00:02:00.0Z"));
DomainBase domain =
loadByForeignKey(DomainBase.class, "example.tld", createTime.plusHours(1)).get();
Domain domain = loadByForeignKey(Domain.class, "example.tld", createTime.plusHours(1)).get();
// Delete domain example.tld within the add grace period.
DateTime deleteTime = createTime.plusDays(1);
@@ -432,7 +430,7 @@ class EppLifecycleDomainTest extends EppTestCase {
// entire cost of registration was refunded. We have to do this through the DB instead of EPP
// because domains deleted during the add grace period vanish immediately as far as the world
// outside our system is concerned.
DomainBase deletedDomain = loadByEntity(domain);
Domain deletedDomain = loadByEntity(domain);
assertAboutDomains().that(deletedDomain).hasRegistrationExpirationTime(createTime);
assertThatLogoutSucceeds();
@@ -482,10 +480,8 @@ class EppLifecycleDomainTest extends EppTestCase {
ImmutableMap.of(
"CODE", "2303", "MSG", "The domain with given ID (example.tld) doesn't exist."));
DomainBase domain =
loadByForeignKey(
DomainBase.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z"))
.get();
Domain domain =
loadByForeignKey(Domain.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z")).get();
// Verify that the autorenew was ended and that the one-time billing event is not canceled.
assertBillingEventsForResource(
domain,
@@ -495,7 +491,7 @@ class EppLifecycleDomainTest extends EppTestCase {
assertThatLogoutSucceeds();
// Make sure that in the future, the domain expiration is unchanged after deletion
DomainBase clonedDomain = domain.cloneProjectedAtTime(deleteTime.plusYears(5));
Domain clonedDomain = domain.cloneProjectedAtTime(deleteTime.plusYears(5));
Truth.assertThat(clonedDomain.getRegistrationExpirationTime())
.isEqualTo(createTime.plusYears(2));
}
@@ -522,10 +518,8 @@ class EppLifecycleDomainTest extends EppTestCase {
.atTime(createTime)
.hasResponse("domain_create_response_eap_fee.xml");
DomainBase domain =
loadByForeignKey(
DomainBase.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z"))
.get();
Domain domain =
loadByForeignKey(Domain.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z")).get();
// Delete domain example.tld within the add grade period.
DateTime deleteTime = createTime.plusDays(1);
@@ -23,7 +23,7 @@ import static google.registry.testing.EppMetricSubject.assertThat;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
import com.google.common.collect.ImmutableMap;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.testing.AppEngineExtension;
import org.joda.time.DateTime;
@@ -212,8 +212,8 @@ class EppLifecycleHostTest extends EppTestCase {
HostResource exampleBarFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get();
DomainBase exampleBarFooTldDomain =
loadByForeignKey(DomainBase.class, "example.bar.foo.tld", timeAfterCreates).get();
Domain exampleBarFooTldDomain =
loadByForeignKey(Domain.class, "example.bar.foo.tld", timeAfterCreates).get();
assertAboutHosts()
.that(exampleBarFooTldHost)
.hasSuperordinateDomain(exampleBarFooTldDomain.createVKey());
@@ -222,8 +222,8 @@ class EppLifecycleHostTest extends EppTestCase {
HostResource exampleFooTldHost =
loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get();
DomainBase exampleFooTldDomain =
loadByForeignKey(DomainBase.class, "example.foo.tld", timeAfterCreates).get();
Domain exampleFooTldDomain =
loadByForeignKey(Domain.class, "example.foo.tld", timeAfterCreates).get();
assertAboutHosts()
.that(exampleFooTldHost)
.hasSuperordinateDomain(exampleFooTldDomain.createVKey());
@@ -231,8 +231,7 @@ class EppLifecycleHostTest extends EppTestCase {
HostResource exampleTldHost =
loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get();
DomainBase exampleTldDomain =
loadByForeignKey(DomainBase.class, "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");
@@ -30,7 +30,7 @@ import static org.joda.time.Duration.standardDays;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import google.registry.flows.EppTestComponent.FakesAndMocksModule;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.ofy.Ofy;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.testing.AppEngineExtension;
@@ -100,7 +100,7 @@ class EppPointInTimeTest {
eppLoader = new EppLoader(this, "domain_create.xml", ImmutableMap.of("DOMAIN", "example.tld"));
runFlow();
tm().clearSessionCache();
DomainBase domainAfterCreate = Iterables.getOnlyElement(loadAllOf(DomainBase.class));
Domain domainAfterCreate = Iterables.getOnlyElement(loadAllOf(Domain.class));
assertThat(domainAfterCreate.getDomainName()).isEqualTo("example.tld");
clock.advanceBy(standardDays(2));
@@ -109,7 +109,7 @@ class EppPointInTimeTest {
runFlow();
tm().clearSessionCache();
DomainBase domainAfterFirstUpdate = loadByEntity(domainAfterCreate);
Domain domainAfterFirstUpdate = loadByEntity(domainAfterCreate);
assertThat(domainAfterCreate).isNotEqualTo(domainAfterFirstUpdate);
clock.advanceOneMilli(); // same day as first update
@@ -117,7 +117,7 @@ class EppPointInTimeTest {
eppLoader = new EppLoader(this, "domain_update_dsdata_rem.xml");
runFlow();
tm().clearSessionCache();
DomainBase domainAfterSecondUpdate = loadByEntity(domainAfterCreate);
Domain domainAfterSecondUpdate = loadByEntity(domainAfterCreate);
clock.advanceBy(standardDays(2));
DateTime timeAtDelete = clock.nowUtc(); // before 'add' grace period ends
@@ -128,7 +128,7 @@ class EppPointInTimeTest {
assertThat(domainAfterFirstUpdate).isNotEqualTo(domainAfterSecondUpdate);
// Point-in-time can only rewind an object from the current version, not roll forward.
DomainBase latest = loadByEntity(domainAfterCreate);
Domain latest = loadByEntity(domainAfterCreate);
// Creation time has millisecond granularity due to isActive() check.
tm().clearSessionCache();
@@ -33,7 +33,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.EppXmlTransformer;
import google.registry.model.ofy.Ofy;
@@ -317,7 +317,7 @@ public class EppTestCase {
/** Makes a one-time billing event corresponding to the given domain's creation. */
protected static BillingEvent.OneTime makeOneTimeCreateBillingEvent(
DomainBase domain, DateTime createTime) {
Domain domain, DateTime createTime) {
return new BillingEvent.OneTime.Builder()
.setReason(Reason.CREATE)
.setTargetId(domain.getDomainName())
@@ -332,7 +332,7 @@ public class EppTestCase {
}
/** Makes a one-time billing event corresponding to the given domain's renewal. */
static BillingEvent.OneTime makeOneTimeRenewBillingEvent(DomainBase domain, DateTime renewTime) {
static BillingEvent.OneTime makeOneTimeRenewBillingEvent(Domain domain, DateTime renewTime) {
return new BillingEvent.OneTime.Builder()
.setReason(Reason.RENEW)
.setTargetId(domain.getDomainName())
@@ -347,7 +347,7 @@ public class EppTestCase {
/** Makes a recurring billing event corresponding to the given domain's creation. */
static BillingEvent.Recurring makeRecurringCreateBillingEvent(
DomainBase domain, DateTime eventTime, DateTime endTime) {
Domain domain, DateTime eventTime, DateTime endTime) {
return makeRecurringBillingEvent(
domain,
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_CREATE, DomainHistory.class),
@@ -357,7 +357,7 @@ public class EppTestCase {
/** Makes a recurring billing event corresponding to the given domain's renewal. */
static BillingEvent.Recurring makeRecurringRenewBillingEvent(
DomainBase domain, DateTime eventTime, DateTime endTime) {
Domain domain, DateTime eventTime, DateTime endTime) {
return makeRecurringBillingEvent(
domain,
getOnlyHistoryEntryOfType(domain, Type.DOMAIN_RENEW, DomainHistory.class),
@@ -367,7 +367,7 @@ public class EppTestCase {
/** Makes a recurring billing event corresponding to the given history entry. */
protected static BillingEvent.Recurring makeRecurringBillingEvent(
DomainBase domain, DomainHistory historyEntry, DateTime eventTime, DateTime endTime) {
Domain domain, DomainHistory historyEntry, DateTime eventTime, DateTime endTime) {
return new BillingEvent.Recurring.Builder()
.setReason(Reason.RENEW)
.setFlags(ImmutableSet.of(Flag.AUTO_RENEW))
@@ -381,7 +381,7 @@ public class EppTestCase {
/** Makes a cancellation billing event cancelling out the given domain create billing event. */
static BillingEvent.Cancellation makeCancellationBillingEventForCreate(
DomainBase domain, OneTime billingEventToCancel, DateTime createTime, DateTime deleteTime) {
Domain domain, OneTime billingEventToCancel, DateTime createTime, DateTime deleteTime) {
return new BillingEvent.Cancellation.Builder()
.setTargetId(domain.getDomainName())
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
@@ -396,7 +396,7 @@ public class EppTestCase {
/** Makes a cancellation billing event cancelling out the given domain renew billing event. */
static BillingEvent.Cancellation makeCancellationBillingEventForRenew(
DomainBase domain, OneTime billingEventToCancel, DateTime renewTime, DateTime deleteTime) {
Domain domain, OneTime billingEventToCancel, DateTime renewTime, DateTime deleteTime) {
return new BillingEvent.Cancellation.Builder()
.setTargetId(domain.getDomainName())
.setRegistrarId(domain.getCurrentSponsorRegistrarId())
@@ -22,7 +22,6 @@ import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.newContactResource;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistContactWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistDeletedContact;
@@ -51,6 +50,7 @@ import google.registry.model.tld.Registry;
import google.registry.model.transfer.TransferData;
import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -205,7 +205,8 @@ class ContactDeleteFlowTest extends ResourceFlowTestCase<ContactDeleteFlow, Cont
@Test
void testFailure_failfastWhenLinkedToDomain() throws Exception {
createTld("tld");
persistResource(newDomainBase("example.tld", persistActiveContact(getUniqueIdFromCommand())));
persistResource(
DatabaseHelper.newDomain("example.tld", persistActiveContact(getUniqueIdFromCommand())));
EppException thrown = assertThrows(ResourceToDeleteIsReferencedException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.EppResourceUtils.isDeleted;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -40,6 +39,7 @@ import google.registry.model.contact.PostalInfo.Type;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.eppcommon.PresenceMarker;
import google.registry.model.eppcommon.StatusValue;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
@@ -121,7 +121,7 @@ class ContactInfoFlowTest extends ResourceFlowTestCase<ContactInfoFlow, ContactR
@Test
void testSuccess_linked() throws Exception {
createTld("foobar");
persistResource(newDomainBase("example.foobar", persistContactResource(true)));
persistResource(DatabaseHelper.newDomain("example.foobar", persistContactResource(true)));
// Check that the persisted contact info was returned.
assertTransactionalFlow(false);
runFlowAssertResponse(
@@ -25,7 +25,6 @@ import static google.registry.model.tld.Registry.TldState.START_DATE_SUNRISE;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistBillingRecurrenceForDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
@@ -73,7 +72,7 @@ import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
@@ -82,6 +81,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldState;
import google.registry.model.tld.label.ReservedList;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.SetClockExtension;
import java.math.BigDecimal;
import org.joda.money.CurrencyUnit;
@@ -94,7 +94,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link DomainCheckFlow}. */
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, DomainBase> {
class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Domain> {
@Order(value = Order.DEFAULT - 3)
@RegisterExtension
@@ -199,7 +199,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_oneExists_allocationTokenIsRedeemed() throws Exception {
setEppInput("domain_check_allocationtoken.xml");
DomainBase domain = persistActiveDomain("example1.tld");
Domain domain = persistActiveDomain("example1.tld");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1L);
persistResource(
new AllocationToken.Builder()
@@ -779,7 +779,7 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
@Test
void testSuccess_thirtyDomains_restoreFees() throws Exception {
// Note that 30 is more than 25, which is the maximum # of entity groups you can enlist in a
// single Datastore transaction (each DomainBase entity is in a separate entity group).
// single Datastore transaction (each Domain entity is in a separate entity group).
// It's also pretty common for registrars to send large domain checks.
setEppInput("domain_check_fee_thirty_domains.xml");
// example-00.tld won't exist and thus will not have a renew fee like the others.
@@ -1414,10 +1414,10 @@ class DomainCheckFlowTest extends ResourceCheckFlowTestCase<DomainCheckFlow, Dom
assertTldsFieldLogged("com", "net", "org");
}
private DomainBase persistPendingDeleteDomain(String domainName) {
DomainBase existingDomain =
private Domain persistPendingDeleteDomain(String domainName) {
Domain existingDomain =
persistResource(
newDomainBase(domainName)
DatabaseHelper.newDomain(domainName)
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(25))
.setRegistrationExpirationTime(clock.nowUtc().minusDays(1))
@@ -38,7 +38,7 @@ import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapExce
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
import google.registry.flows.exceptions.TooManyResourceChecksException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.tld.Registry;
import google.registry.model.tld.Registry.TldState;
import org.joda.money.Money;
@@ -46,8 +46,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainClaimsCheckFlow}. */
public class DomainClaimsCheckFlowTest
extends ResourceFlowTestCase<DomainClaimsCheckFlow, DomainBase> {
public class DomainClaimsCheckFlowTest extends ResourceFlowTestCase<DomainClaimsCheckFlow, Domain> {
DomainClaimsCheckFlowTest() {
setEppInput("domain_check_claims.xml");
@@ -43,14 +43,13 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistReservedList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.testing.TaskQueueHelper.assertNoDnsTasksEnqueued;
@@ -151,7 +150,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.fee.BaseFee.FeeType;
@@ -174,6 +173,7 @@ import google.registry.model.tld.Registry.TldState;
import google.registry.model.tld.Registry.TldType;
import google.registry.monitoring.whitebox.EppMetric;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import java.math.BigDecimal;
import java.util.Map;
@@ -186,7 +186,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainCreateFlow}. */
class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, DomainBase> {
class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain> {
private static final String CLAIMS_KEY = "2013041500/2/6/9/rJ1NrDO92vDsAzf7EQzgjX4R0000000001";
@@ -251,7 +251,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
ImmutableSet<BillingEvent.Flag> expectedBillingFlags,
@Nullable AllocationToken allocationToken)
throws Exception {
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
boolean isAnchorTenant = expectedBillingFlags.contains(ANCHOR_TENANT);
// Set up the creation cost.
@@ -525,7 +525,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
"domain_create_allocationtoken.xml",
ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
persistContactsAndHosts();
DomainBase domain = persistActiveDomain("foo.tld");
Domain domain = persistActiveDomain("foo.tld");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 505L);
persistResource(
new AllocationToken.Builder()
@@ -852,7 +852,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
setEppInput("domain_create_dsdata_no_maxsiglife.xml");
persistContactsAndHosts("tld"); // For some reason this sample uses "tld".
doSuccessfulTest("tld");
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertAboutDomains()
.that(domain)
.hasExactlyDsData(
@@ -1118,7 +1118,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistContactsAndHosts();
String targetId = getUniqueIdFromCommand();
persistResource(
newDomainBase(targetId)
DatabaseHelper.newDomain(targetId)
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -1637,7 +1637,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
// Check for SERVER_HOLD status, no DNS tasks enqueued, and collision poll message.
assertNoDnsTasksEnqueued();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertThat(domain.getStatusValues()).contains(SERVER_HOLD);
assertPollMessagesWithCollisionOneTime(domain);
}
@@ -1654,12 +1654,12 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
// Check for SERVER_HOLD status, no DNS tasks enqueued, and collision poll message.
assertNoDnsTasksEnqueued();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertThat(domain.getStatusValues()).contains(SERVER_HOLD);
assertPollMessagesWithCollisionOneTime(domain);
}
private void assertPollMessagesWithCollisionOneTime(DomainBase domain) {
private void assertPollMessagesWithCollisionOneTime(Domain domain) {
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
assertPollMessagesForResource(
domain,
@@ -1814,7 +1814,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
CommitMode.LIVE,
UserPrivileges.NORMAL,
loadFile("domain_create_response.xml", substitutions));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
assertPollMessagesForResource(
domain,
@@ -2581,7 +2581,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
.setAddGracePeriodLength(Duration.standardMinutes(9))
.build());
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
assertThat(historyEntry.getDomainTransactionRecords())
.containsExactly(
@@ -2597,7 +2597,7 @@ class DomainCreateFlowTest extends ResourceFlowTestCase<DomainCreateFlow, Domain
persistContactsAndHosts();
persistResource(Registry.get("tld").asBuilder().setTldType(TldType.TEST).build());
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getHistoryEntries(domain).get(0);
// No transaction records should be stored for test TLDs
assertThat(historyEntry.getDomainTransactionRecords()).isEmpty();
@@ -44,13 +44,12 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.TaskQueueHelper.assertDnsTasksEnqueued;
@@ -82,7 +81,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -101,6 +100,7 @@ import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferResponse;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.CloudTasksHelper.TaskMatcher;
import google.registry.testing.DatabaseHelper;
import java.util.Map;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -109,9 +109,9 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainDeleteFlow}. */
class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, DomainBase> {
class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain> {
private DomainBase domain;
private Domain domain;
private DomainHistory earlierHistoryEntry;
private static final DateTime TIME_BEFORE_FLOW = DateTime.parse("2000-06-06T22:00:00.0Z");
@@ -159,7 +159,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
ContactResource contact = persistActiveContact("sh8013");
domain =
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setCreationTimeForTest(TIME_BEFORE_FLOW)
.setRegistrant(contact.createVKey())
@@ -379,9 +379,9 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
DateTime redemptionEndTime = domain.getLastEppUpdateTime().plusDays(3);
DomainBase domainAtRedemptionTime = domain.cloneProjectedAtTime(redemptionEndTime);
Domain domainAtRedemptionTime = domain.cloneProjectedAtTime(redemptionEndTime);
assertAboutDomains()
.that(domainAtRedemptionTime)
.hasLastEppUpdateClientId("TheRegistrar")
@@ -437,7 +437,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
DateTime expectedExpirationTime = domain.getRegistrationExpirationTime().minusYears(2);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile(responseFilename, substitutions));
DomainBase resource = reloadResourceByForeignKey();
Domain resource = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
assertAboutDomains()
.that(resource)
@@ -474,7 +474,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
assertDeletionPollMessageFor(resource, "Domain deleted.");
}
private void assertDeletionPollMessageFor(DomainBase domain, String expectedMessage) {
private void assertDeletionPollMessageFor(Domain domain, String expectedMessage) {
// There should be a future poll message at the deletion time. The previous autorenew poll
// message should now be deleted.
assertAboutDomains().that(domain).hasDeletePollMessage();
@@ -636,7 +636,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
setUpSuccessfulTest();
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertThat(domain.getTransferData()).isEqualTo(DomainTransferData.EMPTY);
}
@@ -649,7 +649,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
persistWithPendingTransfer(reloadResourceByForeignKey()).getTransferData();
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("domain_delete_response_pending.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
// Check that the domain is in the pending delete state.
// The PENDING_TRANSFER status should be gone.
assertAboutDomains()
@@ -734,14 +734,14 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
// Add a nameserver.
HostResource host = persistResource(newHostResource("ns1.example.tld"));
persistResource(
loadByForeignKey(DomainBase.class, getUniqueIdFromCommand(), clock.nowUtc())
loadByForeignKey(Domain.class, getUniqueIdFromCommand(), clock.nowUtc())
.get()
.asBuilder()
.setNameservers(ImmutableSet.of(host.createVKey()))
.build());
// Persist another domain that's already been deleted and references this contact and host.
persistResource(
newDomainBase("example1.tld")
DatabaseHelper.newDomain("example1.tld")
.asBuilder()
.setRegistrant(
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())
@@ -808,7 +808,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_hasSubordinateHosts() throws Exception {
DomainBase domain = persistActiveDomain(getUniqueIdFromCommand());
Domain domain = persistActiveDomain(getUniqueIdFromCommand());
HostResource subordinateHost =
persistResource(
newHostResource("ns1." + getUniqueIdFromCommand())
@@ -888,7 +888,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_clientDeleteProhibited() throws Exception {
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.addStatusValue(StatusValue.CLIENT_DELETE_PROHIBITED)
.build());
@@ -900,7 +900,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_serverDeleteProhibited() throws Exception {
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
@@ -912,7 +912,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_pendingDelete() throws Exception {
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.addStatusValue(StatusValue.PENDING_DELETE)
.build());
@@ -947,7 +947,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
@Test
void testFailure_metadataNotFromTool() throws Exception {
setEppInput("domain_delete_metadata.xml");
persistResource(newDomainBase(getUniqueIdFromCommand()));
persistResource(DatabaseHelper.newDomain(getUniqueIdFromCommand()));
EppException thrown = assertThrows(OnlyToolCanPassMetadataException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -1138,7 +1138,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainBase resource = reloadResourceByForeignKey();
Domain resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
@@ -1166,7 +1166,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainBase resource = reloadResourceByForeignKey();
Domain resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
@@ -1186,7 +1186,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
clock.advanceOneMilli();
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("domain_delete_response_pending.xml"));
DomainBase resource = reloadResourceByForeignKey();
Domain resource = reloadResourceByForeignKey();
assertAboutDomains()
.that(resource)
.hasExactlyStatusValues(StatusValue.INACTIVE, StatusValue.PENDING_DELETE)
@@ -1215,7 +1215,7 @@ class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow, Domain
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
assertThat(reloadResourceByForeignKey()).isNull();
DomainBase resavedDomain = loadByEntity(domain);
Domain resavedDomain = loadByEntity(domain);
assertDeletionPollMessageFor(resavedDomain, "Deleted by registry administrator.");
}
@@ -37,7 +37,7 @@ import google.registry.flows.domain.DomainFlowUtils.LeadingDashException;
import google.registry.flows.domain.DomainFlowUtils.MissingBillingAccountMapException;
import google.registry.flows.domain.DomainFlowUtils.TldDoesNotExistException;
import google.registry.flows.domain.DomainFlowUtils.TrailingDashException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.tld.Registry.TldType;
import google.registry.testing.AppEngineExtension;
import org.joda.money.Money;
@@ -45,7 +45,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainFlowUtils}. */
class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
class DomainFlowUtilsTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
@BeforeEach
void setup() {
@@ -22,7 +22,6 @@ import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SP
import static google.registry.model.tld.Registry.TldState.QUIET_PERIOD;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistBillingRecurrenceForDomain;
@@ -57,8 +56,8 @@ import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -70,6 +69,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.SetClockExtension;
import javax.annotation.Nullable;
import org.joda.money.Money;
@@ -80,7 +80,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link DomainInfoFlow}. */
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase> {
class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, Domain> {
@Order(value = Order.DEFAULT - 3)
@RegisterExtension
@@ -104,7 +104,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
private HostResource host1;
private HostResource host2;
private HostResource host3;
private DomainBase domain;
private Domain domain;
@BeforeEach
void setup() {
@@ -122,7 +122,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
host2 = persistActiveHost("ns1.example.net");
domain =
persistResource(
new DomainBase.Builder()
new Domain.Builder()
.setDomainName(domainName)
.setRepoId("2FF-TLD")
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
@@ -554,7 +554,7 @@ class DomainInfoFlowTest extends ResourceFlowTestCase<DomainInfoFlow, DomainBase
@Test
void testFailure_existedButWasDeleted() throws Exception {
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setDeletionTime(clock.nowUtc().minusDays(1))
.build());
@@ -22,7 +22,6 @@ import static google.registry.model.billing.BillingEvent.RenewalPriceBehavior.SP
import static google.registry.model.domain.fee.BaseFee.FeeType.RENEW;
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -42,12 +41,13 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.fee.Fee;
import google.registry.model.eppinput.EppInput;
import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeHttpSession;
import google.registry.util.Clock;
@@ -72,7 +72,7 @@ public class DomainPricingLogicTest {
SessionMetadata sessionMetadata;
@Mock FlowMetadata flowMetadata;
Registry registry;
DomainBase domain;
Domain domain;
@BeforeEach
void beforeEach() throws Exception {
@@ -97,7 +97,7 @@ public class DomainPricingLogicTest {
String domainName, RenewalPriceBehavior renewalPriceBehavior, Optional<Money> renewalPrice) {
domain =
persistResource(
newDomainBase(domainName)
DatabaseHelper.newDomain(domainName)
.asBuilder()
.setCreationTimeForTest(DateTime.parse("1999-01-05T00:00:00Z"))
.build());
@@ -29,13 +29,13 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DatabaseHelper.persistResources;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.TestDataHelper.updateSubstitutions;
@@ -79,7 +79,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -107,7 +107,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link DomainRenewFlow}. */
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBase> {
class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, Domain> {
private static final ImmutableMap<String, String> FEE_BASE_MAP =
ImmutableMap.of(
@@ -151,7 +151,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
@Nullable Money renewalPrice,
StatusValue... statusValues)
throws Exception {
DomainBase domain = newDomainBase(getUniqueIdFromCommand());
Domain domain = DatabaseHelper.newDomain(getUniqueIdFromCommand());
tm().transact(
() -> {
try {
@@ -183,7 +183,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
.setMsg("Domain was auto-renewed.")
.setHistoryEntry(historyEntryDomainCreate)
.build();
DomainBase newDomain =
Domain newDomain =
domain
.asBuilder()
.setRegistrationExpirationTime(expirationTime)
@@ -256,7 +256,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
DateTime newExpiration = currentExpiration.plusYears(renewalYears);
runFlowAssertResponse(
CommitMode.LIVE, userPrivileges, loadFile(responseFilename, substitutions));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertLastHistoryContainsResource(domain);
DomainHistory historyEntryDomainRenew =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW, DomainHistory.class);
@@ -742,7 +742,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
setEppInput(
"domain_renew_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld", "YEARS", "2"));
persistDomain();
DomainBase domain = persistActiveDomain("foo.tld");
Domain domain = persistActiveDomain("foo.tld");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 505L);
persistResource(
new AllocationToken.Builder()
@@ -858,7 +858,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
"false"));
persistDomain();
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertAboutDomains()
.that(domain)
.hasOneHistoryEntryEachOfTypes(
@@ -877,7 +877,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
persistDomain();
runFlow();
DomainBase domain1 = reloadResourceByForeignKey();
Domain domain1 = reloadResourceByForeignKey();
assertAboutDomains()
.that(domain1)
.hasOneHistoryEntryEachOfTypes(
@@ -923,7 +923,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
@Test
void testFailure_pendingDelete() throws Exception {
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setRegistrationExpirationTime(expirationTime)
.setDeletionTime(clock.nowUtc().plusDays(1))
@@ -1185,7 +1185,7 @@ class DomainRenewFlowTest extends ResourceFlowTestCase<DomainRenewFlow, DomainBa
.setRenewGracePeriodLength(Duration.standardMinutes(9))
.build());
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
HistoryEntry historyEntry = getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RENEW);
assertThat(historyEntry.getDomainTransactionRecords())
.containsExactly(
@@ -23,12 +23,11 @@ import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistReservedList;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static google.registry.testing.TaskQueueHelper.assertDnsTasksEnqueued;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -63,7 +62,7 @@ import google.registry.flows.domain.DomainRestoreRequestFlow.RestoreCommandInclu
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -75,6 +74,7 @@ import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.testing.DatabaseHelper;
import java.util.Map;
import java.util.Optional;
import org.joda.money.Money;
@@ -83,8 +83,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainRestoreRequestFlow}. */
class DomainRestoreRequestFlowTest
extends ResourceFlowTestCase<DomainRestoreRequestFlow, DomainBase> {
class DomainRestoreRequestFlowTest extends ResourceFlowTestCase<DomainRestoreRequestFlow, Domain> {
private static final ImmutableMap<String, String> FEE_06_MAP =
ImmutableMap.of("FEE_VERSION", "0.6", "FEE_NS", "fee", "CURRENCY", "USD");
@@ -110,7 +109,7 @@ class DomainRestoreRequestFlowTest
}
void persistPendingDeleteDomain(DateTime expirationTime) throws Exception {
DomainBase domain = persistResource(newDomainBase(getUniqueIdFromCommand()));
Domain domain = persistResource(DatabaseHelper.newDomain(getUniqueIdFromCommand()));
HistoryEntry historyEntry =
persistResource(
new DomainHistory.Builder()
@@ -167,7 +166,7 @@ class DomainRestoreRequestFlowTest
// Double check that we see a poll message in the future for when the delete happens.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
DomainHistory historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
@@ -236,7 +235,7 @@ class DomainRestoreRequestFlowTest
// Double check that we see a poll message in the future for when the delete happens.
assertThat(getPollMessages("TheRegistrar", clock.nowUtc().plusMonths(1))).hasSize(1);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
DomainHistory historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE, DomainHistory.class);
assertLastHistoryContainsResource(domain);
@@ -617,7 +616,7 @@ class DomainRestoreRequestFlowTest
@Test
void testFailure_notInRedemptionPeriod() throws Exception {
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(4))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
@@ -773,7 +772,7 @@ class DomainRestoreRequestFlowTest
void testIcannTransactionReportField_getsStored() throws Exception {
persistPendingDeleteDomain();
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
HistoryEntry historyEntryDomainRestore =
getOnlyHistoryEntryOfType(domain, HistoryEntry.Type.DOMAIN_RESTORE);
assertThat(historyEntryDomainRestore.getDomainTransactionRecords())
@@ -30,7 +30,7 @@ import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.util.DateTimeUtils.START_OF_TIME;
@@ -54,8 +54,8 @@ import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period;
@@ -83,7 +83,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferApproveFlow}. */
class DomainTransferApproveFlowTest
extends DomainTransferFlowTestCase<DomainTransferApproveFlow, DomainBase> {
extends DomainTransferFlowTestCase<DomainTransferApproveFlow, Domain> {
@BeforeEach
void beforeEach() {
@@ -110,7 +110,7 @@ class DomainTransferApproveFlowTest
clock.advanceOneMilli();
}
private void assertTransferApproved(DomainBase domain, DomainTransferData oldTransferData) {
private void assertTransferApproved(Domain domain, DomainTransferData oldTransferData) {
assertAboutDomains()
.that(domain)
.hasCurrentSponsorRegistrarId("NewRegistrar")
@@ -643,7 +643,7 @@ class DomainTransferApproveFlowTest
@Test
void testSuccess_superuserExtension_transferPeriodZero_autorenewGraceActive() throws Exception {
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
VKey<Recurring> existingAutorenewEvent = domain.getAutorenewBillingEvent();
// Set domain to have auto-renewed just before the transfer request, so that it will have an
// active autorenew grace period spanning the entire transfer window.
@@ -28,7 +28,7 @@ import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.util.DateTimeUtils.END_OF_TIME;
@@ -44,8 +44,8 @@ import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException
import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.flows.exceptions.NotTransferInitiatorException;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
@@ -63,7 +63,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferCancelFlow}. */
class DomainTransferCancelFlowTest
extends DomainTransferFlowTestCase<DomainTransferCancelFlow, DomainBase> {
extends DomainTransferFlowTestCase<DomainTransferCancelFlow, Domain> {
@BeforeEach
void beforeEach() {
@@ -24,7 +24,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistDomainWithDependentResources;
import static google.registry.testing.DatabaseHelper.persistDomainWithPendingTransfer;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.base.Ascii;
@@ -36,7 +36,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
@@ -72,7 +72,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
REGISTRATION_EXPIRATION_TIME.plusYears(EXTENDED_REGISTRATION_YEARS);
protected ContactResource contact;
protected DomainBase domain;
protected Domain domain;
HostResource subordinateHost;
private DomainHistory historyEntryDomainCreate;
@@ -89,7 +89,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
AppEngineExtension.makeRegistrar1().asBuilder().setRegistrarId("ClientZ").build());
}
static DomainBase persistWithPendingTransfer(DomainBase domain) {
static Domain persistWithPendingTransfer(Domain domain) {
return persistDomainWithPendingTransfer(
domain,
TRANSFER_REQUEST_TIME,
@@ -162,8 +162,7 @@ abstract class DomainTransferFlowTestCase<F extends Flow, R extends EppResource>
.build();
}
void assertTransferFailed(
DomainBase domain, TransferStatus status, TransferData oldTransferData) {
void assertTransferFailed(Domain domain, TransferStatus status, TransferData oldTransferData) {
assertAboutDomains()
.that(domain)
.doesNotHaveStatusValue(StatusValue.PENDING_TRANSFER)
@@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.assertBillingEvents;
import static google.registry.testing.DatabaseHelper.deleteTestDomain;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -30,8 +30,8 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.exceptions.NoTransferHistoryToQueryException;
import google.registry.flows.exceptions.NotAuthorizedToViewTransferException;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferStatus;
@@ -40,7 +40,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferQueryFlow}. */
class DomainTransferQueryFlowTest
extends DomainTransferFlowTestCase<DomainTransferQueryFlow, DomainBase> {
extends DomainTransferFlowTestCase<DomainTransferQueryFlow, Domain> {
@BeforeEach
void beforeEach() {
@@ -29,7 +29,7 @@ import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistDomainAsDeleted;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.util.DateTimeUtils.END_OF_TIME;
@@ -44,8 +44,8 @@ import google.registry.flows.ResourceFlowUtils.ResourceNotOwnedException;
import google.registry.flows.domain.DomainFlowUtils.NotAuthorizedForTldException;
import google.registry.flows.exceptions.NotPendingTransferException;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.AuthInfo.PasswordAuth;
@@ -65,7 +65,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferRejectFlow}. */
class DomainTransferRejectFlowTest
extends DomainTransferFlowTestCase<DomainTransferRejectFlow, DomainBase> {
extends DomainTransferFlowTestCase<DomainTransferRejectFlow, Domain> {
@BeforeEach
void beforeEach() {
@@ -38,7 +38,7 @@ import static google.registry.testing.DatabaseHelper.loadByKeys;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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;
@@ -84,8 +84,8 @@ import google.registry.flows.exceptions.TransferPeriodZeroAndFeeTransferExtensio
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactAuthInfo;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period;
@@ -117,7 +117,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainTransferRequestFlow}. */
class DomainTransferRequestFlowTest
extends DomainTransferFlowTestCase<DomainTransferRequestFlow, DomainBase> {
extends DomainTransferFlowTestCase<DomainTransferRequestFlow, Domain> {
private static final ImmutableMap<String, String> BASE_FEE_MAP =
new ImmutableMap.Builder<String, String>()
@@ -161,7 +161,7 @@ class DomainTransferRequestFlowTest
}
private void assertTransferRequested(
DomainBase domain,
Domain domain,
DateTime automaticTransferTime,
Period expectedPeriod,
DateTime expectedExpirationTime)
@@ -201,8 +201,7 @@ class DomainTransferRequestFlowTest
}
private void assertTransferApproved(
DomainBase domain, DateTime automaticTransferTime, Period expectedPeriod)
throws Exception {
Domain domain, DateTime automaticTransferTime, Period expectedPeriod) throws Exception {
assertAboutDomains()
.that(domain)
.hasCurrentSponsorRegistrarId("NewRegistrar")
@@ -320,7 +319,7 @@ class DomainTransferRequestFlowTest
assertThat(domain.getGracePeriods()).containsExactlyElementsIn(originalGracePeriods);
// If we fast forward AUTOMATIC_TRANSFER_DAYS, the transfer should have cleared out all other
// grace periods, but expect a transfer grace period (if there was a transfer billing event).
DomainBase domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
if (expectTransferBillingEvent) {
assertGracePeriods(
domainAfterAutomaticTransfer.getGracePeriods(),
@@ -424,7 +423,7 @@ class DomainTransferRequestFlowTest
DateTime expectedExpirationTime, DateTime implicitTransferTime, Period expectedPeriod)
throws Exception {
Registry registry = Registry.get(domain.getTld());
DomainBase domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
Domain domainAfterAutomaticTransfer = domain.cloneProjectedAtTime(implicitTransferTime);
assertTransferApproved(domainAfterAutomaticTransfer, implicitTransferTime, expectedPeriod);
assertAboutDomains()
.that(domainAfterAutomaticTransfer)
@@ -436,7 +435,7 @@ class DomainTransferRequestFlowTest
assertThat(loadByKey(domainAfterAutomaticTransfer.getAutorenewBillingEvent()).getEventTime())
.isEqualTo(expectedExpirationTime);
// And after the expected grace time, the grace period should be gone.
DomainBase afterGracePeriod =
Domain afterGracePeriod =
domain.cloneProjectedAtTime(
clock
.nowUtc()
@@ -575,7 +574,7 @@ class DomainTransferRequestFlowTest
if (expectedAutomaticTransferLength.equals(Duration.ZERO)) {
// The transfer is going to happen immediately. To observe the domain in the pending transfer
// state, grab it directly from the database.
domain = Iterables.getOnlyElement(tm().transact(() -> tm().loadAllOf(DomainBase.class)));
domain = Iterables.getOnlyElement(tm().transact(() -> tm().loadAllOf(Domain.class)));
assertThat(domain.getDomainName()).isEqualTo("example.tld");
} else {
// Transfer should have been requested.
@@ -37,14 +37,13 @@ import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHost;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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.TaskQueueHelper.assertDnsTasksEnqueued;
@@ -95,7 +94,7 @@ import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
@@ -105,6 +104,7 @@ import google.registry.model.poll.PendingActionNotificationResponse.DomainPendin
import google.registry.model.poll.PollMessage;
import google.registry.model.tld.Registry;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import java.util.Optional;
import org.joda.money.Money;
import org.joda.time.DateTime;
@@ -112,7 +112,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** Unit tests for {@link DomainUpdateFlow}. */
class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, DomainBase> {
class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain> {
private static final DelegationSignerData SOME_DSDATA =
DelegationSignerData.create(
@@ -147,12 +147,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
unusedContact = persistActiveContact("unused");
}
private DomainBase persistDomainWithRegistrant() throws Exception {
private Domain persistDomainWithRegistrant() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
DomainBase domain =
Domain domain =
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -173,12 +173,12 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
return domain;
}
private DomainBase persistDomain() throws Exception {
private Domain persistDomain() throws Exception {
HostResource host =
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
DomainBase domain =
Domain domain =
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -204,7 +204,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
private void doSuccessfulTest(String expectedXmlFilename) throws Exception {
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile(expectedXmlFilename));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
// Check that the domain was updated. These values came from the xml.
assertAboutDomains()
.that(domain)
@@ -343,7 +343,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
clock.advanceOneMilli();
assertTransactionalFlow(true);
runFlowAssertResponse(loadFile("generic_success_response.xml"));
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_UPDATE);
assertThat(domain.getNameservers()).hasSize(13);
// getContacts does not return contacts of type REGISTRANT, so check these separately.
@@ -360,7 +360,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
persistReferencedEntities();
persistDomain();
runFlow();
DomainBase domain = reloadResourceByForeignKey();
Domain domain = reloadResourceByForeignKey();
assertAboutDomains().that(domain).hasOneHistoryEntryEachOfTypes(DOMAIN_CREATE, DOMAIN_UPDATE);
assertAboutHistoryEntries()
.that(getOnlyHistoryEntryOfType(domain, DOMAIN_UPDATE))
@@ -392,7 +392,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
// host relationship itself.
setEppInput("domain_update_subordinate_hosts.xml");
persistReferencedEntities();
DomainBase domain = persistDomain();
Domain domain = persistDomain();
persistActiveSubordinateHost("ns1.example.tld", domain);
HostResource addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
persistResource(
@@ -426,7 +426,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
ContactResource sh8013 =
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setRegistrant(sh8013.createVKey())
.build());
@@ -442,7 +442,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
VKey<ContactResource> sh8013Key = sh8013.createVKey();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setRegistrant(sh8013Key)
.setContacts(
@@ -486,11 +486,14 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
throws Exception {
setEppInput(xmlFilename, substitutions);
persistResource(
newDomainBase(getUniqueIdFromCommand()).asBuilder().setDsData(originalDsData).build());
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(originalDsData)
.build());
assertTransactionalFlow(true);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
DomainBase resource = reloadResourceByForeignKey();
Domain resource = reloadResourceByForeignKey();
assertAboutDomains().that(resource).hasOnlyOneHistoryEntryWhich().hasType(DOMAIN_UPDATE);
assertThat(resource.getDsData())
.isEqualTo(
@@ -835,7 +838,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
@Test
void testSuccess_noBillingOnPreExistingServerStatus() throws Exception {
eppRequestSource = EppRequestSource.TOOL;
DomainBase addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
Domain addStatusDomain = persistActiveDomain(getUniqueIdFromCommand());
persistResource(
addStatusDomain.asBuilder().addStatusValue(StatusValue.SERVER_RENEW_PROHIBITED).build());
doServerStatusBillingTest("domain_update_add_server_status.xml", false);
@@ -845,7 +848,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuccess_removeServerStatusBillingEvent() throws Exception {
eppRequestSource = EppRequestSource.TOOL;
persistReferencedEntities();
DomainBase removeStatusDomain = persistDomain();
Domain removeStatusDomain = persistDomain();
persistResource(
removeStatusDomain.asBuilder().addStatusValue(StatusValue.SERVER_RENEW_PROHIBITED).build());
doServerStatusBillingTest("domain_update_remove_server_status.xml", true);
@@ -855,7 +858,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testSuccess_changeServerStatusBillingEvent() throws Exception {
eppRequestSource = EppRequestSource.TOOL;
persistReferencedEntities();
DomainBase changeStatusDomain = persistDomain();
Domain changeStatusDomain = persistDomain();
persistResource(
changeStatusDomain.asBuilder().addStatusValue(StatusValue.SERVER_RENEW_PROHIBITED).build());
doServerStatusBillingTest("domain_update_change_server_status.xml", true);
@@ -934,7 +937,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsInvalidDigestType() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
@@ -946,7 +949,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsMultipleInvalidDigestTypes() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(
ImmutableSet.of(
@@ -963,7 +966,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsInvalidDigestLength() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 1, new byte[] {0, 1, 2})))
.build());
@@ -978,7 +981,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsMultipleInvalidDigestLengths() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(
ImmutableSet.of(
@@ -998,7 +1001,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsInvalidAlgorithm() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 99, 2, new byte[] {0, 1, 2})))
.build());
@@ -1010,7 +1013,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_secDnsMultipleInvalidAlgorithms() throws Exception {
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(
ImmutableSet.of(
@@ -1032,7 +1035,10 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_dsdata_add.xml", OTHER_DSDATA_TEMPLATE_MAP);
persistResource(
newDomainBase(getUniqueIdFromCommand()).asBuilder().setDsData(builder.build()).build());
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDsData(builder.build())
.build());
EppException thrown = assertThrows(TooManyDsRecordsException.class, this::runFlow);
assertAboutEppExceptions().that(thrown).marshalsToXml();
}
@@ -1153,7 +1159,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
DomainBase updatedDomain = reloadResourceByForeignKey();
Domain updatedDomain = reloadResourceByForeignKey();
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
@@ -1192,7 +1198,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
DomainBase updatedDomain = reloadResourceByForeignKey();
Domain updatedDomain = reloadResourceByForeignKey();
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
@@ -1230,7 +1236,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
.build());
runFlowAssertResponse(
CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));
DomainBase updatedDomain = reloadResourceByForeignKey();
Domain updatedDomain = reloadResourceByForeignKey();
assertPollMessagesForResource(
updatedDomain,
new PollMessage.OneTime.Builder()
@@ -1255,7 +1261,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_serverUpdateProhibited_prohibitsNonSuperuserUpdates() throws Exception {
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.addStatusValue(SERVER_UPDATE_PROHIBITED)
.build());
@@ -1296,7 +1302,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_authinfo.xml");
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_UPDATE_PROHIBITED))
.build());
@@ -1309,7 +1315,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_serverUpdateProhibited() throws Exception {
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.build());
@@ -1322,7 +1328,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
void testFailure_pendingDelete() throws Exception {
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(1))
.addStatusValue(StatusValue.PENDING_DELETE)
@@ -1411,7 +1417,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_add_remove_same_host.xml");
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setNameservers(
ImmutableSet.of(
@@ -1429,7 +1435,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_add_remove_same_contact.xml");
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setContacts(
DesignatedContact.create(
@@ -1447,7 +1453,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_remove_admin.xml");
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -1463,7 +1469,7 @@ class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow, Domain
setEppInput("domain_update_remove_tech.xml");
persistReferencedEntities();
persistResource(
newDomainBase(getUniqueIdFromCommand())
DatabaseHelper.newDomain(getUniqueIdFromCommand())
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -22,7 +22,6 @@ import static google.registry.model.domain.token.AllocationToken.TokenStatus.VAL
import static google.registry.model.domain.token.AllocationToken.TokenType.SINGLE_USE;
import static google.registry.model.domain.token.AllocationToken.TokenType.UNLIMITED_USE;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
@@ -44,7 +43,7 @@ import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTok
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForRegistrarException;
import google.registry.flows.domain.token.AllocationTokenFlowUtils.AllocationTokenNotValidForTldException;
import google.registry.flows.domain.token.AllocationTokenFlowUtils.InvalidAllocationTokenException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainCommand;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
@@ -52,6 +51,7 @@ import google.registry.model.domain.token.AllocationTokenExtension;
import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import java.util.Optional;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -102,7 +102,7 @@ class AllocationTokenFlowUtilsTest {
assertThat(
flowUtils
.verifyAllocationTokenIfPresent(
newDomainBase("blah.tld"),
DatabaseHelper.newDomain("blah.tld"),
Registry.get("tld"),
"TheRegistrar",
DateTime.now(UTC),
@@ -145,7 +145,7 @@ class AllocationTokenFlowUtilsTest {
InvalidAllocationTokenException.class,
() ->
flowUtils.verifyAllocationTokenIfPresent(
newDomainBase("blah.tld"),
DatabaseHelper.newDomain("blah.tld"),
Registry.get("tld"),
"TheRegistrar",
DateTime.now(UTC),
@@ -185,7 +185,7 @@ class AllocationTokenFlowUtilsTest {
IllegalStateException.class,
() ->
failingFlowUtils.verifyAllocationTokenIfPresent(
newDomainBase("blah.tld"),
DatabaseHelper.newDomain("blah.tld"),
Registry.get("tld"),
"TheRegistrar",
DateTime.now(UTC),
@@ -305,7 +305,7 @@ class AllocationTokenFlowUtilsTest {
@Test
void test_checkDomainsWithToken_showsFailureMessageForRedeemedToken() {
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1051L);
persistResource(
new AllocationToken.Builder()
@@ -396,7 +396,7 @@ class AllocationTokenFlowUtilsTest {
clazz,
() ->
flowUtils.verifyAllocationTokenIfPresent(
newDomainBase("blah.tld"),
DatabaseHelper.newDomain("blah.tld"),
Registry.get("tld"),
"TheRegistrar",
DateTime.now(UTC),
@@ -438,11 +438,7 @@ class AllocationTokenFlowUtilsTest {
@Override
public AllocationToken validateToken(
DomainBase domain,
AllocationToken token,
Registry registry,
String registrarId,
DateTime now) {
Domain domain, AllocationToken token, Registry registry, String registrarId, DateTime now) {
throw new IllegalStateException("failed for tests");
}
@@ -19,7 +19,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -50,10 +49,11 @@ import google.registry.flows.host.HostFlowUtils.HostNameTooShallowException;
import google.registry.flows.host.HostFlowUtils.InvalidHostNameException;
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainDoesNotExistException;
import google.registry.flows.host.HostFlowUtils.SuperordinateDomainInPendingDeleteException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.Test;
@@ -125,8 +125,8 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
void testSuccess_internalNeverExisted() throws Exception {
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
DomainBase superordinateDomain =
loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
assertThat(superordinateDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
assertDnsTasksEnqueued("ns1.example.tld");
@@ -154,8 +154,8 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
persistDeletedHost(getUniqueIdFromCommand(), clock.nowUtc().minusDays(1));
doSuccessfulInternalTest("tld");
HostResource host = reloadResourceByForeignKey();
DomainBase superordinateDomain =
loadByForeignKey(DomainBase.class, "example.tld", clock.nowUtc()).get();
Domain superordinateDomain =
loadByForeignKey(Domain.class, "example.tld", clock.nowUtc()).get();
assertAboutHosts().that(host).hasSuperordinateDomain(superordinateDomain.createVKey());
assertThat(superordinateDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
assertDnsTasksEnqueued("ns1.example.tld");
@@ -193,7 +193,7 @@ class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, HostResour
setEppHostCreateInputWithIps("ns1.example.tld");
createTld("tld");
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setDeletionTime(clock.nowUtc().plusDays(35))
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
@@ -19,7 +19,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistDeletedHost;
@@ -43,13 +42,14 @@ import google.registry.flows.exceptions.ResourceToDeleteIsReferencedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.reporting.HistoryEntry.Type;
import google.registry.model.tld.Registry;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -159,9 +159,9 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
sessionMetadata.setRegistrarId("TheRegistrar");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
@@ -180,9 +180,9 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
void testFailure_unauthorizedClientReadFromSuperordinate() {
sessionMetadata.setRegistrarId("TheRegistrar");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -204,9 +204,9 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
DateTime now = clock.nowUtc();
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
DateTime transferExpirationTime = now.minusDays(1);
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't hurt.
.addStatusValue(StatusValue.PENDING_TRANSFER)
@@ -238,9 +238,9 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
DateTime now = clock.nowUtc();
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
DateTime transferExpirationTime = now.minusDays(1);
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar") // Shouldn't help.
.addStatusValue(StatusValue.PENDING_TRANSFER)
@@ -267,7 +267,7 @@ class HostDeleteFlowTest extends ResourceFlowTestCase<HostDeleteFlow, HostResour
void testFailure_failfastWhenLinkedToDomain() {
createTld("tld");
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(persistActiveHost("ns1.example.tld").createVKey()))
.build());
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.deleteResource;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
@@ -34,9 +33,10 @@ import google.registry.flows.ResourceFlowUtils.ResourceDoesNotExistException;
import google.registry.flows.host.HostFlowUtils.HostNameNotLowerCaseException;
import google.registry.flows.host.HostFlowUtils.HostNameNotNormalizedException;
import google.registry.flows.host.HostFlowUtils.HostNameNotPunyCodedException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.testing.DatabaseHelper;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -96,7 +96,7 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
void testSuccess_linked() throws Exception {
persistHostResource();
persistResource(
newDomainBase("example.foobar")
DatabaseHelper.newDomain("example.foobar")
.asBuilder()
.addNameserver(persistHostResource().createVKey())
.build());
@@ -113,9 +113,9 @@ class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostResource>
private void runTest_superordinateDomain(
DateTime domainTransferTime, @Nullable DateTime lastSuperordinateChange) throws Exception {
persistNewRegistrar("superclientid");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("parent.foobar")
DatabaseHelper.newDomain("parent.foobar")
.asBuilder()
.setRepoId("BEEF-FOOBAR")
.setLastTransferTime(domainTransferTime)
@@ -23,7 +23,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -31,7 +30,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveSubordinateHos
import static google.registry.testing.DatabaseHelper.persistDeletedHost;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
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;
@@ -70,7 +69,7 @@ import google.registry.flows.host.HostUpdateFlow.CannotRemoveSubordinateHostLast
import google.registry.flows.host.HostUpdateFlow.CannotRenameExternalHostException;
import google.registry.flows.host.HostUpdateFlow.HostAlreadyExistsException;
import google.registry.flows.host.HostUpdateFlow.RenameHostToExternalRemoveIpException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex;
@@ -78,6 +77,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.tld.Registry;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.TaskQueueHelper.TaskMatcher;
import javax.annotation.Nullable;
import org.joda.time.DateTime;
@@ -110,11 +110,11 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
*
* <p>The transfer is from "TheRegistrar" to "NewRegistrar".
*/
private DomainBase createDomainWithServerApprovedTransfer(String domainName) {
private Domain createDomainWithServerApprovedTransfer(String domainName) {
DateTime now = clock.nowUtc();
DateTime requestTime = now.minusDays(1).minus(Registry.DEFAULT_AUTOMATIC_TRANSFER_LENGTH);
DateTime transferExpirationTime = now.minusDays(1);
return newDomainBase(domainName)
return DatabaseHelper.newDomain(domainName)
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.addStatusValue(StatusValue.PENDING_TRANSFER)
@@ -197,7 +197,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.tld"));
persistResource(
newDomainBase("test.xn--q9jyb4c")
DatabaseHelper.newDomain("test.xn--q9jyb4c")
.asBuilder()
.setDeletionTime(END_OF_TIME)
.setNameservers(ImmutableSet.of(host.createVKey()))
@@ -216,7 +216,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_nameUnchanged_superordinateDomainNeverTransferred() throws Exception {
setEppInput("host_update_name_unchanged.xml");
createTld("tld");
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
@@ -242,7 +242,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
setEppInput("host_update_name_unchanged.xml");
createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
DomainBase domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
HostResource oldHost = persistActiveSubordinateHost(oldHostName(), domain);
clock.advanceOneMilli();
runFlowAssertResponse(loadFile("generic_success_response.xml"));
@@ -272,9 +272,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("tld");
DateTime now = clock.nowUtc();
DateTime oneDayAgo = now.minusDays(1);
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.setLastTransferTime(oneDayAgo)
@@ -291,7 +291,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(oneDayAgo);
DomainBase reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(now);
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(now);
assertThat(reloadedDomain.getSubordinateHosts()).containsExactly("ns2.example.tld");
assertDnsTasksEnqueued("ns1.example.tld", "ns2.example.tld");
}
@@ -304,10 +304,10 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase example = persistActiveDomain("example.tld");
DomainBase foo =
Domain example = persistActiveDomain("example.tld");
Domain foo =
persistResource(
newDomainBase("foo.tld")
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
@@ -340,13 +340,13 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("foo");
createTld("tld");
DomainBase fooDomain =
Domain fooDomain =
persistResource(
newDomainBase("example.foo")
DatabaseHelper.newDomain("example.foo")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
DomainBase tldDomain = persistActiveDomain("example.tld");
Domain tldDomain = persistActiveDomain("example.tld");
persistActiveSubordinateHost(oldHostName(), fooDomain);
assertThat(fooDomain.getSubordinateHosts()).containsExactly("ns1.example.foo");
assertThat(tldDomain.getSubordinateHosts()).isEmpty();
@@ -361,9 +361,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.hasPersistedCurrentSponsorRegistrarId("TheRegistrar")
.and()
.hasLastTransferTime(null);
DomainBase reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtTime(now);
Domain reloadedFooDomain = loadByEntity(fooDomain).cloneProjectedAtTime(now);
assertThat(reloadedFooDomain.getSubordinateHosts()).isEmpty();
DomainBase reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtTime(now);
Domain reloadedTldDomain = loadByEntity(tldDomain).cloneProjectedAtTime(now);
assertThat(reloadedTldDomain.getSubordinateHosts()).containsExactly("ns2.example.tld");
assertDnsTasksEnqueued("ns1.example.foo", "ns2.example.tld");
}
@@ -378,9 +378,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
// This registrar should be superseded by domain's registrar.
persistNewRegistrar("Superseded");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.foo")
DatabaseHelper.newDomain("example.foo")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.build());
@@ -406,7 +406,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
.and()
.hasLastSuperordinateChange(clock.nowUtc());
assertThat(renamedHost.getLastTransferTime()).isEqualTo(oneDayAgo);
DomainBase reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(clock.nowUtc());
Domain reloadedDomain = loadByEntity(domain).cloneProjectedAtTime(clock.nowUtc());
assertThat(reloadedDomain.getSubordinateHosts()).isEmpty();
assertDnsTasksEnqueued("ns1.example.foo");
}
@@ -416,7 +416,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld");
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
persistActiveHost(oldHostName());
assertThat(domain.getSubordinateHosts()).isEmpty();
assertThrows(CannotRenameExternalHostException.class, this::runFlow);
@@ -428,7 +428,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
setEppHostUpdateInput(
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld");
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
persistActiveHost(oldHostName());
assertThat(domain.getSubordinateHosts()).isEmpty();
HostResource renamedHost = doSuccessfulTestAsSuperuser();
@@ -504,13 +504,16 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DateTime lastTransferTime = clock.nowUtc().minusDays(5);
DomainBase foo =
Domain foo =
persistResource(
newDomainBase("foo.tld").asBuilder().setLastTransferTime(lastTransferTime).build());
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(lastTransferTime)
.build());
// Set the new domain to have a last transfer time that is different than the last transfer
// time on the host in question.
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.build());
@@ -539,16 +542,16 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("foo.tld")
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.build());
// Set the new domain to have a last transfer time that is different than the last transfer
// time on the host in question.
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(10))
.build());
@@ -579,14 +582,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase foo =
Domain foo =
persistResource(
newDomainBase("foo.tld")
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.build());
// Set the new domain to have a null last transfer time.
persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
@@ -615,10 +619,12 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase foo =
persistResource(newDomainBase("foo.tld").asBuilder().setLastTransferTime(null).build());
Domain foo =
persistResource(
DatabaseHelper.newDomain("foo.tld").asBuilder().setLastTransferTime(null).build());
// Set the new domain to have a null last transfer time.
persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
DateTime lastTransferTime = clock.nowUtc().minusDays(20);
persistResource(
@@ -646,14 +652,15 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase foo =
Domain foo =
persistResource(
newDomainBase("foo.tld")
DatabaseHelper.newDomain("foo.tld")
.asBuilder()
.setLastTransferTime(clock.nowUtc().minusDays(5))
.build());
// Set the new domain to have a null last transfer time.
persistResource(newDomainBase("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
DatabaseHelper.newDomain("example.tld").asBuilder().setLastTransferTime(null).build());
persistResource(
newHostResource(oldHostName())
.asBuilder()
@@ -679,7 +686,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
null,
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("foo");
DomainBase domain = persistActiveDomain("example.foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
.asBuilder()
@@ -717,7 +724,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
null,
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("foo");
DomainBase domain = persistActiveDomain("example.foo");
Domain domain = persistActiveDomain("example.foo");
DateTime lastTransferTime = clock.nowUtc().minusDays(12);
persistResource(
newHostResource(oldHostName())
@@ -753,7 +760,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
null,
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("foo");
DomainBase domain = persistActiveDomain("example.foo");
Domain domain = persistActiveDomain("example.foo");
persistResource(
newHostResource(oldHostName())
.asBuilder()
@@ -784,7 +791,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"ns1.example.foo", "ns2.example.tld", "<host:addr ip=\"v4\">192.0.2.22</host:addr>", null);
createTld("tld");
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setLastTransferTime(domainTransferTime)
.build());
@@ -835,9 +842,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
"<host:addr ip=\"v4\">192.0.2.22</host:addr>",
"<host:addr ip=\"v6\">1080:0:0:0:8:800:200C:417A</host:addr>");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setSubordinateHosts(ImmutableSet.of(oldHostName()))
.setDeletionTime(clock.nowUtc().plusDays(35))
@@ -1104,9 +1111,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testSuccess_authorizedClientReadFromSuperordinate() throws Exception {
sessionMetadata.setRegistrarId("NewRegistrar");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -1126,9 +1133,9 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
void testFailure_unauthorizedClientReadFromSuperordinate() {
sessionMetadata.setRegistrarId("NewRegistrar");
createTld("tld");
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.build());
@@ -1149,7 +1156,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
sessionMetadata.setRegistrarId("NewRegistrar");
createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
DomainBase domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
.asBuilder()
@@ -1167,7 +1174,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
sessionMetadata.setRegistrarId("TheRegistrar");
createTld("tld");
// Create a domain that will belong to NewRegistrar after cloneProjectedAtTime is called.
DomainBase domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
persistResource(
newHostResource("ns1.example.tld")
.asBuilder()
@@ -1188,7 +1195,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
createTld("tld");
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -1210,7 +1217,7 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
HostResource host =
persistActiveSubordinateHost(oldHostName(), persistActiveDomain("example.foo"));
// The domain will belong to NewRegistrar after cloneProjectedAtTime is called.
DomainBase domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
assertAboutDomains().that(domain).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
assertAboutHosts().that(host).hasPersistedCurrentSponsorRegistrarId("TheRegistrar");
@@ -1226,10 +1233,10 @@ class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, HostResour
createTld("foo");
createTld("tld");
// The domain will belong to NewRegistrar after cloneProjectedAtTime is called.
DomainBase domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
DomainBase superordinate =
Domain domain = persistResource(createDomainWithServerApprovedTransfer("example.tld"));
Domain superordinate =
persistResource(
newDomainBase("example.foo")
DatabaseHelper.newDomain("example.foo")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("NewRegistrar")
.build());
@@ -17,7 +17,6 @@ package google.registry.flows.poll;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createHistoryEntryForEppResource;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -30,8 +29,9 @@ import google.registry.flows.poll.PollAckFlow.MessageDoesNotExistException;
import google.registry.flows.poll.PollAckFlow.MissingMessageIdException;
import google.registry.flows.poll.PollAckFlow.NotAuthorizedToAckMessageException;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.poll.PollMessage;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.SetClockExtension;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -49,7 +49,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
/** This is the message id being sent in the ACK request. */
private static final long MESSAGE_ID = 3;
private DomainBase domain;
private Domain domain;
private ContactResource contact;
@BeforeEach
@@ -58,7 +58,7 @@ class PollAckFlowTest extends FlowTestCase<PollAckFlow> {
setRegistrarIdForFlow("NewRegistrar");
createTld("example");
contact = persistActiveContact("jd1234");
domain = persistResource(newDomainBase("test.example", contact));
domain = persistResource(DatabaseHelper.newDomain("test.example", contact));
}
private void persistOneTimePollMessage(long messageId) {
@@ -16,7 +16,6 @@ package google.registry.flows.poll;
import static google.registry.testing.DatabaseHelper.createHistoryEntryForEppResource;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
@@ -30,7 +29,7 @@ import google.registry.flows.FlowTestCase;
import google.registry.flows.poll.PollRequestFlow.UnexpectedMessageIdException;
import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostHistory;
import google.registry.model.host.HostResource;
@@ -40,6 +39,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.TransferResponse.ContactTransferResponse;
import google.registry.model.transfer.TransferResponse.DomainTransferResponse;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.SetClockExtension;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
@@ -53,7 +53,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
@RegisterExtension
final SetClockExtension setClockExtension = new SetClockExtension(clock, "2011-01-02T01:01:01Z");
private DomainBase domain;
private Domain domain;
private ContactResource contact;
private HostResource host;
@@ -64,7 +64,7 @@ class PollRequestFlowTest extends FlowTestCase<PollRequestFlow> {
createTld("example");
persistNewRegistrar("BadRegistrar");
contact = persistActiveContact("jd1234");
domain = persistResource(newDomainBase("test.example", contact));
domain = persistResource(DatabaseHelper.newDomain("test.example", contact));
host = persistActiveHost("ns1.test.example");
}
@@ -34,7 +34,7 @@ import google.registry.model.EntityTestCase;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -59,7 +59,7 @@ public class BillingEventTest extends EntityTestCase {
private DomainHistory domainHistory;
private DomainHistory domainHistory2;
private DomainBase domain;
private Domain domain;
private BillingEvent.OneTime oneTime;
private BillingEvent.OneTime oneTimeSynthetic;
private BillingEvent.Recurring recurring;
@@ -15,9 +15,11 @@
package google.registry.model.bulkquery;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static google.registry.model.bulkquery.BulkQueryEntities.assembleDomain;
import static google.registry.model.bulkquery.BulkQueryEntities.assembleDomainHistory;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.domain.GracePeriod;
@@ -28,17 +30,17 @@ import google.registry.model.reporting.DomainTransactionRecord;
import google.registry.persistence.VKey;
/**
* Helpers for bulk-loading {@link google.registry.model.domain.DomainBase} and {@link
* google.registry.model.domain.DomainHistory} entities in <em>tests</em>.
* Helpers for bulk-loading {@link Domain} and {@link google.registry.model.domain.DomainHistory}
* entities in <em>tests</em>.
*/
public class BulkQueryHelper {
static DomainBase loadAndAssembleDomainBase(String domainRepoId) {
static Domain loadAndAssembleDomain(String domainRepoId) {
return jpaTm()
.transact(
() ->
BulkQueryEntities.assembleDomainBase(
jpaTm().loadByKey(DomainBaseLite.createVKey(domainRepoId)),
assembleDomain(
jpaTm().loadByKey(DomainLite.createVKey(domainRepoId)),
jpaTm()
.loadAllOfStream(GracePeriod.class)
.filter(gracePeriod -> gracePeriod.getDomainRepoId().equals(domainRepoId))
@@ -58,7 +60,7 @@ public class BulkQueryHelper {
return jpaTm()
.transact(
() ->
BulkQueryEntities.assembleDomainHistory(
assembleDomainHistory(
jpaTm().loadByKey(VKey.createSql(DomainHistoryLite.class, domainHistoryId)),
jpaTm()
.loadAllOfStream(DomainDsDataHistory.class)
@@ -15,13 +15,14 @@
package google.registry.model.bulkquery;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.bulkquery.BulkQueryHelper.loadAndAssembleDomain;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static org.joda.time.DateTimeZone.UTC;
import com.google.common.collect.Sets;
import com.google.common.collect.Sets.SetView;
import com.google.common.truth.Truth8;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.FakeClock;
import java.util.Set;
@@ -33,8 +34,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for reading {@link DomainBaseLite}. */
class DomainBaseLiteTest {
/** Unit tests for reading {@link DomainLite}. */
class DomainLiteTest {
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@@ -65,53 +66,46 @@ class DomainBaseLiteTest {
}
@Test
void domainBaseLiteAttributes_versusDomainBase() {
Set<String> domainBaseAttributes =
void domainLiteAttributes_versusDomain() {
Set<String> domainAttributes =
jpaTm()
.transact(
() ->
jpaTm()
.getEntityManager()
.getMetamodel()
.entity(DomainBase.class)
.getAttributes())
jpaTm().getEntityManager().getMetamodel().entity(Domain.class).getAttributes())
.stream()
.map(Attribute::getName)
.collect(Collectors.toSet());
setupHelper.setupBulkQueryJpaTm(appEngine);
Set<String> domainBaseLiteAttributes =
Set<String> domainLiteAttributes =
jpaTm()
.transact(
() ->
jpaTm()
.getEntityManager()
.getMetamodel()
.entity(DomainBaseLite.class)
.entity(DomainLite.class)
.getAttributes())
.stream()
.map(Attribute::getName)
.collect(Collectors.toSet());
assertThat(domainBaseAttributes).containsAtLeastElementsIn(domainBaseLiteAttributes);
assertThat(domainAttributes).containsAtLeastElementsIn(domainLiteAttributes);
SetView<?> excludedFromDomainBase =
Sets.difference(domainBaseAttributes, domainBaseLiteAttributes);
assertThat(excludedFromDomainBase)
SetView<?> excludedFromDomain = Sets.difference(domainAttributes, domainLiteAttributes);
assertThat(excludedFromDomain)
.containsExactly("internalDelegationSignerData", "internalGracePeriods", "nsHosts");
}
@Test
void readDomainBaseLite_simple() {
void readDomainLite_simple() {
setupHelper.setupBulkQueryJpaTm(appEngine);
assertThat(BulkQueryHelper.loadAndAssembleDomainBase(TestSetupHelper.DOMAIN_REPO_ID))
.isEqualTo(setupHelper.domain);
assertThat(loadAndAssembleDomain(TestSetupHelper.DOMAIN_REPO_ID)).isEqualTo(setupHelper.domain);
}
@Test
void readDomainBaseLite_full() {
void readDomainLite_full() {
setupHelper.applyChangeToDomainAndHistory();
setupHelper.setupBulkQueryJpaTm(appEngine);
assertThat(BulkQueryHelper.loadAndAssembleDomainBase(TestSetupHelper.DOMAIN_REPO_ID))
.isEqualTo(setupHelper.domain);
assertThat(loadAndAssembleDomain(TestSetupHelper.DOMAIN_REPO_ID)).isEqualTo(setupHelper.domain);
}
}
@@ -24,8 +24,8 @@ import com.google.common.base.Ascii;
import com.google.common.collect.ImmutableSet;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.Period;
@@ -73,7 +73,7 @@ public final class TestSetupHelper {
public Registry registry;
public Registrar registrar;
public ContactResource contact;
public DomainBase domain;
public Domain domain;
public DomainHistory domainHistory;
public HostResource host;
@@ -127,16 +127,15 @@ public final class TestSetupHelper {
.build();
}
static DomainBase createSimpleDomain(ContactResource contact) {
return DatabaseHelper.newDomainBase(DOMAIN_NAME, DOMAIN_REPO_ID, contact)
static Domain createSimpleDomain(ContactResource contact) {
return DatabaseHelper.newDomain(DOMAIN_NAME, DOMAIN_REPO_ID, contact)
.asBuilder()
.setCreationRegistrarId(REGISTRAR_ID)
.setPersistedCurrentSponsorRegistrarId(REGISTRAR_ID)
.build();
}
static DomainBase createFullDomain(
ContactResource contact, HostResource host, FakeClock fakeClock) {
static Domain createFullDomain(ContactResource contact, HostResource host, FakeClock fakeClock) {
return createSimpleDomain(contact)
.asBuilder()
.setDomainName(DOMAIN_NAME)
@@ -188,7 +187,7 @@ public final class TestSetupHelper {
.build();
}
static DomainHistory createHistoryWithoutContent(DomainBase domain, FakeClock fakeClock) {
static DomainHistory createHistoryWithoutContent(Domain domain, FakeClock fakeClock) {
return new DomainHistory.Builder()
.setType(HistoryEntry.Type.DOMAIN_CREATE)
.setXmlBytes("<xml></xml>".getBytes(UTF_8))
@@ -204,7 +203,7 @@ public final class TestSetupHelper {
.build();
}
static DomainHistory createFullHistory(DomainBase domain, FakeClock fakeClock) {
static DomainHistory createFullHistory(Domain domain, FakeClock fakeClock) {
return createHistoryWithoutContent(domain, fakeClock)
.asBuilder()
.setType(HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE)
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
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;
@@ -61,7 +61,7 @@ public class ClassPathManagerTest {
.isEqualTo(EppResourceIndexBucket.class);
assertThat(ClassPathManager.getClass("EntityGroupRoot")).isEqualTo(EntityGroupRoot.class);
assertThat(ClassPathManager.getClass("Lock")).isEqualTo(Lock.class);
assertThat(ClassPathManager.getClass("DomainBase")).isEqualTo(DomainBase.class);
assertThat(ClassPathManager.getClass("Domain")).isEqualTo(Domain.class);
assertThat(ClassPathManager.getClass("HistoryEntry")).isEqualTo(HistoryEntry.class);
assertThat(ClassPathManager.getClass("PollMessage")).isEqualTo(PollMessage.class);
assertThat(ClassPathManager.getClass("ForeignKeyHostIndex"))
@@ -115,7 +115,7 @@ public class ClassPathManagerTest {
.isEqualTo("EppResourceIndexBucket");
assertThat(ClassPathManager.getClassName(EntityGroupRoot.class)).isEqualTo("EntityGroupRoot");
assertThat(ClassPathManager.getClassName(Lock.class)).isEqualTo("Lock");
assertThat(ClassPathManager.getClassName(DomainBase.class)).isEqualTo("DomainBase");
assertThat(ClassPathManager.getClassName(Domain.class)).isEqualTo("Domain");
assertThat(ClassPathManager.getClassName(HistoryEntry.class)).isEqualTo("HistoryEntry");
assertThat(ClassPathManager.getClassName(PollMessage.class)).isEqualTo("PollMessage");
assertThat(ClassPathManager.getClassName(ForeignKeyHostIndex.class))
@@ -64,8 +64,8 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
/** Verify that we can store/retrieve DomainBase objects from a SQL database. */
public class DomainBaseSqlTest {
/** Verify that we can store/retrieve Domain objects from a SQL database. */
public class DomainSqlTest {
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@@ -77,7 +77,7 @@ public class DomainBaseSqlTest {
.withClock(fakeClock)
.build();
private DomainBase domain;
private Domain domain;
private DomainHistory historyEntry;
private VKey<ContactResource> contactKey;
private VKey<ContactResource> contact2Key;
@@ -98,7 +98,7 @@ public class DomainBaseSqlTest {
host1VKey = createKey(HostResource.class, "host1");
domain =
new DomainBase.Builder()
new Domain.Builder()
.setDomainName("example.com")
.setRepoId("4-COM")
.setCreationRegistrarId("registrar1")
@@ -141,7 +141,7 @@ public class DomainBaseSqlTest {
}
@Test
void testDomainBasePersistence() {
void testDomainPersistence() {
persistDomain();
assertEqualDomainExcept(loadByKey(domain.createVKey()));
}
@@ -164,7 +164,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
jpaTm().put(persisted.asBuilder().build());
});
// Load the domain in its entirety.
@@ -177,16 +177,15 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
DomainBase modified =
persisted.asBuilder().setGracePeriods(ImmutableSet.of()).build();
Domain persisted = jpaTm().loadByKey(domain.createVKey());
Domain modified = persisted.asBuilder().setGracePeriods(ImmutableSet.of()).build();
jpaTm().put(modified);
});
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getGracePeriods()).isEmpty();
});
}
@@ -197,15 +196,15 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
DomainBase modified = persisted.asBuilder().setGracePeriods(null).build();
Domain persisted = jpaTm().loadByKey(domain.createVKey());
Domain modified = persisted.asBuilder().setGracePeriods(null).build();
jpaTm().put(modified);
});
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getGracePeriods()).isEmpty();
});
}
@@ -216,8 +215,8 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
DomainBase modified =
Domain persisted = jpaTm().loadByKey(domain.createVKey());
Domain modified =
persisted
.asBuilder()
.addGracePeriod(
@@ -235,7 +234,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getGracePeriods())
.containsExactly(
GracePeriod.create(
@@ -248,8 +247,8 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
DomainBase.Builder builder = persisted.asBuilder();
Domain persisted = jpaTm().loadByKey(domain.createVKey());
Domain.Builder builder = persisted.asBuilder();
for (GracePeriod gracePeriod : persisted.getGracePeriods()) {
if (gracePeriod.getType() == GracePeriodStatus.RENEW) {
builder.removeGracePeriod(gracePeriod);
@@ -261,7 +260,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertEqualDomainExcept(persisted);
});
}
@@ -272,18 +271,17 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
DomainBase modified =
persisted.asBuilder().setGracePeriods(ImmutableSet.of()).build();
Domain persisted = jpaTm().loadByKey(domain.createVKey());
Domain modified = persisted.asBuilder().setGracePeriods(ImmutableSet.of()).build();
jpaTm().put(modified);
});
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getGracePeriods()).isEmpty();
DomainBase modified =
Domain modified =
persisted
.asBuilder()
.addGracePeriod(
@@ -301,7 +299,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getGracePeriods())
.containsExactly(
GracePeriod.create(
@@ -322,9 +320,9 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getDsData()).containsExactlyElementsIn(domain.getDsData());
DomainBase modified = persisted.asBuilder().setDsData(unionDsData).build();
Domain modified = persisted.asBuilder().setDsData(unionDsData).build();
jpaTm().put(modified);
});
@@ -332,7 +330,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertThat(persisted.getDsData()).containsExactlyElementsIn(unionDsData);
assertEqualDomainExcept(persisted, "dsData");
});
@@ -341,7 +339,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
jpaTm().put(persisted.asBuilder().setDsData(domain.getDsData()).build());
});
@@ -349,7 +347,7 @@ public class DomainBaseSqlTest {
jpaTm()
.transact(
() -> {
DomainBase persisted = jpaTm().loadByKey(domain.createVKey());
Domain persisted = jpaTm().loadByKey(domain.createVKey());
assertEqualDomainExcept(persisted);
});
}
@@ -358,7 +356,7 @@ public class DomainBaseSqlTest {
void testSerializable() {
createTld("com");
insertInDb(contact, contact2, domain, host);
DomainBase persisted = jpaTm().transact(() -> jpaTm().loadByEntity(domain));
Domain persisted = jpaTm().transact(() -> jpaTm().loadByEntity(domain));
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
}
@@ -484,7 +482,7 @@ public class DomainBaseSqlTest {
domain);
// Store the existing BillingRecurrence VKey. This happens after the event has been persisted.
DomainBase persisted = loadByKey(domain.createVKey());
Domain persisted = loadByKey(domain.createVKey());
// Verify that the domain data has been persisted.
// dsData still isn't persisted. gracePeriods appears to have the same values but for some
@@ -616,7 +614,7 @@ public class DomainBaseSqlTest {
domain);
// Store the existing BillingRecurrence VKey. This happens after the event has been persisted.
DomainBase persisted = loadByKey(domain.createVKey());
Domain persisted = loadByKey(domain.createVKey());
// Verify that the domain data has been persisted.
// dsData still isn't persisted. gracePeriods appears to have the same values but for some
@@ -652,7 +650,7 @@ public class DomainBaseSqlTest {
clazz, id, Key.create(Key.create(EntityGroupRoot.class, "per-tld"), clazz, id));
}
private void assertEqualDomainExcept(DomainBase thatDomain, String... excepts) {
private void assertEqualDomainExcept(Domain thatDomain, String... excepts) {
ImmutableList<String> moreExcepts =
new ImmutableList.Builder<String>()
.addAll(Arrays.asList(excepts))
@@ -671,7 +669,7 @@ public class DomainBaseSqlTest {
@Test
void testUpdateTimeAfterNameserverUpdate() {
persistDomain();
DomainBase persisted = loadByKey(domain.createVKey());
Domain persisted = loadByKey(domain.createVKey());
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
fakeClock.advanceOneMilli();
DateTime transactionTime =
@@ -698,7 +696,7 @@ public class DomainBaseSqlTest {
@Test
void testUpdateTimeAfterDsDataUpdate() {
persistDomain();
DomainBase persisted = loadByKey(domain.createVKey());
Domain persisted = loadByKey(domain.createVKey());
DateTime originalUpdateTime = persisted.getUpdateTimestamp().getTimestamp();
fakeClock.advanceOneMilli();
DateTime transactionTime =
@@ -22,13 +22,12 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.DomainBaseSubject.assertAboutDomains;
import static google.registry.testing.DomainSubject.assertAboutDomains;
import static google.registry.testing.SqlHelper.saveRegistrar;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
@@ -64,6 +63,7 @@ import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.util.Optional;
import org.joda.money.Money;
@@ -72,9 +72,9 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Unit tests for {@link DomainBase}. */
/** Unit tests for {@link Domain}. */
@SuppressWarnings("WeakerAccess") // Referred to by EppInputTest.
public class DomainBaseTest {
public class DomainTest {
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@@ -86,7 +86,7 @@ public class DomainBaseTest {
.withClock(fakeClock)
.build();
private DomainBase domain;
private Domain domain;
private VKey<BillingEvent.OneTime> oneTimeBillKey;
private VKey<BillingEvent.Recurring> recurringBillKey;
private DomainHistory domainHistory;
@@ -171,7 +171,7 @@ public class DomainBaseTest {
domain =
persistResource(
cloneAndSetAutoTimestamps(
new DomainBase.Builder()
new Domain.Builder()
.setDomainName("example.com")
.setRepoId("4-COM")
.setCreationRegistrarId("TheRegistrar")
@@ -230,9 +230,9 @@ public class DomainBaseTest {
}
@Test
void testDomainContentToDomainBase() {
void testDomainContentToDomain() {
ImmutableObjectSubject.assertAboutImmutableObjects()
.that(new DomainBase.Builder().copyFrom(domain).build())
.that(new Domain.Builder().copyFrom(domain).build())
.isEqualExceptFields(domain, "updateTimestamp", "revisions");
}
@@ -241,28 +241,28 @@ public class DomainBaseTest {
// Note that this only verifies that the value stored under the foreign key is the same as that
// stored under the primary key ("domain" is the domain loaded from the datastore, not the
// original domain object).
assertThat(loadByForeignKey(DomainBase.class, domain.getForeignKey(), fakeClock.nowUtc()))
assertThat(loadByForeignKey(Domain.class, domain.getForeignKey(), fakeClock.nowUtc()))
.hasValue(domain);
}
@Test
void testEmptyStringsBecomeNull() {
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId(null)
.build()
.getCurrentSponsorRegistrarId())
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("")
.build()
.getCurrentSponsorRegistrarId())
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId(" ")
.build()
@@ -272,21 +272,21 @@ public class DomainBaseTest {
void testEmptySetsAndArraysBecomeNull() {
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(ImmutableSet.of())
.build()
.nsHosts)
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(ImmutableSet.of())
.build()
.nsHosts)
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(ImmutableSet.of(newHostResource("foo.example.tld").createVKey()))
.build()
@@ -294,7 +294,7 @@ public class DomainBaseTest {
.isNotNull();
// This behavior should also hold true for ImmutableObjects nested in collections.
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, (byte[]) null)))
.build()
@@ -304,7 +304,7 @@ public class DomainBaseTest {
.getDigest())
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, new byte[] {})))
.build()
@@ -314,7 +314,7 @@ public class DomainBaseTest {
.getDigest())
.isNull();
assertThat(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 1, 1, new byte[] {1})))
.build()
@@ -327,8 +327,9 @@ public class DomainBaseTest {
@Test
void testEmptyTransferDataBecomesNull() {
DomainBase withNull = newDomainBase("example.com").asBuilder().setTransferData(null).build();
DomainBase withEmpty = withNull.asBuilder().setTransferData(DomainTransferData.EMPTY).build();
Domain withNull =
DatabaseHelper.newDomain("example.com").asBuilder().setTransferData(null).build();
Domain withEmpty = withNull.asBuilder().setTransferData(DomainTransferData.EMPTY).build();
assertThat(withNull).isEqualTo(withEmpty);
assertThat(withEmpty.transferData).isNull();
}
@@ -340,13 +341,14 @@ public class DomainBaseTest {
StatusValue[] statuses = {StatusValue.OK};
// OK is implicit if there's no other statuses but there are nameservers.
assertAboutDomains()
.that(newDomainBase("example.com").asBuilder().setNameservers(nameservers).build())
.that(
DatabaseHelper.newDomain("example.com").asBuilder().setNameservers(nameservers).build())
.hasExactlyStatusValues(statuses);
StatusValue[] statuses1 = {StatusValue.CLIENT_HOLD};
// If there are other status values, OK should be suppressed. (Domains can't be LINKED.)
assertAboutDomains()
.that(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
@@ -356,7 +358,7 @@ public class DomainBaseTest {
// When OK is suppressed, it should be removed even if it was originally there.
assertAboutDomains()
.that(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.OK, StatusValue.CLIENT_HOLD))
@@ -365,13 +367,13 @@ public class DomainBaseTest {
StatusValue[] statuses3 = {StatusValue.INACTIVE};
// If there are no nameservers, INACTIVE should be added, which suppresses OK.
assertAboutDomains()
.that(newDomainBase("example.com").asBuilder().build())
.that(DatabaseHelper.newDomain("example.com").asBuilder().build())
.hasExactlyStatusValues(statuses3);
StatusValue[] statuses4 = {StatusValue.CLIENT_HOLD, StatusValue.INACTIVE};
// If there are no nameservers but there are status values, INACTIVE should still be added.
assertAboutDomains()
.that(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
.build())
@@ -380,7 +382,7 @@ public class DomainBaseTest {
// If there are nameservers, INACTIVE should be removed even if it was originally there.
assertAboutDomains()
.that(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.INACTIVE, StatusValue.CLIENT_HOLD))
@@ -389,9 +391,7 @@ public class DomainBaseTest {
}
private void assertTransferred(
DomainBase domain,
DateTime newExpirationTime,
VKey<BillingEvent.Recurring> newAutorenewEvent) {
Domain domain, DateTime newExpirationTime, VKey<BillingEvent.Recurring> newAutorenewEvent) {
assertThat(domain.getTransferData().getTransferStatus())
.isEqualTo(TransferStatus.SERVER_APPROVED);
assertThat(domain.getCurrentSponsorRegistrarId()).isEqualTo("TheRegistrar");
@@ -453,7 +453,7 @@ public class DomainBaseTest {
"TheRegistrar",
oneTimeBillKey))
.build();
DomainBase afterTransfer = domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(1));
Domain afterTransfer = domain.cloneProjectedAtTime(fakeClock.nowUtc().plusDays(1));
DateTime newExpirationTime = oldExpirationTime.plusYears(1);
VKey<BillingEvent.Recurring> serverApproveAutorenewEvent =
domain.getTransferData().getServerApproveAutorenewEvent();
@@ -471,7 +471,7 @@ public class DomainBaseTest {
transferBillingEvent.createVKey(),
afterTransfer.getGracePeriods().iterator().next().getGracePeriodId()));
// If we project after the grace period expires all should be the same except the grace period.
DomainBase afterGracePeriod =
Domain afterGracePeriod =
domain.cloneProjectedAtTime(
fakeClock
.nowUtc()
@@ -521,13 +521,13 @@ public class DomainBaseTest {
DateTime transferSuccessDateTime = now.plusDays(5);
setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime);
DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
// If autorenew happens before transfer succeeds(before transfer grace period starts as well),
// lastEppUpdateClientId should still be the current sponsor client id
DomainBase afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1));
Domain afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1));
assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime);
assertThat(afterAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("NewRegistrar");
}
@@ -540,12 +540,11 @@ public class DomainBaseTest {
DateTime transferSuccessDateTime = now.plusDays(5);
setupPendingTransferDomain(autorenewDateTime, transferRequestDateTime, transferSuccessDateTime);
DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(transferRequestDateTime);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
DomainBase afterTransferSuccess =
domain.cloneProjectedAtTime(transferSuccessDateTime.plusDays(1));
Domain afterTransferSuccess = domain.cloneProjectedAtTime(transferSuccessDateTime.plusDays(1));
assertThat(afterTransferSuccess.getLastEppUpdateTime()).isEqualTo(transferSuccessDateTime);
assertThat(afterTransferSuccess.getLastEppUpdateRegistrarId()).isEqualTo("TheRegistrar");
}
@@ -568,11 +567,11 @@ public class DomainBaseTest {
DateTime autorenewDateTime = now.plusDays(3);
setupUnmodifiedDomain(autorenewDateTime);
DomainBase beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
Domain beforeAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.minusDays(1));
assertThat(beforeAutoRenew.getLastEppUpdateTime()).isEqualTo(null);
assertThat(beforeAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo(null);
DomainBase afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1));
Domain afterAutoRenew = domain.cloneProjectedAtTime(autorenewDateTime.plusDays(1));
assertThat(afterAutoRenew.getLastEppUpdateTime()).isEqualTo(autorenewDateTime);
assertThat(afterAutoRenew.getLastEppUpdateRegistrarId()).isEqualTo("NewRegistrar");
}
@@ -650,7 +649,7 @@ public class DomainBaseTest {
@Test
void testRenewalsHappenAtExpiration() {
DomainBase renewed = domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime());
Domain renewed = domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime());
assertThat(renewed.getRegistrationExpirationTime())
.isEqualTo(domain.getRegistrationExpirationTime().plusYears(1));
assertThat(renewed.getLastEppUpdateTime()).isEqualTo(domain.getRegistrationExpirationTime());
@@ -661,7 +660,7 @@ public class DomainBaseTest {
@Test
void testTldGetsSet() {
createTld("tld");
domain = newDomainBase("foo.tld");
domain = DatabaseHelper.newDomain("foo.tld");
assertThat(domain.getTld()).isEqualTo("tld");
}
@@ -672,7 +671,7 @@ public class DomainBaseTest {
.asBuilder()
.setRegistrationExpirationTime(DateTime.parse("2004-02-29T22:00:00.0Z"))
.build();
DomainBase renewed =
Domain renewed =
domain.cloneProjectedAtTime(domain.getRegistrationExpirationTime().plusYears(4));
assertThat(renewed.getRegistrationExpirationTime().getDayOfMonth()).isEqualTo(28);
}
@@ -696,7 +695,7 @@ public class DomainBaseTest {
.put(oldExpirationTime.plusYears(2).plusMillis(1), Money.of(USD, 5))
.build())
.build());
DomainBase renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2));
Domain renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2));
assertThat(renewedThreeTimes.getRegistrationExpirationTime())
.isEqualTo(oldExpirationTime.plusYears(3));
assertThat(renewedThreeTimes.getLastEppUpdateTime()).isEqualTo(oldExpirationTime.plusYears(2));
@@ -881,7 +880,7 @@ public class DomainBaseTest {
.setTransferData(transferData)
.setAutorenewBillingEvent(recurringBillKey)
.build());
DomainBase clone = domain.cloneProjectedAtTime(now);
Domain clone = domain.cloneProjectedAtTime(now);
assertThat(clone.getRegistrationExpirationTime())
.isEqualTo(domain.getRegistrationExpirationTime().plusYears(1));
// Transferring removes the AUTORENEW grace period and adds a TRANSFER grace period
@@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableSortedMap;
import com.googlecode.objectify.Key;
import google.registry.model.EntityTestCase;
import google.registry.model.billing.BillingEvent.RenewalPriceBehavior;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.token.AllocationToken.RegistrationBehavior;
import google.registry.model.domain.token.AllocationToken.TokenStatus;
import google.registry.model.domain.token.AllocationToken.TokenType;
@@ -79,7 +79,7 @@ public class AllocationTokenTest extends EntityTestCase {
.build());
assertThat(loadByEntity(unlimitedUseToken)).isEqualTo(unlimitedUseToken);
DomainBase domain = persistActiveDomain("example.foo");
Domain domain = persistActiveDomain("example.foo");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1);
AllocationToken singleUseToken =
persistResource(
@@ -116,7 +116,7 @@ public class AllocationTokenTest extends EntityTestCase {
AllocationToken persisted = loadByEntity(unlimitedUseToken);
assertThat(SerializeUtils.serializeDeserialize(persisted)).isEqualTo(persisted);
DomainBase domain = persistActiveDomain("example.foo");
Domain domain = persistActiveDomain("example.foo");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1);
AllocationToken singleUseToken =
persistResource(
@@ -264,7 +264,7 @@ public class AllocationTokenTest extends EntityTestCase {
@Test
void testBuild_redemptionHistoryEntryOnlyInSingleUse() {
DomainBase domain = persistActiveDomain("blahdomain.foo");
Domain domain = persistActiveDomain("blahdomain.foo");
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1);
AllocationToken.Builder builder =
new AllocationToken.Builder()
@@ -21,7 +21,7 @@ import static google.registry.testing.TestDataHelper.loadBytes;
import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.contact.ContactResourceTest;
import google.registry.model.domain.DomainBaseTest;
import google.registry.model.domain.DomainTest;
import google.registry.model.eppinput.EppInput.InnerCommand;
import google.registry.model.eppinput.EppInput.Login;
import google.registry.xml.XmlException;
@@ -44,7 +44,7 @@ class EppInputTest {
@Test
void testUnmarshalling_domainCheck() throws Exception {
EppInput input =
unmarshal(EppInput.class, loadBytes(DomainBaseTest.class, "domain_check.xml").read());
unmarshal(EppInput.class, loadBytes(DomainTest.class, "domain_check.xml").read());
assertThat(input.getCommandWrapper().getClTrid()).hasValue("ABC-12345");
assertThat(input.getCommandType()).isEqualTo("check");
assertThat(input.getResourceType()).hasValue("domain");
@@ -20,7 +20,7 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.newHostResourceWithRoid;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -28,7 +28,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainContent;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
@@ -60,7 +60,7 @@ public class DomainHistoryTest extends EntityTestCase {
@Test
void testPersistence() {
DomainBase domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
Domain domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
DomainHistory domainHistory = createDomainHistory(domain);
insertInDb(domainHistory);
@@ -75,7 +75,7 @@ public class DomainHistoryTest extends EntityTestCase {
@Test
void testSerializable() {
DomainBase domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
Domain domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
DomainHistory domainHistory = createDomainHistory(domain);
insertInDb(domainHistory);
DomainHistory fromDatabase =
@@ -85,7 +85,7 @@ public class DomainHistoryTest extends EntityTestCase {
@Test
void testLegacyPersistence_nullResource() {
DomainBase domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
Domain domain = addGracePeriodForSql(createDomainWithContactsAndHosts());
DomainHistory domainHistory = createDomainHistory(domain).asBuilder().setDomain(null).build();
insertInDb(domainHistory);
@@ -100,7 +100,7 @@ public class DomainHistoryTest extends EntityTestCase {
});
}
static DomainBase createDomainWithContactsAndHosts() {
static Domain createDomainWithContactsAndHosts() {
createTld("tld");
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
ContactResource contact = newContactResourceWithRoid("contactId", "contact1");
@@ -112,8 +112,8 @@ public class DomainHistoryTest extends EntityTestCase {
jpaTm().insert(contact);
});
DomainBase domain =
newDomainBase("example.tld", "domainRepoId", contact)
Domain domain =
newDomain("example.tld", "domainRepoId", contact)
.asBuilder()
.setNameservers(host.createVKey())
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
@@ -123,8 +123,8 @@ public class DomainHistoryTest extends EntityTestCase {
return domain;
}
private static DomainBase addGracePeriodForSql(DomainBase domainBase) {
return domainBase
private static Domain addGracePeriodForSql(Domain domain) {
return domain
.asBuilder()
.setGracePeriods(
ImmutableSet.of(
@@ -19,7 +19,6 @@ import static google.registry.model.ImmutableObjectSubject.immutableObjectCorres
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.cloneAndSetAutoTimestamps;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistNewRegistrars;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.HostResourceSubject.assertAboutHosts;
@@ -30,11 +29,12 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import google.registry.model.EntityTestCase;
import google.registry.model.ImmutableObjectSubject;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.eppcommon.Trid;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.DatabaseHelper;
import google.registry.util.SerializeUtils;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -47,7 +47,7 @@ class HostResourceTest extends EntityTestCase {
private final DateTime day2 = day3.minusDays(1);
private final DateTime day1 = day2.minusDays(1);
private DomainBase domain;
private Domain domain;
private HostResource host;
@BeforeEach
@@ -57,7 +57,7 @@ class HostResourceTest extends EntityTestCase {
// Set up a new persisted registrar entity.
domain =
persistResource(
newDomainBase("example.com")
DatabaseHelper.newDomain("example.com")
.asBuilder()
.setRepoId("1-COM")
.setTransferData(
@@ -17,15 +17,15 @@ package google.registry.model.index;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.TestCacheExtension;
import java.time.Duration;
import org.junit.jupiter.api.BeforeEach;
@@ -46,8 +46,8 @@ class ForeignKeyIndexTest extends EntityTestCase {
@Test
void testModifyForeignKeyIndex_notThrowExceptionInSql() {
DomainBase domainBase = newDomainBase("test.com");
ForeignKeyIndex<DomainBase> fki = ForeignKeyIndex.create(domainBase, fakeClock.nowUtc());
Domain domain = DatabaseHelper.newDomain("test.com");
ForeignKeyIndex<Domain> fki = ForeignKeyIndex.create(domain, fakeClock.nowUtc());
tm().transact(() -> tm().insert(fki));
tm().transact(() -> tm().put(fki));
tm().transact(() -> tm().delete(fki));
@@ -19,7 +19,6 @@ import static google.registry.persistence.transaction.TransactionManagerFactory.
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.insertInDb;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistResource;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -27,13 +26,14 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableList;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PendingActionNotificationResponse.HostPendingActionNotificationResponse;
import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import google.registry.util.SerializeUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test;
/** Unit tests for {@link PollMessage}. */
public class PollMessageTest extends EntityTestCase {
private DomainBase domain;
private Domain domain;
private HistoryEntry historyEntry;
private PollMessage.OneTime oneTime;
private PollMessage.Autorenew autoRenew;
@@ -54,7 +54,7 @@ public class PollMessageTest extends EntityTestCase {
void setUp() {
createTld("foobar");
ContactResource contact = persistActiveContact("contact1234");
domain = persistResource(newDomainBase("foo.foobar", contact));
domain = persistResource(DatabaseHelper.newDomain("foo.foobar", contact));
historyEntry =
persistResource(
new DomainHistory.Builder()
@@ -18,7 +18,7 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -27,18 +27,19 @@ import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
import google.registry.model.reporting.DomainTransactionRecord.TransactionReportField;
import google.registry.testing.DatabaseHelper;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
class HistoryEntryDaoTest extends EntityTestCase {
private DomainBase domain;
private Domain domain;
private HistoryEntry domainHistory;
@BeforeEach
@@ -120,7 +121,7 @@ class HistoryEntryDaoTest extends EntityTestCase {
@Test
void testLoadByResource_noEntriesForResource() {
DomainBase newDomain = persistResource(newDomainBase("new.foobar"));
Domain newDomain = persistResource(DatabaseHelper.newDomain("new.foobar"));
assertThat(HistoryEntryDao.loadHistoryObjectsForResource(newDomain.createVKey())).isEmpty();
}
}
@@ -26,7 +26,7 @@ import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactHistory;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
@@ -44,7 +44,7 @@ class HistoryEntryTest extends EntityTestCase {
@BeforeEach
void setUp() {
createTld("foobar");
DomainBase domain = persistActiveDomain("foo.foobar");
Domain domain = persistActiveDomain("foo.foobar");
DomainTransactionRecord transactionRecord =
new DomainTransactionRecord.Builder()
.setTld("foobar")
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ImmutableObjectSubject.immutableObjectCorrespondence;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -26,8 +25,9 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.reporting.Spec11ThreatMatch.ThreatType;
import google.registry.testing.DatabaseHelper;
import org.joda.time.LocalDate;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -38,19 +38,19 @@ class Spec11ThreatMatchDaoTest extends EntityTestCase {
private static final LocalDate TODAY = new LocalDate(2020, 8, 4);
private static final LocalDate YESTERDAY = new LocalDate(2020, 8, 3);
private DomainBase todayComDomain;
private DomainBase todayOrgDomain;
private DomainBase yesterdayComDomain;
private DomainBase yesterdayOrgDomain;
private Domain todayComDomain;
private Domain todayOrgDomain;
private Domain yesterdayComDomain;
private Domain yesterdayOrgDomain;
@BeforeEach
void setUp() {
createTlds("com", "org");
ContactResource contact = persistActiveContact("jd1234");
todayComDomain = persistResource(newDomainBase("today.com", contact));
todayOrgDomain = persistResource(newDomainBase("today.org", contact));
yesterdayComDomain = persistResource(newDomainBase("yesterday.com", contact));
yesterdayOrgDomain = persistResource(newDomainBase("yesterday.org", contact));
todayComDomain = persistResource(DatabaseHelper.newDomain("today.com", contact));
todayOrgDomain = persistResource(DatabaseHelper.newDomain("today.org", contact));
yesterdayComDomain = persistResource(DatabaseHelper.newDomain("yesterday.com", contact));
yesterdayOrgDomain = persistResource(DatabaseHelper.newDomain("yesterday.org", contact));
jpaTm()
.transact(
() -> {
@@ -27,7 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
import google.registry.model.EntityTestCase;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.transfer.ContactTransferData;
import google.registry.persistence.VKey;
@@ -44,7 +44,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
private static final LocalDate DATE = LocalDate.parse("2020-06-10", ISODateTimeFormat.date());
private Spec11ThreatMatch threat;
private DomainBase domain;
private Domain domain;
private HostResource host;
private ContactResource registrantContact;
@@ -62,7 +62,7 @@ public final class Spec11ThreatMatchTest extends EntityTestCase {
// Create a domain for the purpose of testing a foreign key reference in the Threat table.
domain =
new DomainBase()
new Domain()
.asBuilder()
.setCreationRegistrarId(REGISTRAR_ID)
.setPersistedCurrentSponsorRegistrarId(REGISTRAR_ID)
@@ -23,7 +23,7 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Cancellation;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.billing.BillingEvent.Recurring;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.eppcommon.Trid;
import google.registry.model.poll.PollMessage;
@@ -52,7 +52,7 @@ public class TransferDataTest {
@BeforeEach
void beforeEach() {
Key<HistoryEntry> historyEntryKey =
Key.create(Key.create(DomainBase.class, "4-TLD"), HistoryEntry.class, 1356L);
Key.create(Key.create(Domain.class, "4-TLD"), HistoryEntry.class, 1356L);
transferBillingEventKey = OneTime.createVKey(12345L);
otherServerApproveBillingEventKey = Cancellation.createVKey(2468L);
recurringBillingEventKey = Recurring.createVKey(13579L);
@@ -15,12 +15,12 @@
package google.registry.model.translators;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import com.googlecode.objectify.Key;
import google.registry.model.common.ClassPathManager;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.reporting.HistoryEntry;
@@ -49,17 +49,17 @@ public class VKeyTranslatorFactoryTest {
void testEntityWithFlatKey() {
// Creating an objectify key instead of a datastore key as this should get a correctly formatted
// key path.
DomainBase domain = newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<DomainBase> key = Key.create(domain);
VKey<DomainBase> vkey = VKeyTranslatorFactory.createVKey(key);
assertThat(vkey.getKind()).isEqualTo(DomainBase.class);
Domain domain = newDomain("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<Domain> key = Key.create(domain);
VKey<Domain> vkey = VKeyTranslatorFactory.createVKey(key);
assertThat(vkey.getKind()).isEqualTo(Domain.class);
assertThat(vkey.getOfyKey()).isEqualTo(key);
assertThat(vkey.getSqlKey()).isEqualTo("ROID-1");
}
@Test
void testEntityWithAncestor() {
Key<DomainBase> domainKey = Key.create(DomainBase.class, "ROID-1");
Key<Domain> domainKey = Key.create(Domain.class, "ROID-1");
Key<HistoryEntry> historyEntryKey = Key.create(domainKey, HistoryEntry.class, 10L);
VKey<HistoryEntry> vkey = VKeyTranslatorFactory.createVKey(historyEntryKey);
@@ -24,7 +24,7 @@ import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Parent;
import google.registry.model.ImmutableObject;
import google.registry.model.common.EntityGroupRoot;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.AppEngineExtension;
@@ -46,7 +46,7 @@ class DomainHistoryVKeyTest {
@Test
void testRestoreSymmetricVKey() {
Key<HistoryEntry> ofyKey =
Key.create(Key.create(DomainBase.class, "domainRepoId"), HistoryEntry.class, 10L);
Key.create(Key.create(Domain.class, "domainRepoId"), HistoryEntry.class, 10L);
DomainHistoryVKey domainHistoryVKey = DomainHistoryVKey.create(ofyKey);
TestEntity original = new TestEntity(domainHistoryVKey);
tm().transact(() -> tm().insert(original));
@@ -62,7 +62,7 @@ class DomainHistoryVKeyTest {
@Test
void testCreateSymmetricVKeyFromOfyKey() {
Key<HistoryEntry> ofyKey =
Key.create(Key.create(DomainBase.class, "domainRepoId"), HistoryEntry.class, 10L);
Key.create(Key.create(Domain.class, "domainRepoId"), HistoryEntry.class, 10L);
DomainHistoryVKey domainHistoryVKey = DomainHistoryVKey.create(ofyKey);
assertThat(domainHistoryVKey.createSqlKey())
.isEqualTo(new DomainHistoryId("domainRepoId", 10L));
@@ -15,7 +15,7 @@ package google.registry.persistence;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newDomain;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -23,7 +23,7 @@ import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Entity;
import google.registry.model.billing.BillingEvent.OneTime;
import google.registry.model.common.ClassPathManager;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.registrar.RegistrarPoc;
import google.registry.testing.AppEngineExtension;
@@ -127,10 +127,10 @@ class VKeyTest {
// Creating an objectify key instead of a datastore key as this should get a correctly formatted
// key path. We have to one of our actual model object classes for this, TestObject can not be
// reconstructed by the VKeyTranslatorFactory.
DomainBase domain = newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<DomainBase> key = Key.create(domain);
VKey<DomainBase> vkey = VKey.fromWebsafeKey(key.getString());
assertThat(vkey.getKind()).isEqualTo(DomainBase.class);
Domain domain = newDomain("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<Domain> key = Key.create(domain);
VKey<Domain> vkey = VKey.fromWebsafeKey(key.getString());
assertThat(vkey.getKind()).isEqualTo(Domain.class);
assertThat(vkey.getOfyKey()).isEqualTo(key);
assertThat(vkey.getSqlKey()).isEqualTo("ROID-1");
}
@@ -150,14 +150,12 @@ class VKeyTest {
@Test
void testStringify_vkeyFromWebsafeKey() {
DomainBase domain = newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<DomainBase> key = Key.create(domain);
VKey<DomainBase> vkey = VKey.fromWebsafeKey(key.getString());
Domain domain = newDomain("example.com", "ROID-1", persistActiveContact("contact-1"));
Key<Domain> key = Key.create(domain);
VKey<Domain> vkey = VKey.fromWebsafeKey(key.getString());
assertThat(vkey.stringify())
.isEqualTo(
"kind:DomainBase"
+ "@sql:rO0ABXQABlJPSUQtMQ"
+ "@ofy:agR0ZXN0chYLEgpEb21haW5CYXNlIgZST0lELTEM");
"kind:Domain" + "@sql:rO0ABXQABlJPSUQtMQ" + "@ofy:agR0ZXN0chILEgZEb21haW4iBlJPSUQtMQw");
}
@Test
@@ -236,19 +234,18 @@ class VKeyTest {
void testCreate_stringifyVkey_fromWebsafeKey() {
assertThat(
VKey.create(
"kind:DomainBase@sql:rO0ABXQABlJPSUQtMQ"
"kind:Domain@sql:rO0ABXQABlJPSUQtMQ"
+ "@ofy:agR0ZXN0chYLEgpEb21haW5CYXNlIgZST0lELTEM"))
.isEqualTo(
VKey.fromWebsafeKey(
Key.create(
newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1")))
Key.create(newDomain("example.com", "ROID-1", persistActiveContact("contact-1")))
.getString()));
}
@Test
void testCreate_stringifedVKey_websafeKey() {
assertThat(VKey.create("agR0ZXN0chYLEgpEb21haW5CYXNlIgZST0lELTEM"))
.isEqualTo(VKey.fromWebsafeKey("agR0ZXN0chYLEgpEb21haW5CYXNlIgZST0lELTEM"));
assertThat(VKey.create("agR0ZXN0chkLEgZEb21haW4iDUdBU0RHSDQyMkQtSUQM"))
.isEqualTo(VKey.fromWebsafeKey("agR0ZXN0chkLEgZEb21haW4iDUdBU0RHSDQyMkQtSUQM"));
}
@Test
@@ -286,7 +283,7 @@ class VKeyTest {
@Test
void testCreate_createFromExistingOfyKey_success() {
String keyString =
Key.create(newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1")))
Key.create(newDomain("example.com", "ROID-1", persistActiveContact("contact-1")))
.getString();
assertThat(VKey.fromWebsafeKey(keyString)).isEqualTo(VKey.create(keyString));
}
@@ -21,7 +21,7 @@ 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.makeDomainBase;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
@@ -29,7 +29,7 @@ import static org.mockito.Mockito.verify;
import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.host.HostResource;
import google.registry.model.registrar.Registrar;
@@ -90,7 +90,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
HostResource host2 = makeAndPersistHostResource(
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
persistResource(
makeDomainBase(
makeDomain(
"cat.lol",
registrantLol,
adminContactLol,
@@ -106,9 +106,9 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
// deleted domain in lol
HostResource hostDodo2 = makeAndPersistHostResource(
"ns2.dodo.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2));
DomainBase domainDeleted =
Domain domainDeleted =
persistResource(
makeDomainBase(
makeDomain(
"dodo.lol",
makeAndPersistContactResource(
"5372808-ERL",
@@ -163,7 +163,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
clock.nowUtc().minusYears(3),
registrarIdn);
persistResource(
makeDomainBase(
makeDomain(
"cat.みんな",
registrantIdn,
adminContactIdn,
@@ -203,7 +203,7 @@ class RdapDomainActionTest extends RdapActionBaseTestCase<RdapDomainAction> {
clock.nowUtc().minusYears(3),
registrar1Tld);
persistResource(
makeDomainBase(
makeDomain(
"cat.1.tld",
registrant1Tld,
adminContact1Tld,
@@ -25,7 +25,7 @@ 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.makeDomainBase;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrarContacts;
@@ -38,7 +38,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.host.HostResource;
import google.registry.model.registrar.Registrar;
@@ -65,11 +65,11 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
}
private Registrar registrar;
private DomainBase domainCatLol;
private DomainBase domainCatLol2;
private DomainBase domainCatExample;
private DomainBase domainIdn;
private DomainBase domainMultipart;
private Domain domainCatLol;
private Domain domainCatLol2;
private Domain domainCatExample;
private Domain domainIdn;
private Domain domainMultipart;
private ContactResource contact1;
private ContactResource contact2;
private ContactResource contact3;
@@ -153,7 +153,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
"ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef", clock.nowUtc().minusYears(2)));
domainCatLol =
persistResource(
makeDomainBase(
makeDomain(
"cat.lol",
contact1,
contact2,
@@ -173,7 +173,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
domainCatLol2 =
persistResource(
makeDomainBase(
makeDomain(
"cat2.lol",
makeAndPersistContactResource(
"6372808-ERL",
@@ -214,7 +214,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
persistSimpleResources(makeRegistrarContacts(registrar));
domainCatExample =
persistResource(
makeDomainBase(
makeDomain(
"cat.example",
makeAndPersistContactResource(
"7372808-ERL",
@@ -251,7 +251,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
persistSimpleResources(makeRegistrarContacts(registrar));
domainIdn =
persistResource(
makeDomainBase(
makeDomain(
"cat.みんな",
makeAndPersistContactResource(
"8372808-ERL",
@@ -290,7 +290,7 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
persistSimpleResources(makeRegistrarContacts(registrar));
domainMultipart =
persistResource(
makeDomainBase(
makeDomain(
"cat.1.test",
makeAndPersistContactResource(
"9372808-ERL",
@@ -415,11 +415,11 @@ class RdapDomainSearchActionTest extends RdapSearchActionTestCase<RdapDomainSear
}
ImmutableSet<VKey<HostResource>> hostKeys = hostKeysBuilder.build();
// Create all the domains at once, then persist them in parallel, for increased efficiency.
ImmutableList.Builder<DomainBase> domainsBuilder = new ImmutableList.Builder<>();
ImmutableList.Builder<Domain> domainsBuilder = new ImmutableList.Builder<>();
for (int i = numActiveDomains * numTotalDomainsPerActiveDomain; i >= 1; i--) {
String domainName = String.format("domain%d.lol", i);
DomainBase.Builder builder =
makeDomainBase(domainName, contact1, contact2, contact3, null, null, registrar)
Domain.Builder builder =
makeDomain(domainName, contact1, contact2, contact3, null, null, registrar)
.asBuilder()
.setNameservers(hostKeys)
.setCreationTimeForTest(clock.nowUtc().minusYears(3))
@@ -22,7 +22,7 @@ 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.makeAndPersistDeletedContactResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomainBase;
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;
@@ -89,13 +89,8 @@ class RdapEntityActionTest extends RdapActionBaseTestCase<RdapEntityAction> {
persistResource(makeHostResource("ns1.cat.lol", "1.2.3.4"));
HostResource host2 =
persistResource(makeHostResource("ns2.cat.lol", "bad:f00d:cafe:0:0:0:15:beef"));
persistResource(makeDomainBase("cat.lol",
registrant,
adminContact,
techContact,
host1,
host2,
registrarLol));
persistResource(
makeDomain("cat.lol", registrant, adminContact, techContact, host1, host2, registrarLol));
// xn--q9jyb4c
createTld("xn--q9jyb4c");
Registrar registrarIdn = persistResource(
@@ -22,7 +22,7 @@ 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.makeDomainBase;
import static google.registry.testing.FullFieldsTestEntityHelper.makeDomain;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import static google.registry.testing.FullFieldsTestEntityHelper.makeRegistrar;
import static google.registry.testing.TestDataHelper.loadFile;
@@ -35,7 +35,7 @@ import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.ofy.Ofy;
@@ -70,8 +70,8 @@ class RdapJsonFormatterTest {
private RdapJsonFormatter rdapJsonFormatter;
private Registrar registrar;
private DomainBase domainBaseFull;
private DomainBase domainBaseNoNameserversNoTransfers;
private Domain domainFull;
private Domain domainNoNameserversNoTransfers;
private HostResource hostResourceIpv4;
private HostResource hostResourceIpv6;
private HostResource hostResourceBoth;
@@ -158,7 +158,7 @@ class RdapJsonFormatterTest {
.asBuilder()
.setSuperordinateDomain(
persistResource(
makeDomainBase(
makeDomain(
"dog.みんな",
contactResourceRegistrant,
contactResourceAdmin,
@@ -182,9 +182,9 @@ class RdapJsonFormatterTest {
.build())
.createVKey())
.build());
domainBaseFull =
domainFull =
persistResource(
makeDomainBase(
makeDomain(
"cat.みんな",
contactResourceRegistrant,
contactResourceAdmin,
@@ -196,9 +196,9 @@ class RdapJsonFormatterTest {
.setCreationTimeForTest(clock.nowUtc().minusMonths(4))
.setLastEppUpdateTime(clock.nowUtc().minusMonths(3))
.build());
domainBaseNoNameserversNoTransfers =
domainNoNameserversNoTransfers =
persistResource(
makeDomainBase(
makeDomain(
"fish.みんな",
contactResourceRegistrant,
contactResourceRegistrant,
@@ -213,7 +213,7 @@ class RdapJsonFormatterTest {
// Create an unused domain that references hostResourceBoth and hostResourceNoAddresses so that
// they will have "associated" (ie, StatusValue.LINKED) status.
persistResource(
makeDomainBase(
makeDomain(
"dog.みんな",
contactResourceRegistrant,
contactResourceAdmin,
@@ -226,30 +226,30 @@ class RdapJsonFormatterTest {
// We create 3 "transfer approved" entries, to make sure we only save the last one
persistResource(
makeHistoryEntry(
domainBaseFull,
domainFull,
HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE,
null,
null,
clock.nowUtc().minusMonths(3)));
persistResource(
makeHistoryEntry(
domainBaseFull,
domainFull,
HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE,
null,
null,
clock.nowUtc().minusMonths(1)));
persistResource(
makeHistoryEntry(
domainBaseFull,
domainFull,
HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE,
null,
null,
clock.nowUtc().minusMonths(2)));
// We create a "transfer approved" entry for domainBaseNoNameserversNoTransfers that happened
// We create a "transfer approved" entry for domainNoNameserversNoTransfers that happened
// before the domain was created, to make sure we don't show it
persistResource(
makeHistoryEntry(
domainBaseNoNameserversNoTransfers,
domainNoNameserversNoTransfers,
HistoryEntry.Type.DOMAIN_TRANSFER_APPROVE,
null,
null,
@@ -472,13 +472,13 @@ class RdapJsonFormatterTest {
@Test
void testDomain_full() {
assertThat(rdapJsonFormatter.createRdapDomain(domainBaseFull, OutputDataType.FULL).toJson())
assertThat(rdapJsonFormatter.createRdapDomain(domainFull, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_domain_full.json"));
}
@Test
void testDomain_summary() {
assertThat(rdapJsonFormatter.createRdapDomain(domainBaseFull, OutputDataType.SUMMARY).toJson())
assertThat(rdapJsonFormatter.createRdapDomain(domainFull, OutputDataType.SUMMARY).toJson())
.isEqualTo(loadJson("rdapjson_domain_summary.json"));
}
@@ -487,7 +487,7 @@ class RdapJsonFormatterTest {
// Expected data are from "rdapjson_domain_summary.json"
assertThat(
Maps.transformValues(
rdapJsonFormatter.getLastHistoryEntryByType(domainBaseFull),
rdapJsonFormatter.getLastHistoryEntryByType(domainFull),
HistoryEntry::getModificationTime))
.containsExactlyEntriesIn(
ImmutableMap.of(TRANSFER, DateTime.parse("1999-12-01T00:00:00.000Z")));
@@ -496,7 +496,7 @@ class RdapJsonFormatterTest {
@Test
void testDomain_logged_out() {
rdapJsonFormatter.rdapAuthorization = RdapAuthorization.PUBLIC_AUTHORIZATION;
assertThat(rdapJsonFormatter.createRdapDomain(domainBaseFull, OutputDataType.FULL).toJson())
assertThat(rdapJsonFormatter.createRdapDomain(domainFull, OutputDataType.FULL).toJson())
.isEqualTo(loadJson("rdapjson_domain_logged_out.json"));
}
@@ -504,7 +504,7 @@ class RdapJsonFormatterTest {
void testDomain_noNameserversNoTransfersMultipleRoleContact() {
assertThat(
rdapJsonFormatter
.createRdapDomain(domainBaseNoNameserversNoTransfers, OutputDataType.FULL)
.createRdapDomain(domainNoNameserversNoTransfers, OutputDataType.FULL)
.toJson())
.isEqualTo(loadJson("rdapjson_domain_no_nameservers.json"));
}
@@ -25,7 +25,7 @@ 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.makeDomainBase;
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;
@@ -36,7 +36,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.model.registrar.Registrar;
import google.registry.rdap.RdapMetrics.EndpointType;
@@ -56,7 +56,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
super(RdapNameserverSearchAction.class);
}
private DomainBase domainCatLol;
private Domain domainCatLol;
private HostResource hostNs1CatLol;
private HostResource hostNs2CatLol;
@@ -130,7 +130,7 @@ class RdapNameserverSearchActionTest extends RdapSearchActionTestCase<RdapNamese
// create a domain so that we can use it as a test nameserver search string suffix
domainCatLol =
persistResource(
makeDomainBase(
makeDomain(
"cat.lol",
persistResource(
makeContactResource(
@@ -19,7 +19,6 @@ import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;
import static com.google.common.truth.Truth8.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistEppResource;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.END_OF_TIME;
@@ -39,8 +38,8 @@ import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -56,6 +55,7 @@ import google.registry.model.reporting.HistoryEntry;
import google.registry.model.transfer.DomainTransferData;
import google.registry.model.transfer.TransferStatus;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.util.Idn;
import google.registry.xjc.domain.XjcDomainStatusType;
@@ -76,12 +76,12 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
/**
* Unit tests for {@link DomainBaseToXjcConverter}.
* Unit tests for {@link DomainToXjcConverter}.
*
* <p>This tests the mapping between {@link DomainBase} and {@link XjcRdeDomain} as well as some
* <p>This tests the mapping between {@link Domain} and {@link XjcRdeDomain} as well as some
* exceptional conditions.
*/
public class DomainBaseToXjcConverterTest {
public class DomainToXjcConverterTest {
@RegisterExtension
public final AppEngineExtension appEngine = AppEngineExtension.builder().withCloudSql().build();
@@ -96,7 +96,7 @@ public class DomainBaseToXjcConverterTest {
@Test
void testConvertThick() {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL);
XjcRdeDomain bean = DomainToXjcConverter.convertDomain(makeDomain(clock), RdeMode.FULL);
assertThat(bean.getClID()).isEqualTo("TheRegistrar");
@@ -177,7 +177,7 @@ public class DomainBaseToXjcConverterTest {
@Test
void testConvertThin() {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN);
XjcRdeDomain bean = DomainToXjcConverter.convertDomain(makeDomain(clock), RdeMode.THIN);
assertThat(bean.getRegistrant()).isNull();
assertThat(bean.getContacts()).isEmpty();
assertThat(bean.getSecDNS()).isNull();
@@ -185,13 +185,13 @@ public class DomainBaseToXjcConverterTest {
@Test
void testMarshalThick() throws Exception {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.FULL);
XjcRdeDomain bean = DomainToXjcConverter.convertDomain(makeDomain(clock), RdeMode.FULL);
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
}
@Test
void testMarshalThin() throws Exception {
XjcRdeDomain bean = DomainBaseToXjcConverter.convertDomain(makeDomainBase(clock), RdeMode.THIN);
XjcRdeDomain bean = DomainToXjcConverter.convertDomain(makeDomain(clock), RdeMode.THIN);
wrapDeposit(bean).marshal(new ByteArrayOutputStream(), UTF_8);
}
@@ -212,10 +212,13 @@ public class DomainBaseToXjcConverterTest {
return deposit;
}
static DomainBase makeDomainBase(FakeClock clock) {
DomainBase domain =
static Domain makeDomain(FakeClock clock) {
Domain domain =
persistResource(
newDomainBase("example.xn--q9jyb4c").asBuilder().setRepoId("2-Q9JYB4C").build());
DatabaseHelper.newDomain("example.xn--q9jyb4c")
.asBuilder()
.setRepoId("2-Q9JYB4C")
.build());
DomainHistory domainHistory =
persistResource(
new DomainHistory.Builder()
@@ -16,17 +16,17 @@ package google.registry.rde;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.xjc.XjcXmlTransformer.marshalStrict;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.InetAddresses;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.xjc.host.XjcHostStatusType;
import google.registry.xjc.host.XjcHostStatusValueType;
import google.registry.xjc.rdehost.XjcRdeHost;
@@ -55,8 +55,8 @@ public class HostResourceToXjcConverterTest {
@Test
void testConvertSubordinateHost() {
DomainBase domain =
newDomainBase("love.foobar")
Domain domain =
DatabaseHelper.newDomain("love.foobar")
.asBuilder()
.setPersistedCurrentSponsorRegistrarId("LeisureDog")
.setLastTransferTime(DateTime.parse("2010-01-01T00:00:00Z"))
@@ -33,8 +33,8 @@ import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.domain.rgp.GracePeriodStatus;
@@ -56,9 +56,9 @@ import org.joda.time.DateTime;
/** Utility class for creating {@code EppResource} entities that'll successfully marshal. */
final class RdeFixtures {
static DomainBase makeDomainBase(FakeClock clock, String tld) {
DomainBase domain =
new DomainBase.Builder()
static Domain makeDomain(FakeClock clock, String tld) {
Domain domain =
new Domain.Builder()
.setDomainName("example." + tld)
.setRepoId(generateNewDomainRoid(tld))
.setRegistrant(
@@ -23,7 +23,7 @@ import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
@SuiteDisplayName("RDE tests suite")
@SelectClasses({
DomainBaseToXjcConverterTest.class,
DomainToXjcConverterTest.class,
GhostrydeGpgIntegrationTest.class,
GhostrydeTest.class,
HostResourceToXjcConverterTest.class,
@@ -22,7 +22,6 @@ import static google.registry.reporting.spec11.Spec11RegistrarThreatMatchesParse
import static google.registry.reporting.spec11.Spec11RegistrarThreatMatchesParserTest.sampleThreatMatches;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -35,10 +34,11 @@ import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.MediaType;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.reporting.spec11.soy.Spec11EmailSoyInfo;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.util.EmailMessage;
import google.registry.util.SendEmailService;
import java.util.LinkedHashSet;
@@ -101,8 +101,8 @@ class Spec11EmailUtilsTest {
private ArgumentCaptor<EmailMessage> contentCaptor;
private final LocalDate date = new LocalDate(2018, 7, 15);
private DomainBase aDomain;
private DomainBase bDomain;
private Domain aDomain;
private Domain bDomain;
@BeforeEach
void beforeEach() throws Exception {
@@ -408,9 +408,9 @@ class Spec11EmailUtilsTest {
assertThat(message).isEqualTo(expectedContentBuilder.build());
}
private static DomainBase persistDomainWithHost(String domainName, HostResource host) {
private static Domain persistDomainWithHost(String domainName, HostResource host) {
return persistResource(
newDomainBase(domainName)
DatabaseHelper.newDomain(domainName)
.asBuilder()
.setNameservers(ImmutableSet.of(host.createVKey()))
.build());
@@ -19,7 +19,7 @@ import static com.google.common.truth.Truth.assert_;
import google.registry.model.billing.BillingEventTest;
import google.registry.model.common.CursorTest;
import google.registry.model.contact.ContactResourceTest;
import google.registry.model.domain.DomainBaseSqlTest;
import google.registry.model.domain.DomainSqlTest;
import google.registry.model.domain.token.AllocationTokenTest;
import google.registry.model.history.ContactHistoryTest;
import google.registry.model.history.DomainHistoryTest;
@@ -84,7 +84,7 @@ import org.junit.runner.RunWith;
ContactHistoryTest.class,
ContactResourceTest.class,
CursorTest.class,
DomainBaseSqlTest.class,
DomainSqlTest.class,
DomainHistoryTest.class,
HostHistoryTest.class,
LockTest.class,
@@ -20,7 +20,6 @@ import static google.registry.model.domain.DesignatedContact.Type.TECH;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newContactResource;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistPremiumList;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -34,6 +33,7 @@ import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.ofy.Ofy;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectExtension;
import java.io.IOException;
@@ -123,7 +123,7 @@ public enum Fixture {
.build());
persistResource(
newDomainBase("love.xn--q9jyb4c", justine)
DatabaseHelper.newDomain("love.xn--q9jyb4c", justine)
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -137,7 +137,7 @@ public enum Fixture {
.build());
persistResource(
newDomainBase("moogle.example", justine)
DatabaseHelper.newDomain("moogle.example", justine)
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -78,8 +78,8 @@ import google.registry.model.contact.ContactHistory;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DesignatedContact.Type;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainAuthInfo;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.DomainContent;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
@@ -168,26 +168,24 @@ public class DatabaseHelper {
.build();
}
public static DomainBase newDomainBase(String domainName) {
public static Domain newDomain(String domainName) {
String repoId = generateNewDomainRoid(getTldFromDomainName(domainName));
return newDomainBase(domainName, repoId, persistActiveContact("contact1234"));
return newDomain(domainName, repoId, persistActiveContact("contact1234"));
}
public static DomainBase newDomainBase(String domainName, ContactResource contact) {
return newDomainBase(
domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact);
public static Domain newDomain(String domainName, ContactResource contact) {
return newDomain(domainName, generateNewDomainRoid(getTldFromDomainName(domainName)), contact);
}
public static DomainBase newDomainBase(String domainName, HostResource... hosts) {
public static Domain newDomain(String domainName, HostResource... hosts) {
ImmutableSet<VKey<HostResource>> hostKeys =
Arrays.stream(hosts).map(HostResource::createVKey).collect(toImmutableSet());
return newDomainBase(domainName).asBuilder().setNameservers(hostKeys).build();
return newDomain(domainName).asBuilder().setNameservers(hostKeys).build();
}
public static DomainBase newDomainBase(
String domainName, String repoId, ContactResource contact) {
public static Domain newDomain(String domainName, String repoId, ContactResource contact) {
VKey<ContactResource> contactKey = contact.createVKey();
return new DomainBase.Builder()
return new Domain.Builder()
.setRepoId(repoId)
.setDomainName(domainName)
.setCreationRegistrarId("TheRegistrar")
@@ -276,7 +274,7 @@ public class DatabaseHelper {
}
public static HostResource persistActiveSubordinateHost(
String hostName, DomainBase superordinateDomain) {
String hostName, Domain superordinateDomain) {
checkNotNull(superordinateDomain);
return persistResource(
newHostResource(hostName)
@@ -293,19 +291,19 @@ public class DatabaseHelper {
newHostResource(hostName).asBuilder().setDeletionTime(deletionTime).build());
}
public static DomainBase persistActiveDomain(String domainName) {
return persistResource(newDomainBase(domainName));
public static Domain persistActiveDomain(String domainName) {
return persistResource(newDomain(domainName));
}
public static DomainBase persistActiveDomain(String domainName, DateTime creationTime) {
public static Domain persistActiveDomain(String domainName, DateTime creationTime) {
return persistResource(
newDomainBase(domainName).asBuilder().setCreationTimeForTest(creationTime).build());
newDomain(domainName).asBuilder().setCreationTimeForTest(creationTime).build());
}
public static DomainBase persistActiveDomain(
public static Domain persistActiveDomain(
String domainName, DateTime creationTime, DateTime expirationTime) {
return persistResource(
newDomainBase(domainName)
newDomain(domainName)
.asBuilder()
.setCreationTimeForTest(creationTime)
.setRegistrationExpirationTime(expirationTime)
@@ -313,31 +311,33 @@ public class DatabaseHelper {
}
/** Persists a domain resource with the given domain name deleted at the specified time. */
public static DomainBase persistDeletedDomain(String domainName, DateTime deletionTime) {
return persistDomainAsDeleted(newDomainBase(domainName), deletionTime);
public static Domain persistDeletedDomain(String domainName, DateTime deletionTime) {
return persistDomainAsDeleted(newDomain(domainName), deletionTime);
}
/**
* Returns a persisted domain that is the passed-in domain modified to be deleted at the specified
* time.
*/
public static DomainBase persistDomainAsDeleted(DomainBase domain, DateTime deletionTime) {
public static Domain persistDomainAsDeleted(Domain domain, DateTime deletionTime) {
return persistResource(domain.asBuilder().setDeletionTime(deletionTime).build());
}
/** Persists a domain and enqueues a LORDN task of the appropriate type for it. */
public static DomainBase persistDomainAndEnqueueLordn(final DomainBase domain) {
final DomainBase persistedDomain = persistResource(domain);
// Calls {@link LordnTaskUtils#enqueueDomainBaseTask} wrapped in a transaction so that the
// transaction time is set correctly.
tm().transactNew(() -> LordnTaskUtils.enqueueDomainBaseTask(persistedDomain));
public static Domain persistDomainAndEnqueueLordn(final Domain domain) {
final Domain persistedDomain = persistResource(domain);
/**
* Calls {@link LordnTaskUtils#enqueueDomainTask} wrapped in a transaction so that the
* transaction time is set correctly.
*/
tm().transactNew(() -> LordnTaskUtils.enqueueDomainTask(persistedDomain));
maybeAdvanceClock();
return persistedDomain;
}
/** Persists a {@link Recurring} and {@link HistoryEntry} for a domain that already exists. */
public static DomainBase persistBillingRecurrenceForDomain(
DomainBase domain, RenewalPriceBehavior renewalPriceBehavior, @Nullable Money renewalPrice) {
public static Domain persistBillingRecurrenceForDomain(
Domain domain, RenewalPriceBehavior renewalPriceBehavior, @Nullable Money renewalPrice) {
DomainHistory historyEntry =
persistResource(
new DomainHistory.Builder()
@@ -465,7 +465,7 @@ public class DatabaseHelper {
/**
* Deletes "domain" and all history records, billing events, poll messages and subordinate hosts.
*/
public static void deleteTestDomain(DomainBase domain, DateTime now) {
public static void deleteTestDomain(Domain domain, DateTime now) {
Iterable<BillingEvent> billingEvents = getBillingEvents(domain);
Iterable<? extends HistoryEntry> historyEntries =
HistoryEntryDao.loadHistoryObjectsForResource(domain.createVKey());
@@ -547,7 +547,7 @@ public class DatabaseHelper {
}
public static BillingEvent.OneTime createBillingEventForTransfer(
DomainBase domain, DomainHistory historyEntry, DateTime costLookupTime, DateTime eventTime) {
Domain domain, DomainHistory historyEntry, DateTime costLookupTime, DateTime eventTime) {
return new BillingEvent.OneTime.Builder()
.setReason(Reason.TRANSFER)
.setTargetId(domain.getDomainName())
@@ -609,7 +609,7 @@ public class DatabaseHelper {
.build());
}
public static DomainBase persistDomainWithDependentResources(
public static Domain persistDomainWithDependentResources(
String label,
String tld,
ContactResource contact,
@@ -618,9 +618,9 @@ public class DatabaseHelper {
DateTime expirationTime) {
String domainName = String.format("%s.%s", label, tld);
String repoId = generateNewDomainRoid(tld);
DomainBase domain =
Domain domain =
persistResource(
new DomainBase.Builder()
new Domain.Builder()
.setRepoId(repoId)
.setDomainName(domainName)
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
@@ -675,8 +675,8 @@ public class DatabaseHelper {
.build());
}
public static DomainBase persistDomainWithPendingTransfer(
DomainBase domain,
public static Domain persistDomainWithPendingTransfer(
Domain domain,
DateTime requestTime,
DateTime expirationTime,
DateTime extendedRegistrationExpirationTime) {
@@ -1165,7 +1165,7 @@ public class DatabaseHelper {
return resource.getRepoId() != null
? HistoryEntry.Type.HOST_CREATE
: HistoryEntry.Type.HOST_UPDATE;
} else if (resource instanceof DomainBase) {
} else if (resource instanceof Domain) {
return resource.getRepoId() != null
? HistoryEntry.Type.DOMAIN_CREATE
: HistoryEntry.Type.DOMAIN_UPDATE;
@@ -16,6 +16,7 @@ package google.registry.testing;
import google.registry.model.AppEngineEnvironment;
import google.registry.model.annotations.DeleteAfterMigration;
import google.registry.model.domain.DomainSqlTest;
import org.junit.jupiter.api.extension.AfterEachCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -31,8 +32,8 @@ import org.junit.jupiter.api.extension.ExtensionContext;
* <p>When used together with {@code JpaIntegrationWithCoverageExtension} or @{@code
* TestPipelineExtension}, this extension must be registered first. For consistency's sake, it is
* recommended that the field for this extension be annotated with
* {@code @org.junit.jupiter.api.Order(value = 1)}. Please refer to {@link
* google.registry.model.domain.DomainBaseSqlTest} for example, and to <a
* {@code @org.junit.jupiter.api.Order(value = 1)}. Please refer to {@link DomainSqlTest} for
* example, and to <a
* href="https://junit.org/junit5/docs/current/user-guide/#extensions-registration-programmatic">
* JUnit 5 User Guide</a> for details of extension ordering.
*
@@ -22,7 +22,7 @@ import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
import com.google.common.collect.ImmutableSet;
import com.google.common.truth.FailureMetadata;
import com.google.common.truth.SimpleSubjectBuilder;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.AuthInfo;
@@ -30,90 +30,89 @@ import google.registry.testing.TruthChainer.And;
import java.util.Set;
import org.joda.time.DateTime;
/** Truth subject for asserting things about {@link DomainBase} instances. */
public final class DomainBaseSubject
extends AbstractEppResourceSubject<DomainBase, DomainBaseSubject> {
/** Truth subject for asserting things about {@link Domain} instances. */
public final class DomainSubject extends AbstractEppResourceSubject<Domain, DomainSubject> {
private final DomainBase actual;
private final Domain actual;
public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) {
public DomainSubject(FailureMetadata failureMetadata, Domain subject) {
super(failureMetadata, checkNotNull(subject));
this.actual = subject;
}
public And<DomainBaseSubject> hasFullyQualifiedDomainName(String fullyQualifiedDomainName) {
public And<DomainSubject> hasFullyQualifiedDomainName(String fullyQualifiedDomainName) {
return hasValue(
fullyQualifiedDomainName, actual.getDomainName(), "has fullyQualifiedDomainName");
}
public And<DomainBaseSubject> hasExactlyDsData(DelegationSignerData... dsData) {
public And<DomainSubject> hasExactlyDsData(DelegationSignerData... dsData) {
return hasExactlyDsData(ImmutableSet.copyOf(dsData));
}
public And<DomainBaseSubject> hasExactlyDsData(Set<DelegationSignerData> dsData) {
public And<DomainSubject> hasExactlyDsData(Set<DelegationSignerData> dsData) {
return hasValue(dsData, actual.getDsData(), "has dsData");
}
public And<DomainBaseSubject> hasNumDsData(int num) {
public And<DomainSubject> hasNumDsData(int num) {
return hasValue(num, actual.getDsData().size(), "has num dsData");
}
public And<DomainBaseSubject> hasLaunchNotice(LaunchNotice launchNotice) {
public And<DomainSubject> hasLaunchNotice(LaunchNotice launchNotice) {
return hasValue(launchNotice, actual.getLaunchNotice(), "has launchNotice");
}
public And<DomainBaseSubject> hasAuthInfoPwd(String pw) {
public And<DomainSubject> hasAuthInfoPwd(String pw) {
AuthInfo authInfo = actual.getAuthInfo();
return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw");
}
public And<DomainBaseSubject> hasCurrentSponsorRegistrarId(String registrarId) {
public And<DomainSubject> hasCurrentSponsorRegistrarId(String registrarId) {
return hasValue(
registrarId, actual.getCurrentSponsorRegistrarId(), "has currentSponsorRegistrarId");
}
public And<DomainBaseSubject> hasRegistrationExpirationTime(DateTime expiration) {
public And<DomainSubject> hasRegistrationExpirationTime(DateTime expiration) {
return hasValue(
expiration, actual.getRegistrationExpirationTime(), "getRegistrationExpirationTime()");
}
public And<DomainBaseSubject> hasLastTransferTime(DateTime lastTransferTime) {
public And<DomainSubject> hasLastTransferTime(DateTime lastTransferTime) {
return hasValue(lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
}
public And<DomainBaseSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
public And<DomainSubject> hasLastTransferTimeNotEqualTo(DateTime lastTransferTime) {
return doesNotHaveValue(
lastTransferTime, actual.getLastTransferTime(), "getLastTransferTime()");
}
public And<DomainBaseSubject> hasDeletePollMessage() {
public And<DomainSubject> hasDeletePollMessage() {
if (actual.getDeletePollMessage() == null) {
failWithActual(simpleFact("expected to have a delete poll message"));
}
return andChainer();
}
public And<DomainBaseSubject> hasNoDeletePollMessage() {
public And<DomainSubject> hasNoDeletePollMessage() {
if (actual.getDeletePollMessage() != null) {
failWithActual(simpleFact("expected to have no delete poll message"));
}
return andChainer();
}
public And<DomainBaseSubject> hasSmdId(String smdId) {
public And<DomainSubject> hasSmdId(String smdId) {
return hasValue(smdId, actual.getSmdId(), "getSmdId()");
}
public And<DomainBaseSubject> hasAutorenewEndTime(DateTime autorenewEndTime) {
public And<DomainSubject> hasAutorenewEndTime(DateTime autorenewEndTime) {
checkArgumentNotNull(autorenewEndTime, "Use hasNoAutorenewEndTime() instead");
return hasValue(autorenewEndTime, actual.getAutorenewEndTime(), "getAutorenewEndTime()");
}
public And<DomainBaseSubject> hasNoAutorenewEndTime() {
public And<DomainSubject> hasNoAutorenewEndTime() {
return hasNoValue(actual.getAutorenewEndTime(), "getAutorenewEndTime()");
}
public static SimpleSubjectBuilder<DomainBaseSubject, DomainBase> assertAboutDomains() {
return assertAbout(DomainBaseSubject::new);
public static SimpleSubjectBuilder<DomainSubject, Domain> assertAboutDomains() {
return assertAbout(DomainSubject::new);
}
}
@@ -29,7 +29,7 @@ import google.registry.model.contact.ContactPhoneNumber;
import google.registry.model.contact.ContactResource;
import google.registry.model.contact.PostalInfo;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.StatusValue;
@@ -330,7 +330,7 @@ public final class FullFieldsTestEntityHelper {
return contactResource;
}
public static DomainBase makeDomainBase(
public static Domain makeDomain(
String domain,
@Nullable ContactResource registrant,
@Nullable ContactResource admin,
@@ -338,8 +338,8 @@ public final class FullFieldsTestEntityHelper {
@Nullable HostResource ns1,
@Nullable HostResource ns2,
Registrar registrar) {
DomainBase.Builder builder =
new DomainBase.Builder()
Domain.Builder builder =
new Domain.Builder()
.setDomainName(Idn.toASCII(domain))
.setRepoId(generateNewDomainRoid(getTldFromDomainName(Idn.toASCII(domain))))
.setLastEppUpdateTime(DateTime.parse("2009-05-29T20:13:00Z"))
@@ -19,7 +19,7 @@ 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.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.host.HostResource;
import google.registry.persistence.VKey;
import google.registry.testing.TruthChainer.And;
@@ -57,7 +57,7 @@ public final class HostResourceSubject
}
public And<HostResourceSubject> hasSuperordinateDomain(
@Nullable VKey<DomainBase> superordinateDomain) {
@Nullable VKey<Domain> superordinateDomain) {
return hasValue(
superordinateDomain, actual.getSuperordinateDomain(), "has superordinateDomain");
}
@@ -22,7 +22,7 @@ import static google.registry.testing.DatabaseHelper.persistDomainAndEnqueueLord
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
import static org.junit.jupiter.api.Assertions.assertThrows;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.ofy.Ofy;
import google.registry.model.registrar.Registrar.Type;
@@ -53,8 +53,8 @@ public class LordnTaskUtilsTest {
inject.setStaticField(Ofy.class, "clock", clock);
}
private DomainBase.Builder newDomainBuilder() {
return new DomainBase.Builder()
private Domain.Builder newDomainBuilder() {
return new Domain.Builder()
.setDomainName("fleece.example")
.setPersistedCurrentSponsorRegistrarId("TheRegistrar")
.setCreationRegistrarId("TheRegistrar")
@@ -64,7 +64,7 @@ public class LordnTaskUtilsTest {
}
@Test
void test_enqueueDomainBaseTask_sunrise() {
void test_enqueueDomainTask_sunrise() {
persistDomainAndEnqueueLordn(newDomainBuilder().setRepoId("A-EXAMPLE").build());
String expectedPayload =
"A-EXAMPLE,fleece.example,smdzzzz,1,2010-05-01T10:11:12.000Z";
@@ -73,8 +73,8 @@ public class LordnTaskUtilsTest {
}
@Test
void test_enqueueDomainBaseTask_claims() {
DomainBase domain =
void test_enqueueDomainTask_claims() {
Domain domain =
newDomainBuilder()
.setRepoId("11-EXAMPLE")
.setLaunchNotice(
@@ -104,9 +104,9 @@ public class LordnTaskUtilsTest {
}
@Test
void test_enqueueDomainBaseTask_throwsNpeOnNullDomain() {
void test_enqueueDomainTask_throwsNpeOnNullDomain() {
assertThrows(
NullPointerException.class,
() -> tm().transactNew(() -> LordnTaskUtils.enqueueDomainBaseTask(null)));
() -> tm().transactNew(() -> LordnTaskUtils.enqueueDomainTask(null)));
}
}
@@ -21,7 +21,6 @@ import static com.google.common.net.MediaType.FORM_DATA;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistDomainAndEnqueueLordn;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
@@ -47,11 +46,12 @@ import com.google.appengine.api.taskqueue.TransientFailureException;
import com.google.apphosting.api.DeadlineExceededException;
import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.model.ofy.Ofy;
import google.registry.model.tld.Registry;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.FakeSleeper;
import google.registry.testing.FakeUrlConnectionService;
@@ -289,7 +289,7 @@ class NordnUploadActionTest {
}
private void persistClaimsModeDomain() {
DomainBase domain = newDomainBase("claims-landrush1.tld");
Domain domain = DatabaseHelper.newDomain("claims-landrush1.tld");
persistDomainAndEnqueueLordn(
domain
.asBuilder()
@@ -301,7 +301,7 @@ class NordnUploadActionTest {
private void persistSunriseModeDomain() {
action.phase = "sunrise";
DomainBase domain = newDomainBase("sunrise1.tld");
Domain domain = DatabaseHelper.newDomain("sunrise1.tld");
persistDomainAndEnqueueLordn(domain.asBuilder().setSmdId("my-smdid").build());
}
@@ -19,11 +19,10 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.loadByKeys;
import static google.registry.testing.DatabaseHelper.loadByKeysIfPresent;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistResource;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.DomainHistory.DomainHistoryId;
import google.registry.model.ofy.Ofy;
@@ -32,6 +31,7 @@ import google.registry.model.poll.PollMessage.Autorenew;
import google.registry.model.poll.PollMessage.OneTime;
import google.registry.model.reporting.HistoryEntry;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import google.registry.testing.InjectExtension;
import org.joda.time.DateTime;
@@ -53,7 +53,8 @@ public class AckPollMessagesCommandTest extends CommandTestCase<AckPollMessagesC
inject.setStaticField(Ofy.class, "clock", clock);
command.clock = clock;
createTld("tld");
DomainBase domain = newDomainBase("example.tld").asBuilder().setRepoId("FSDGS-TLD").build();
Domain domain =
DatabaseHelper.newDomain("example.tld").asBuilder().setRepoId("FSDGS-TLD").build();
persistResource(domain);
domainHistory =
persistResource(
@@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.domain.token.AllocationToken.TokenType;
import google.registry.model.reporting.HistoryEntry;
@@ -173,7 +173,7 @@ class DeleteAllocationTokensCommandTest extends CommandTestCase<DeleteAllocation
.setDomainName(domainName);
if (redeemed) {
String domainToPersist = domainName != null ? domainName : "example.foo";
DomainBase domain = persistActiveDomain(domainToPersist);
Domain domain = persistActiveDomain(domainToPersist);
Key<HistoryEntry> historyEntryKey = Key.create(Key.create(domain), HistoryEntry.class, 1051L);
builder.setRedemptionHistoryEntry(HistoryEntry.createVKey(historyEntryKey));
}
@@ -22,7 +22,6 @@ import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.getHistoryEntriesOfType;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.loadByEntity;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.SqlHelper.getRegistryLockByRevisionId;
@@ -38,7 +37,7 @@ import com.google.common.collect.ImmutableList;
import google.registry.batch.RelockDomainAction;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.RegistryLock;
import google.registry.model.host.HostResource;
@@ -83,13 +82,13 @@ public final class DomainLockUtilsTest {
.withUserService(UserInfo.create(POC_ID, "12345"))
.build();
private DomainBase domain;
private Domain domain;
@BeforeEach
void setup() {
createTlds("tld", "net");
HostResource host = persistActiveHost("ns1.example.net");
domain = persistResource(newDomainBase(DOMAIN_NAME, host));
domain = persistResource(DatabaseHelper.newDomain(DOMAIN_NAME, host));
domainLockUtils =
new DomainLockUtils(
@@ -25,7 +25,7 @@ import static google.registry.testing.HistoryEntrySubject.assertAboutHistoryEntr
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.ofy.Ofy;
import google.registry.model.poll.PollMessage;
import google.registry.model.reporting.HistoryEntry;
@@ -39,7 +39,7 @@ class EnqueuePollMessageCommandTest extends CommandTestCase<EnqueuePollMessageCo
@RegisterExtension final InjectExtension inject = new InjectExtension();
private DomainBase domain;
private Domain domain;
@BeforeEach
void beforeEach() {
@@ -25,7 +25,7 @@ import com.google.common.collect.ImmutableMap;
import google.registry.flows.EppTestCase;
import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.reporting.HistoryEntry.Type;
import google.registry.testing.AppEngineExtension;
@@ -137,10 +137,8 @@ class EppLifecycleToolsTest extends EppTestCase {
// Assert about billing events.
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
DomainBase domain =
loadByForeignKey(
DomainBase.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z"))
.get();
Domain domain =
loadByForeignKey(Domain.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z")).get();
BillingEvent.OneTime renewBillingEvent =
new BillingEvent.OneTime.Builder()
.setReason(Reason.RENEW)
@@ -17,7 +17,6 @@ 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.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
@@ -32,10 +31,11 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.net.InetAddresses;
import google.registry.model.domain.DomainBase;
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.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.io.IOException;
import java.io.Reader;
@@ -65,7 +65,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
private HostResource nameserver2;
private HostResource nameserver3;
private HostResource nameserver4;
private DomainBase domain1;
private Domain domain1;
private static final ImmutableList<?> DS_DATA_OUTPUT = ImmutableList.of(
ImmutableMap.of(
@@ -139,7 +139,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
nameserver4 = persistActiveHost("ns2.google.com");
domain1 =
persistResource(
newDomainBase("example.xn--q9jyb4c")
DatabaseHelper.newDomain("example.xn--q9jyb4c")
.asBuilder()
.setNameservers(ImmutableSet.of(nameserver1.createVKey(), nameserver2.createVKey()))
.setDsData(
@@ -150,7 +150,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
56789, 2, 4, base16().decode("69FD46E6C4A45C55D4AC"))))
.build());
persistResource(
newDomainBase("foobar.xn--q9jyb4c")
DatabaseHelper.newDomain("foobar.xn--q9jyb4c")
.asBuilder()
.setNameservers(ImmutableSet.of(nameserver3.createVKey(), nameserver4.createVKey()))
.build());
@@ -16,12 +16,12 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.nio.charset.StandardCharsets.UTF_8;
import google.registry.model.domain.launch.LaunchNotice;
import google.registry.testing.DatabaseHelper;
import java.nio.file.Files;
import java.nio.file.Path;
import org.joda.time.DateTime;
@@ -42,10 +42,10 @@ class GenerateLordnCommandTest extends CommandTestCase<GenerateLordnCommand> {
@Test
void testExample() throws Exception {
createTld("tld");
persistResource(newDomainBase("sneezy.tld").asBuilder().setSmdId("smd1").build());
persistResource(newDomainBase("wheezy.tld").asBuilder().setSmdId("smd2").build());
persistResource(DatabaseHelper.newDomain("sneezy.tld").asBuilder().setSmdId("smd1").build());
persistResource(DatabaseHelper.newDomain("wheezy.tld").asBuilder().setSmdId("smd2").build());
persistResource(
newDomainBase("fleecey.tld")
DatabaseHelper.newDomain("fleecey.tld")
.asBuilder()
.setLaunchNotice(LaunchNotice.create("smd3", "validator", START_OF_TIME, START_OF_TIME))
.setSmdId("smd3")
@@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableList;
import com.googlecode.objectify.Key;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.token.AllocationToken;
import google.registry.model.reporting.HistoryEntry;
import org.joda.time.DateTime;
@@ -76,8 +76,7 @@ class GetAllocationTokenCommandTest extends CommandTestCase<GetAllocationTokenCo
@Test
void testSuccess_redeemedToken() throws Exception {
createTld("tld");
DomainBase domain =
persistActiveDomain("fqqdn.tld", DateTime.parse("2016-04-07T22:19:17.044Z"));
Domain domain = persistActiveDomain("fqqdn.tld", DateTime.parse("2016-04-07T22:19:17.044Z"));
AllocationToken token =
persistResource(
new AllocationToken.Builder()
@@ -15,13 +15,13 @@
package google.registry.tools;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import google.registry.testing.DatabaseHelper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -41,9 +41,9 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
assertInStdout("Contact=VKey<ContactResource>(sql:3-ROID");
assertInStdout(
"Websafe key: "
+ "kind:DomainBase"
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
}
@Test
@@ -54,9 +54,9 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
assertInStdout("sqlKey=3-ROID");
assertInStdout(
"Websafe key: "
+ "kind:DomainBase"
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw");
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
assertNotInStdout("LiveRef");
}
@@ -78,20 +78,20 @@ class GetDomainCommandTest extends CommandTestCase<GetDomainCommand> {
assertInStdout("fullyQualifiedDomainName=example2.tld");
assertInStdout(
"Websafe key: "
+ "kind:DomainBase"
+ "@sql:rO0ABXQABTQtVExE"
+ "@ofy:agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
+ "kind:Domain"
+ "@sql:rO0ABXQABTItVExE"
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTItVExEDA");
assertInStdout(
"Websafe key: "
+ "kind:DomainBase"
+ "kind:Domain"
+ "@sql:rO0ABXQABTQtVExE"
+ "@ofy:agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw");
+ "@ofy:agR0ZXN0chELEgZEb21haW4iBTQtVExEDA");
}
@Test
void testSuccess_domainDeletedInFuture() throws Exception {
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setDeletionTime(fakeClock.nowUtc().plusDays(1))
.build());
@@ -19,7 +19,7 @@ import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistResource;
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.Period;
import google.registry.model.reporting.HistoryEntry;
import google.registry.testing.FakeClock;
@@ -32,7 +32,7 @@ class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesComm
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
private DomainBase domain;
private Domain domain;
@BeforeEach
void beforeEach() {
@@ -17,7 +17,6 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.eppcommon.StatusValue.SERVER_TRANSFER_PROHIBITED;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -26,9 +25,10 @@ import static google.registry.tools.LockOrUnlockDomainCommand.REGISTRY_LOCK_STAT
import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.registrar.Registrar.Type;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.DeterministicStringGenerator;
import google.registry.util.StringGenerator.Alphabets;
import java.util.ArrayList;
@@ -54,7 +54,7 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
@Test
void testSuccess_locksDomain() throws Exception {
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
runCommandForced("--client=TheRegistrar", "example.tld");
assertThat(reloadResource(domain).getStatusValues())
.containsAtLeastElementsIn(REGISTRY_LOCK_STATUSES);
@@ -62,9 +62,9 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
@Test
void testSuccess_partiallyUpdatesStatuses() throws Exception {
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.addStatusValue(SERVER_TRANSFER_PROHIBITED)
.build());
@@ -77,7 +77,7 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
void testSuccess_manyDomains() throws Exception {
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
// case that was going to be the failure point).
List<DomainBase> domains = new ArrayList<>();
List<Domain> domains = new ArrayList<>();
for (int n = 0; n < 26; n++) {
String domain = String.format("domain%d.tld", n);
domains.add(persistActiveDomain(domain));
@@ -85,9 +85,9 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
runCommandForced(
ImmutableList.<String>builder()
.add("--client=TheRegistrar")
.addAll(domains.stream().map(DomainBase::getDomainName).collect(Collectors.toList()))
.addAll(domains.stream().map(Domain::getDomainName).collect(Collectors.toList()))
.build());
for (DomainBase domain : domains) {
for (Domain domain : domains) {
assertThat(reloadResource(domain).getStatusValues())
.containsAtLeastElementsIn(REGISTRY_LOCK_STATUSES);
}
@@ -101,9 +101,9 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
@Test
void testSuccess_alreadyLockedDomain_performsNoAction() throws Exception {
DomainBase domain =
Domain domain =
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.addStatusValues(REGISTRY_LOCK_STATUSES)
.build());
@@ -113,7 +113,7 @@ class LockDomainCommandTest extends CommandTestCase<LockDomainCommand> {
@Test
void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
runCommandForced("example.tld");
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
.isEqualTo("adminreg");
@@ -15,7 +15,6 @@
package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
@@ -24,8 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableMap;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.registrar.Registrar;
import google.registry.testing.DatabaseHelper;
import java.util.List;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -60,8 +60,8 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
.verifyNoMoreSent();
}
private static List<DomainBase> persistThreeDomains() {
ImmutableList.Builder<DomainBase> domains = new ImmutableList.Builder<>();
private static List<Domain> persistThreeDomains() {
ImmutableList.Builder<Domain> domains = new ImmutableList.Builder<>();
domains.add(
persistActiveDomain(
"domain1.tld",
@@ -75,7 +75,7 @@ public class RenewDomainCommandTest extends EppToolCommandTestCase<RenewDomainCo
// The third domain is owned by a different registrar.
domains.add(
persistResource(
newDomainBase("domain3.tld")
DatabaseHelper.newDomain("domain3.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2015-01-05T05:05:05Z"))
.setRegistrationExpirationTime(DateTime.parse("2016-01-05T05:05:05Z"))
@@ -16,7 +16,6 @@ package google.registry.tools;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.loadRegistrar;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -25,11 +24,12 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.beust.jcommander.ParameterException;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.DomainBase;
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.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -43,7 +43,7 @@ class UniformRapidSuspensionCommandTest
private HostResource ns2;
private HostResource urs1;
private HostResource urs2;
private DomainBase defaultDomainBase;
private Domain defaultDomain;
private ImmutableSet<DelegationSignerData> defaultDsData;
@BeforeEach
@@ -55,7 +55,7 @@ class UniformRapidSuspensionCommandTest
ns2 = persistActiveHost("ns2.example.com");
urs1 = persistActiveHost("urs1.example.com");
urs2 = persistActiveHost("urs2.example.com");
defaultDomainBase = newDomainBase("evil.tld");
defaultDomain = DatabaseHelper.newDomain("evil.tld");
defaultDsData =
ImmutableSet.of(
DelegationSignerData.create(1, 2, 3, new HexBinaryAdapter().unmarshal("dead")),
@@ -63,18 +63,17 @@ class UniformRapidSuspensionCommandTest
}
private void persistDomainWithHosts(
DomainBase domainBase, ImmutableSet<DelegationSignerData> dsData, HostResource... hosts) {
Domain domain, ImmutableSet<DelegationSignerData> dsData, HostResource... hosts) {
ImmutableSet.Builder<VKey<HostResource>> hostRefs = new ImmutableSet.Builder<>();
for (HostResource host : hosts) {
hostRefs.add(host.createVKey());
}
persistResource(
domainBase.asBuilder().setNameservers(hostRefs.build()).setDsData(dsData).build());
persistResource(domain.asBuilder().setNameservers(hostRefs.build()).setDsData(dsData).build());
}
@Test
void testCommand_addsLocksReplacesHostsAndDsDataPrintsUndo() throws Exception {
persistDomainWithHosts(defaultDomainBase, defaultDsData, ns1, ns2);
persistDomainWithHosts(defaultDomain, defaultDsData, ns1, ns2);
runCommandForced(
"--domain_name=evil.tld",
"--hosts=urs1.example.com,urs2.example.com",
@@ -95,7 +94,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testCommand_respectsExistingHost() throws Exception {
persistDomainWithHosts(defaultDomainBase, defaultDsData, urs2, ns1);
persistDomainWithHosts(defaultDomain, defaultDsData, urs2, ns1);
runCommandForced(
"--domain_name=evil.tld",
"--hosts=urs1.example.com,urs2.example.com",
@@ -127,9 +126,10 @@ class UniformRapidSuspensionCommandTest
@Test
void testCommand_generatesUndoWithLocksToPreserve() throws Exception {
persistResource(
newDomainBase("evil.tld").asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
runCommandForced("--domain_name=evil.tld", "--renew_one_year=false");
eppVerifier.verifySentAny().verifyNoMoreSent();
assertInStdout("uniform_rapid_suspension --undo");
@@ -140,7 +140,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testCommand_removeClientHold() throws Exception {
persistResource(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.addStatusValue(StatusValue.CLIENT_HOLD)
.addNameserver(ns1.createVKey())
@@ -164,7 +164,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testUndo_removesLocksReplacesHostsAndDsData() throws Exception {
persistDomainWithHosts(defaultDomainBase, defaultDsData, urs1, urs2);
persistDomainWithHosts(defaultDomain, defaultDsData, urs1, urs2);
runCommandForced(
"--domain_name=evil.tld",
"--undo",
@@ -180,7 +180,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testUndo_respectsLocksToPreserveFlag() throws Exception {
persistDomainWithHosts(defaultDomainBase, defaultDsData, urs1, urs2);
persistDomainWithHosts(defaultDomain, defaultDsData, urs1, urs2);
runCommandForced(
"--domain_name=evil.tld",
"--undo",
@@ -197,7 +197,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testUndo_restoresClientHolds() throws Exception {
persistDomainWithHosts(defaultDomainBase, defaultDsData, urs1, urs2);
persistDomainWithHosts(defaultDomain, defaultDsData, urs1, urs2);
runCommandForced(
"--domain_name=evil.tld",
"--undo",
@@ -215,7 +215,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testAutorenews_setToFalseByDefault() throws Exception {
persistResource(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
@@ -227,7 +227,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testAutorenews_setToTrueWhenUndo() throws Exception {
persistResource(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.addStatusValue(StatusValue.SERVER_DELETE_PROHIBITED)
.build());
@@ -244,7 +244,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testRenewOneYearWithoutUndo_verifyReasonWithoutUndo() throws Exception {
persistDomainWithHosts(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
@@ -281,7 +281,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testRenewOneYearWithUndo_verifyReasonWithUndo() throws Exception {
persistDomainWithHosts(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
@@ -319,7 +319,7 @@ class UniformRapidSuspensionCommandTest
@Test
void testRenewOneYear_verifyBothRenewAndUpdateFlowsAreTriggered() throws Exception {
persistDomainWithHosts(
newDomainBase("evil.tld")
DatabaseHelper.newDomain("evil.tld")
.asBuilder()
.setCreationTimeForTest(DateTime.parse("2021-10-01T05:01:11Z"))
.setRegistrationExpirationTime(DateTime.parse("2022-10-01T05:01:11Z"))
@@ -18,7 +18,6 @@ import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.eppcommon.StatusValue.SERVER_DELETE_PROHIBITED;
import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBITED;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistNewRegistrar;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -28,10 +27,11 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.RegistryLock;
import google.registry.model.registrar.Registrar.Type;
import google.registry.testing.CloudTasksHelper;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.DeterministicStringGenerator;
import google.registry.util.StringGenerator.Alphabets;
import java.util.ArrayList;
@@ -55,8 +55,8 @@ class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
new CloudTasksHelper(fakeClock).getTestCloudTasksUtils());
}
private DomainBase persistLockedDomain(String domainName, String registrarId) {
DomainBase domain = persistResource(newDomainBase(domainName));
private Domain persistLockedDomain(String domainName, String registrarId) {
Domain domain = persistResource(DatabaseHelper.newDomain(domainName));
RegistryLock lock =
command.domainLockUtils.saveNewRegistryLockRequest(domainName, registrarId, null, true);
command.domainLockUtils.verifyAndApplyLock(lock.getVerificationCode(), true);
@@ -65,14 +65,14 @@ class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
@Test
void testSuccess_unlocksDomain() throws Exception {
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
Domain domain = persistLockedDomain("example.tld", "TheRegistrar");
runCommandForced("--client=TheRegistrar", "example.tld");
assertThat(reloadResource(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
}
@Test
void testSuccess_partiallyUpdatesStatuses() throws Exception {
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
Domain domain = persistLockedDomain("example.tld", "TheRegistrar");
domain =
persistResource(
domain
@@ -88,7 +88,7 @@ class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
void testSuccess_manyDomains() throws Exception {
// Create 26 domains -- one more than the number of entity groups allowed in a transaction (in
// case that was going to be the failure point).
List<DomainBase> domains = new ArrayList<>();
List<Domain> domains = new ArrayList<>();
for (int n = 0; n < 26; n++) {
String domain = String.format("domain%d.tld", n);
domains.add(persistLockedDomain(domain, "TheRegistrar"));
@@ -96,9 +96,9 @@ class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
runCommandForced(
ImmutableList.<String>builder()
.add("--client=TheRegistrar")
.addAll(domains.stream().map(DomainBase::getDomainName).collect(Collectors.toList()))
.addAll(domains.stream().map(Domain::getDomainName).collect(Collectors.toList()))
.build());
for (DomainBase domain : domains) {
for (Domain domain : domains) {
assertThat(reloadResource(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
}
}
@@ -111,14 +111,14 @@ class UnlockDomainCommandTest extends CommandTestCase<UnlockDomainCommand> {
@Test
void testSuccess_alreadyUnlockedDomain_staysUnlocked() throws Exception {
DomainBase domain = persistActiveDomain("example.tld");
Domain domain = persistActiveDomain("example.tld");
runCommandForced("--client=TheRegistrar", "example.tld");
assertThat(reloadResource(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
}
@Test
void testSuccess_defaultsToAdminRegistrar_ifUnspecified() throws Exception {
DomainBase domain = persistLockedDomain("example.tld", "TheRegistrar");
Domain domain = persistLockedDomain("example.tld", "TheRegistrar");
runCommandForced("example.tld");
assertThat(getMostRecentRegistryLockByRepoId(domain.getRepoId()).get().getRegistrarId())
.isEqualTo("adminreg");
@@ -25,7 +25,6 @@ import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.getOnlyHistoryEntryOfType;
import static google.registry.testing.DatabaseHelper.getPollMessages;
import static google.registry.testing.DatabaseHelper.loadByKey;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistDeletedDomain;
@@ -39,11 +38,12 @@ import google.registry.model.billing.BillingEvent;
import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.ofy.Ofy;
import google.registry.model.poll.PollMessage;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.InjectExtension;
import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@@ -86,12 +86,12 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
runCommandForced("-p", "2", "foo.tld", "bar.tld");
fakeClock.disableAutoIncrement();
assertThat(
loadByForeignKey(DomainBase.class, "foo.tld", fakeClock.nowUtc())
loadByForeignKey(Domain.class, "foo.tld", fakeClock.nowUtc())
.get()
.getRegistrationExpirationTime())
.isEqualTo(DateTime.parse("2019-12-06T13:55:01.001Z"));
assertThat(
loadByForeignKey(DomainBase.class, "bar.tld", fakeClock.nowUtc())
loadByForeignKey(Domain.class, "bar.tld", fakeClock.nowUtc())
.get()
.getRegistrationExpirationTime())
.isEqualTo(DateTime.parse("2018-12-06T13:55:01.002Z"));
@@ -114,7 +114,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
runCommandForced("-p", "2", "foo.tld");
DateTime unrenewTime = fakeClock.nowUtc();
fakeClock.advanceOneMilli();
DomainBase domain = loadByForeignKey(DomainBase.class, "foo.tld", fakeClock.nowUtc()).get();
Domain domain = loadByForeignKey(Domain.class, "foo.tld", fakeClock.nowUtc()).get();
assertAboutHistoryEntries()
.that(getOnlyHistoryEntryOfType(domain, SYNTHETIC))
@@ -187,19 +187,19 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
void test_varietyOfInvalidDomains_displaysErrors() {
DateTime now = fakeClock.nowUtc();
persistResource(
newDomainBase("deleting.tld")
DatabaseHelper.newDomain("deleting.tld")
.asBuilder()
.setDeletionTime(now.plusHours(1))
.setStatusValues(ImmutableSet.of(PENDING_DELETE))
.build());
persistDeletedDomain("deleted.tld", now.minusHours(1));
persistResource(
newDomainBase("transferring.tld")
DatabaseHelper.newDomain("transferring.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(PENDING_TRANSFER))
.build());
persistResource(
newDomainBase("locked.tld")
DatabaseHelper.newDomain("locked.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_UPDATE_PROHIBITED))
.build());
@@ -21,7 +21,6 @@ import static google.registry.model.eppcommon.StatusValue.SERVER_UPDATE_PROHIBIT
import static google.registry.model.reporting.HistoryEntry.Type.DOMAIN_CREATE;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newContactResource;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
import static google.registry.testing.DatabaseHelper.persistActiveHost;
import static google.registry.testing.DatabaseHelper.persistResource;
@@ -38,13 +37,14 @@ import google.registry.model.billing.BillingEvent.Flag;
import google.registry.model.billing.BillingEvent.Reason;
import google.registry.model.contact.ContactResource;
import google.registry.model.domain.DesignatedContact;
import google.registry.model.domain.DomainBase;
import google.registry.model.domain.Domain;
import google.registry.model.domain.DomainHistory;
import google.registry.model.domain.GracePeriod;
import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.model.ofy.Ofy;
import google.registry.persistence.VKey;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.InjectExtension;
import google.registry.util.CapturingLogHandler;
import google.registry.util.JdkLoggerConfig;
@@ -59,7 +59,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
private final CapturingLogHandler logHandler = new CapturingLogHandler();
private DomainBase domain;
private Domain domain;
@RegisterExtension public final InjectExtension inject = new InjectExtension();
@@ -162,12 +162,12 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
HostResource host1 = persistActiveHost("foo.bar.tld");
HostResource host2 = persistActiveHost("baz.bar.tld");
persistResource(
newDomainBase("example.abc")
DatabaseHelper.newDomain("example.abc")
.asBuilder()
.setNameservers(ImmutableSet.of(host1.createVKey()))
.build());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setNameservers(ImmutableSet.of(host2.createVKey()))
.build());
@@ -236,7 +236,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
ImmutableSet<VKey<HostResource>> nameservers =
ImmutableSet.of(host1.createVKey(), host2.createVKey());
persistResource(
newDomainBase("example.tld").asBuilder().setNameservers(nameservers).build());
DatabaseHelper.newDomain("example.tld").asBuilder().setNameservers(nameservers).build());
runCommandForced(
"--client=NewRegistrar", "--nameservers=ns2.zdns.google,ns3.zdns.google", "example.tld");
eppVerifier.verifySent("domain_update_set_nameservers.xml");
@@ -250,7 +250,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
VKey<ContactResource> techContactKey = techContact.createVKey();
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -268,7 +268,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setStatusValues(
ImmutableSet.of(
@@ -377,7 +377,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
VKey<ContactResource> techContactKey = techContact.createVKey();
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setContacts(
ImmutableSet.of(
@@ -401,7 +401,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(SERVER_UPDATE_PROHIBITED))
.setNameservers(nameservers)
@@ -426,7 +426,7 @@ class UpdateDomainCommandTest extends EppToolCommandTestCase<UpdateDomainCommand
HostResource host = persistActiveHost("ns1.zdns.google");
ImmutableSet<VKey<HostResource>> nameservers = ImmutableSet.of(host.createVKey());
persistResource(
newDomainBase("example.tld")
DatabaseHelper.newDomain("example.tld")
.asBuilder()
.setStatusValues(ImmutableSet.of(PENDING_DELETE))
.setNameservers(nameservers)
@@ -16,7 +16,6 @@ package google.registry.tools.server;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.testing.DatabaseHelper.createTlds;
import static google.registry.testing.DatabaseHelper.newDomainBase;
import static google.registry.testing.DatabaseHelper.newHostResource;
import static google.registry.testing.DatabaseHelper.persistActiveContact;
import static google.registry.testing.DatabaseHelper.persistActiveDomain;
@@ -38,6 +37,7 @@ import google.registry.model.eppcommon.StatusValue;
import google.registry.model.host.HostResource;
import google.registry.persistence.VKey;
import google.registry.testing.AppEngineExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.net.InetAddress;
import java.util.Map;
@@ -73,47 +73,58 @@ class GenerateZoneFilesActionTest {
// This domain will have glue records, because it has a subordinate host which is its own
// nameserver. None of the other domains should have glue records, because their nameservers are
// subordinate to different domains.
persistResource(newDomainBase("bar.tld").asBuilder()
.addNameservers(nameservers)
.addSubordinateHost("ns.bar.tld")
.build());
persistResource(newDomainBase("foo.tld").asBuilder()
.addSubordinateHost("ns.foo.tld")
.build());
persistResource(newDomainBase("ns-and-ds.tld").asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistResource(newDomainBase("ns-only.tld").asBuilder()
.addNameservers(nameservers)
.build());
persistResource(newDomainBase("ns-only-client-hold.tld").asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
.build());
persistResource(newDomainBase("ns-only-pending-delete.tld").asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
persistResource(newDomainBase("ns-only-server-hold.tld").asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_HOLD))
.build());
persistResource(
DatabaseHelper.newDomain("bar.tld")
.asBuilder()
.addNameservers(nameservers)
.addSubordinateHost("ns.bar.tld")
.build());
persistResource(
DatabaseHelper.newDomain("foo.tld").asBuilder().addSubordinateHost("ns.foo.tld").build());
persistResource(
DatabaseHelper.newDomain("ns-and-ds.tld")
.asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistResource(
DatabaseHelper.newDomain("ns-only.tld").asBuilder().addNameservers(nameservers).build());
persistResource(
DatabaseHelper.newDomain("ns-only-client-hold.tld")
.asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.CLIENT_HOLD))
.build());
persistResource(
DatabaseHelper.newDomain("ns-only-pending-delete.tld")
.asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
.build());
persistResource(
DatabaseHelper.newDomain("ns-only-server-hold.tld")
.asBuilder()
.addNameservers(nameservers)
.setStatusValues(ImmutableSet.of(StatusValue.SERVER_HOLD))
.build());
// These should be ignored; contacts aren't in DNS, hosts need to be from the same tld and have
// IP addresses, and domains need to be from the same TLD and have hosts (even in the case where
// domains contain DS data).
persistResource(newDomainBase("ds-only.tld").asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistResource(
DatabaseHelper.newDomain("ds-only.tld")
.asBuilder()
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistActiveContact("ignored_contact");
persistActiveHost("ignored.host.tld"); // No ips.
persistActiveDomain("ignored_domain.tld"); // No hosts or DS data.
persistResource(newHostResource("ignored.foo.com").asBuilder().addInetAddresses(ips).build());
persistResource(newDomainBase("ignored.com")
.asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
persistResource(
DatabaseHelper.newDomain("ignored.com")
.asBuilder()
.addNameservers(nameservers)
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
.build());
GenerateZoneFilesAction action = new GenerateZoneFilesAction();
action.bucket = "zonefiles-bucket";

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