mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 17:01:51 +02:00
Make loadByForeignKey() and related methods return Optional
This is safer and addresses a common source of confusion in the codebase because it's always explicit that the resource returned may not be present, whether because it's soft-deleted when projected to the given time or because it never existed in the first place. In production code, the presence of the returned value is always checked. In test code, its presence is assumed using .get() where that is expected and convenient, as it not being present will throw an NPE that will cause the test to fail anyway. Note that the roughly equivalent reloadResourceByForeignKey(), which is widely used in test code, is not having this same treatment applied to it. That is out of the scope of this CL, and has much smaller returns anyway because it's only used in tests (where the unexpected absence of a given resource would just cause the test to fail). ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=225424002
This commit is contained in:
parent
b573ec4969
commit
4491b7b909
52 changed files with 374 additions and 290 deletions
|
@ -193,14 +193,14 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
ContactResource contactUpdated =
|
||||
loadByForeignKey(ContactResource.class, "blah8221", clock.nowUtc());
|
||||
loadByForeignKey(ContactResource.class, "blah8221", clock.nowUtc()).get();
|
||||
assertAboutContacts()
|
||||
.that(contactUpdated)
|
||||
.doesNotHaveStatusValue(PENDING_DELETE)
|
||||
.and()
|
||||
.hasDeletionTime(END_OF_TIME);
|
||||
DomainResource domainReloaded =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc());
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get();
|
||||
assertThat(domainReloaded.getReferencedContacts()).contains(Key.create(contactUpdated));
|
||||
HistoryEntry historyEntry =
|
||||
getOnlyHistoryEntryOfType(contactUpdated, HistoryEntry.Type.CONTACT_DELETE_FAILURE);
|
||||
|
@ -268,7 +268,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create(clientTrid.orElse(null), "fakeServerTrid"),
|
||||
false);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "jim919", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "jim919", clock.nowUtc())).isEmpty();
|
||||
ContactResource contactAfterDeletion = ofy().load().entity(contact).now();
|
||||
assertAboutContacts()
|
||||
.that(contactAfterDeletion)
|
||||
|
@ -332,10 +332,10 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
// Check that the contact is deleted as of now.
|
||||
assertThat(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())).isEmpty();
|
||||
// Check that it's still there (it wasn't deleted yesterday) and that it has history.
|
||||
ContactResource softDeletedContact =
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutContacts()
|
||||
.that(softDeletedContact)
|
||||
.hasOneHistoryEntryEachOfTypes(CONTACT_TRANSFER_REQUEST, CONTACT_DELETE);
|
||||
|
@ -393,9 +393,9 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||
false);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "blah1234", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "blah1234", clock.nowUtc())).isEmpty();
|
||||
ContactResource contactBeforeDeletion =
|
||||
loadByForeignKey(ContactResource.class, "blah1234", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(ContactResource.class, "blah1234", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutContacts()
|
||||
.that(contactBeforeDeletion)
|
||||
.isNotActiveAt(clock.nowUtc())
|
||||
|
@ -428,7 +428,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
ContactResource contactAfter =
|
||||
loadByForeignKey(ContactResource.class, "jane0991", clock.nowUtc());
|
||||
loadByForeignKey(ContactResource.class, "jane0991", clock.nowUtc()).get();
|
||||
assertAboutContacts()
|
||||
.that(contactAfter)
|
||||
.doesNotHaveStatusValue(PENDING_DELETE)
|
||||
|
@ -455,7 +455,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||
true);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "nate007", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "nate007", clock.nowUtc())).isEmpty();
|
||||
ContactResource contactAfterDeletion = ofy().load().entity(contact).now();
|
||||
assertAboutContacts()
|
||||
.that(contactAfterDeletion)
|
||||
|
@ -561,9 +561,9 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
enqueueMapreduceOnly();
|
||||
assertThat(loadByForeignKey(ContactResource.class, "blah2222", clock.nowUtc()))
|
||||
.isEqualTo(contact);
|
||||
.hasValue(contact);
|
||||
assertThat(loadByForeignKey(HostResource.class, "rustles.your.jimmies", clock.nowUtc()))
|
||||
.isEqualTo(host);
|
||||
.hasValue(host);
|
||||
assertNoTasksEnqueued(QUEUE_ASYNC_DELETE);
|
||||
verify(action.asyncFlowMetrics).recordContactHostDeletionBatchSize(2L);
|
||||
verify(action.asyncFlowMetrics)
|
||||
|
@ -610,13 +610,14 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
HostResource hostAfter =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
|
||||
assertAboutHosts()
|
||||
.that(hostAfter)
|
||||
.doesNotHaveStatusValue(PENDING_DELETE)
|
||||
.and()
|
||||
.hasDeletionTime(END_OF_TIME);
|
||||
DomainResource domain = loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc());
|
||||
DomainResource domain =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get();
|
||||
assertThat(domain.getNameservers()).contains(Key.create(hostAfter));
|
||||
HistoryEntry historyEntry = getOnlyHistoryEntryOfType(hostAfter, HOST_DELETE_FAILURE);
|
||||
assertPollMessageFor(
|
||||
|
@ -653,9 +654,9 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create(clientTrid.orElse(null), "fakeServerTrid"),
|
||||
false);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isEmpty();
|
||||
HostResource hostBeforeDeletion =
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutHosts()
|
||||
.that(hostBeforeDeletion)
|
||||
.isNotActiveAt(clock.nowUtc())
|
||||
|
@ -697,9 +698,9 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||
false);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())).isEmpty();
|
||||
HostResource hostBeforeDeletion =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutHosts()
|
||||
.that(hostBeforeDeletion)
|
||||
.isNotActiveAt(clock.nowUtc())
|
||||
|
@ -743,15 +744,16 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
// Check that the host is deleted as of now.
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc())).isEmpty();
|
||||
assertNoBillingEvents();
|
||||
assertThat(
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc())
|
||||
.get()
|
||||
.getSubordinateHosts())
|
||||
.isEmpty();
|
||||
assertDnsTasksEnqueued("ns2.example.tld");
|
||||
HostResource hostBeforeDeletion =
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutHosts()
|
||||
.that(hostBeforeDeletion)
|
||||
.isNotActiveAt(clock.nowUtc())
|
||||
|
@ -782,7 +784,7 @@ public class DeleteContactsAndHostsActionTest
|
|||
false);
|
||||
runMapreduce();
|
||||
HostResource hostAfter =
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
|
||||
assertAboutHosts()
|
||||
.that(hostAfter)
|
||||
.doesNotHaveStatusValue(PENDING_DELETE)
|
||||
|
@ -809,9 +811,9 @@ public class DeleteContactsAndHostsActionTest
|
|||
Trid.create("fakeClientTrid", "fakeServerTrid"),
|
||||
true);
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns66.example.tld", clock.nowUtc())).isNull();
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns66.example.tld", clock.nowUtc())).isEmpty();
|
||||
HostResource hostBeforeDeletion =
|
||||
loadByForeignKey(HostResource.class, "ns66.example.tld", clock.nowUtc().minusDays(1));
|
||||
loadByForeignKey(HostResource.class, "ns66.example.tld", clock.nowUtc().minusDays(1)).get();
|
||||
assertAboutHosts()
|
||||
.that(hostBeforeDeletion)
|
||||
.isNotActiveAt(clock.nowUtc())
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.batch;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -46,6 +47,7 @@ import google.registry.model.registry.Registry.TldType;
|
|||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.testing.FakeResponse;
|
||||
import google.registry.testing.mapreduce.MapreduceTestCase;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -190,7 +192,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
runMapreduce();
|
||||
DateTime timeAfterDeletion = DateTime.now(UTC);
|
||||
assertThat(loadByForeignKey(DomainResource.class, "blah.ib-any.test", timeAfterDeletion))
|
||||
.isNull();
|
||||
.isEmpty();
|
||||
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
|
||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||
}
|
||||
|
@ -207,7 +209,7 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
resetAction();
|
||||
runMapreduce();
|
||||
assertThat(loadByForeignKey(DomainResource.class, "blah.ib-any.test", timeAfterDeletion))
|
||||
.isNull();
|
||||
.isEmpty();
|
||||
assertThat(ofy().load().entity(domain).now().getDeletionTime()).isLessThan(timeAfterDeletion);
|
||||
assertDnsTasksEnqueued("blah.ib-any.test");
|
||||
}
|
||||
|
@ -220,10 +222,10 @@ public class DeleteProberDataActionTest extends MapreduceTestCase<DeleteProberDa
|
|||
.setCreationTimeForTest(DateTime.now(UTC).minusSeconds(1))
|
||||
.build());
|
||||
runMapreduce();
|
||||
DomainResource domain =
|
||||
Optional<DomainResource> domain =
|
||||
loadByForeignKey(DomainResource.class, "blah.ib-any.test", DateTime.now(UTC));
|
||||
assertThat(domain).isNotNull();
|
||||
assertThat(domain.getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||
assertThat(domain).isPresent();
|
||||
assertThat(domain.get().getDeletionTime()).isEqualTo(END_OF_TIME);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -250,7 +250,7 @@ public class DnsUpdateWriterTest {
|
|||
newDomainResource("example.tld")
|
||||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.addNameserver(Key.create(host))
|
||||
.build());
|
||||
|
||||
writer.publishHost("ns1.example.tld");
|
||||
|
@ -358,7 +358,7 @@ public class DnsUpdateWriterTest {
|
|||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("foo.example.tld")
|
||||
.addNameservers(ImmutableSet.of(Key.create(inBailiwickNameserver)))
|
||||
.addNameserver(Key.create(inBailiwickNameserver))
|
||||
.build());
|
||||
|
||||
writer.publishDomain("example.tld");
|
||||
|
|
|
@ -107,7 +107,7 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
"EXDATE", "2002-06-01T00:02:00.0Z"));
|
||||
|
||||
DomainResource domain =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", createTime.plusHours(1));
|
||||
loadByForeignKey(DomainResource.class, "example.tld", createTime.plusHours(1)).get();
|
||||
|
||||
// Delete domain example.tld within the add grace period.
|
||||
DateTime deleteTime = createTime.plusDays(1);
|
||||
|
@ -184,7 +184,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
|
||||
DomainResource domain =
|
||||
loadByForeignKey(
|
||||
DomainResource.class, "example.tld", DateTime.parse("2000-08-01T00:02:00Z"));
|
||||
DomainResource.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,
|
||||
|
@ -218,7 +219,8 @@ public class EppLifecycleDomainTest extends EppTestCase {
|
|||
|
||||
DomainResource domain =
|
||||
loadByForeignKey(
|
||||
DomainResource.class, "example.tld", DateTime.parse("2000-06-01T00:03:00Z"));
|
||||
DomainResource.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);
|
||||
|
|
|
@ -218,9 +218,9 @@ public class EppLifecycleHostTest extends EppTestCase {
|
|||
DateTime timeAfterCreates = DateTime.parse("2000-06-01T00:06:00Z");
|
||||
|
||||
HostResource exampleBarFooTldHost =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates);
|
||||
loadByForeignKey(HostResource.class, "ns1.example.bar.foo.tld", timeAfterCreates).get();
|
||||
DomainResource exampleBarFooTldDomain =
|
||||
loadByForeignKey(DomainResource.class, "example.bar.foo.tld", timeAfterCreates);
|
||||
loadByForeignKey(DomainResource.class, "example.bar.foo.tld", timeAfterCreates).get();
|
||||
assertAboutHosts()
|
||||
.that(exampleBarFooTldHost)
|
||||
.hasSuperordinateDomain(Key.create(exampleBarFooTldDomain));
|
||||
|
@ -228,18 +228,18 @@ public class EppLifecycleHostTest extends EppTestCase {
|
|||
.containsExactly("ns1.example.bar.foo.tld");
|
||||
|
||||
HostResource exampleFooTldHost =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates);
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo.tld", timeAfterCreates).get();
|
||||
DomainResource exampleFooTldDomain =
|
||||
loadByForeignKey(DomainResource.class, "example.foo.tld", timeAfterCreates);
|
||||
loadByForeignKey(DomainResource.class, "example.foo.tld", timeAfterCreates).get();
|
||||
assertAboutHosts()
|
||||
.that(exampleFooTldHost)
|
||||
.hasSuperordinateDomain(Key.create(exampleFooTldDomain));
|
||||
assertThat(exampleFooTldDomain.getSubordinateHosts()).containsExactly("ns1.example.foo.tld");
|
||||
|
||||
HostResource exampleTldHost =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates);
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", timeAfterCreates).get();
|
||||
DomainResource exampleTldDomain =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", timeAfterCreates);
|
||||
loadByForeignKey(DomainResource.class, "example.tld", timeAfterCreates).get();
|
||||
assertAboutHosts().that(exampleTldHost).hasSuperordinateDomain(Key.create(exampleTldDomain));
|
||||
assertThat(exampleTldDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.flows;
|
|||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.EppResourceUtils.loadDomainApplication;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.tmch.ClaimsListShardTest.createTestClaimsListShard;
|
||||
import static google.registry.testing.EppExceptionSubject.assertAboutEppExceptions;
|
||||
|
@ -32,7 +33,6 @@ import com.google.common.testing.TestLogHandler;
|
|||
import com.googlecode.objectify.Key;
|
||||
import google.registry.flows.FlowUtils.NotLoggedInException;
|
||||
import google.registry.model.EppResource;
|
||||
import google.registry.model.EppResourceUtils;
|
||||
import google.registry.model.domain.DomainApplication;
|
||||
import google.registry.model.domain.launch.ApplicationIdTargetExtension;
|
||||
import google.registry.model.eppcommon.Trid;
|
||||
|
@ -46,6 +46,7 @@ import google.registry.testing.TaskQueueHelper.TaskMatcher;
|
|||
import google.registry.util.TypeUtils.TypeInstantiator;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import javax.annotation.Nullable;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
import org.json.simple.JSONValue;
|
||||
|
@ -71,20 +72,22 @@ public abstract class ResourceFlowTestCase<F extends Flow, R extends EppResource
|
|||
LoggerConfig.getConfig("").addHandler(logHandler);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected R reloadResourceByForeignKey(DateTime now) throws Exception {
|
||||
// Force the session to be cleared so that when we read it back, we read from Datastore and not
|
||||
// from the transaction's session cache.
|
||||
ofy().clearSessionCache();
|
||||
return loadByForeignKey(getResourceClass(), getUniqueIdFromCommand(), now);
|
||||
return loadByForeignKey(getResourceClass(), getUniqueIdFromCommand(), now).orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected R reloadResourceByForeignKey() throws Exception {
|
||||
return reloadResourceByForeignKey(clock.nowUtc());
|
||||
}
|
||||
|
||||
protected DomainApplication reloadDomainApplication() throws Exception {
|
||||
ofy().clearSessionCache();
|
||||
return EppResourceUtils.loadDomainApplication(getUniqueIdFromCommand(), clock.nowUtc());
|
||||
return loadDomainApplication(getUniqueIdFromCommand(), clock.nowUtc()).get();
|
||||
}
|
||||
|
||||
protected <T extends EppResource> T reloadResourceAndCloneAtTime(T resource, DateTime now) {
|
||||
|
|
|
@ -150,7 +150,7 @@ public class DomainAllocateFlowTest
|
|||
boolean sunrushAddGracePeriod = (nameservers == 0);
|
||||
|
||||
// The application should be marked as allocated, with a new history entry.
|
||||
DomainApplication application = loadDomainApplication(applicationId, clock.nowUtc());
|
||||
DomainApplication application = loadDomainApplication(applicationId, clock.nowUtc()).get();
|
||||
assertAboutApplications().that(application)
|
||||
.hasApplicationStatus(ApplicationStatus.ALLOCATED).and()
|
||||
.hasHistoryEntryAtIndex(0)
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
package google.registry.flows.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.isLinked;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.EppResourceUtils.loadDomainApplication;
|
||||
import static google.registry.model.index.ForeignKeyIndex.loadAndGetKey;
|
||||
import static google.registry.testing.DatastoreHelper.assertNoBillingEvents;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -72,7 +74,7 @@ public class DomainApplicationDeleteFlowTest
|
|||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
// Check that the domain is fully deleted.
|
||||
assertThat(reloadDomainApplication()).isNull();
|
||||
assertThat(loadDomainApplication(getUniqueIdFromCommand(), clock.nowUtc())).isEmpty();
|
||||
assertNoBillingEvents();
|
||||
}
|
||||
|
||||
|
@ -93,11 +95,10 @@ public class DomainApplicationDeleteFlowTest
|
|||
.asBuilder()
|
||||
.setRepoId("1-TLD")
|
||||
.setRegistrant(
|
||||
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get()))
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()))))
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.net", clock.nowUtc()).get()))
|
||||
.build());
|
||||
doSuccessfulTest();
|
||||
for (Key<? extends EppResource> key :
|
||||
|
|
|
@ -112,16 +112,15 @@ public class DomainApplicationUpdateFlowTest
|
|||
}
|
||||
|
||||
private DomainApplication persistApplication() {
|
||||
HostResource host =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
|
||||
return persistResource(
|
||||
newApplicationBuilder()
|
||||
.setContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(Type.TECH, Key.create(sh8013Contact)),
|
||||
DesignatedContact.create(Type.ADMIN, Key.create(unusedContact))))
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
public void testSuccess_registrantMovedToTechContact() throws Exception {
|
||||
setEppInput("domain_update_sunrise_registrant_to_tech.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ContactResource sh8013 =
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
|
||||
persistResource(newApplicationBuilder().setRegistrant(Key.create(sh8013)).build());
|
||||
clock.advanceOneMilli();
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
|
@ -194,7 +194,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
public void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
|
||||
setEppInput("domain_update_sunrise_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ContactResource sh8013 =
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(
|
||||
newApplicationBuilder()
|
||||
|
@ -411,7 +412,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
nameservers.add(
|
||||
Key.create(
|
||||
loadByForeignKey(
|
||||
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())));
|
||||
HostResource.class, String.format("ns%d.example.tld", i), clock.nowUtc())
|
||||
.get()));
|
||||
}
|
||||
}
|
||||
persistResource(
|
||||
|
@ -546,7 +548,7 @@ public class DomainApplicationUpdateFlowTest
|
|||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc())))))
|
||||
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()).get()))))
|
||||
.build());
|
||||
EppException thrown = assertThrows(DuplicateContactForRoleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -639,7 +641,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
|
||||
.get())))
|
||||
.build());
|
||||
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -656,7 +659,8 @@ public class DomainApplicationUpdateFlowTest
|
|||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())
|
||||
.get()))))
|
||||
.build());
|
||||
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -759,10 +763,9 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistResource(
|
||||
reloadDomainApplication()
|
||||
.asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()))))
|
||||
.addNameserver(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get()))
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -833,10 +836,9 @@ public class DomainApplicationUpdateFlowTest
|
|||
persistResource(
|
||||
reloadDomainApplication()
|
||||
.asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()))))
|
||||
.addNameserver(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get()))
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
|
|
@ -692,6 +692,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
HostResource host = persistResource(newHostResource("ns1.example.tld"));
|
||||
persistResource(
|
||||
loadByForeignKey(DomainResource.class, getUniqueIdFromCommand(), clock.nowUtc())
|
||||
.get()
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.build());
|
||||
|
@ -700,7 +701,7 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
newDomainResource("example1.tld")
|
||||
.asBuilder()
|
||||
.setRegistrant(
|
||||
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))
|
||||
Key.create(loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get()))
|
||||
.setNameservers(ImmutableSet.of(Key.create(host)))
|
||||
.setDeletionTime(START_OF_TIME)
|
||||
.build());
|
||||
|
|
|
@ -124,7 +124,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
}
|
||||
|
||||
private DomainResource persistDomain() throws Exception {
|
||||
HostResource host = loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc());
|
||||
HostResource host =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get();
|
||||
DomainResource domain =
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand())
|
||||
|
@ -227,7 +228,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
getOnlyHistoryEntryOfType(resource, HistoryEntry.Type.DOMAIN_UPDATE);
|
||||
assertThat(resource.getNameservers())
|
||||
.containsExactly(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()));
|
||||
BillingEvent.OneTime regularAddBillingEvent =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.CREATE)
|
||||
|
@ -283,7 +285,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(null)
|
||||
.setNameservers(ImmutableSet.of())
|
||||
.addGracePeriod(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
.build());
|
||||
|
@ -308,7 +310,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(null)
|
||||
.setNameservers(ImmutableSet.of())
|
||||
.addGracePeriod(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
.build());
|
||||
|
@ -329,9 +331,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()))
|
||||
.addGracePeriod(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
.addStatusValue(StatusValue.SERVER_HOLD)
|
||||
|
@ -356,9 +357,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()))
|
||||
.addGracePeriod(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
.addStatusValue(StatusValue.CLIENT_HOLD)
|
||||
|
@ -383,7 +383,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setNameservers(null)
|
||||
.setNameservers(ImmutableSet.of())
|
||||
.addGracePeriod(
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, sunrushAddBillingEvent))
|
||||
.addStatusValue(StatusValue.SERVER_HOLD)
|
||||
|
@ -407,7 +407,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
nameservers.add(
|
||||
Key.create(
|
||||
loadByForeignKey(
|
||||
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())));
|
||||
HostResource.class, String.format("ns%d.example.foo", i), clock.nowUtc())
|
||||
.get()));
|
||||
}
|
||||
}
|
||||
persistResource(
|
||||
|
@ -523,8 +524,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(
|
||||
HostResource.class, "ns1.example.tld", clock.nowUtc()))))
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
|
||||
.get())))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
|
@ -532,8 +533,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
domain = reloadResourceByForeignKey();
|
||||
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
|
||||
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
||||
existingHost = loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc());
|
||||
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
existingHost = loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
|
||||
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
}
|
||||
|
@ -542,7 +543,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
public void testSuccess_registrantMovedToTechContact() throws Exception {
|
||||
setEppInput("domain_update_registrant_to_tech.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ContactResource sh8013 =
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand())
|
||||
.asBuilder()
|
||||
|
@ -556,7 +558,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
public void testSuccess_multipleReferencesToSameContactRemoved() throws Exception {
|
||||
setEppInput("domain_update_remove_multiple_contacts.xml");
|
||||
persistReferencedEntities();
|
||||
ContactResource sh8013 = loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc());
|
||||
ContactResource sh8013 =
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get();
|
||||
Key<ContactResource> sh8013Key = Key.create(sh8013);
|
||||
persistResource(
|
||||
newDomainResource(getUniqueIdFromCommand())
|
||||
|
@ -936,11 +939,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.setContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc())))))
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "foo", clock.nowUtc()).get())))
|
||||
.build());
|
||||
EppException thrown = assertThrows(DuplicateContactForRoleException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -1114,7 +1116,8 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()))))
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())
|
||||
.get())))
|
||||
.build());
|
||||
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -1128,11 +1131,10 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
newDomainResource(getUniqueIdFromCommand())
|
||||
.asBuilder()
|
||||
.setContacts(
|
||||
ImmutableSet.of(
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc())))))
|
||||
DesignatedContact.create(
|
||||
Type.TECH,
|
||||
Key.create(
|
||||
loadByForeignKey(ContactResource.class, "sh8013", clock.nowUtc()).get())))
|
||||
.build());
|
||||
EppException thrown = assertThrows(AddRemoveSameValueException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
|
@ -1179,6 +1181,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistActiveContact("sh8013");
|
||||
persistResource(
|
||||
loadByForeignKey(ContactResource.class, "mak21", clock.nowUtc())
|
||||
.get()
|
||||
.asBuilder()
|
||||
.addStatusValue(StatusValue.PENDING_DELETE)
|
||||
.build());
|
||||
|
@ -1197,6 +1200,7 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistActiveContact("sh8013");
|
||||
persistResource(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())
|
||||
.get()
|
||||
.asBuilder()
|
||||
.addStatusValue(StatusValue.PENDING_DELETE)
|
||||
.build());
|
||||
|
@ -1249,11 +1253,13 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.build());
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.doesNotContain(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()));
|
||||
runFlow();
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.contains(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1294,10 +1300,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addNameserver(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()))
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -1307,12 +1312,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.build());
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.contains(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
|
||||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.doesNotContain(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1387,10 +1394,9 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
persistResource(
|
||||
reloadResourceByForeignKey()
|
||||
.asBuilder()
|
||||
.addNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()))))
|
||||
.addNameserver(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns2.example.foo", clock.nowUtc()).get()))
|
||||
.build());
|
||||
persistResource(
|
||||
Registry.get("tld")
|
||||
|
@ -1401,12 +1407,14 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
.build());
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.contains(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
|
||||
clock.advanceOneMilli();
|
||||
runFlow();
|
||||
assertThat(reloadResourceByForeignKey().getNameservers())
|
||||
.doesNotContain(
|
||||
Key.create(loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc())));
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.foo", clock.nowUtc()).get()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -116,7 +116,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
|||
doSuccessfulInternalTest("tld");
|
||||
HostResource host = reloadResourceByForeignKey();
|
||||
DomainResource superordinateDomain =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc());
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get();
|
||||
assertAboutHosts().that(host).hasSuperordinateDomain(Key.create(superordinateDomain));
|
||||
assertThat(superordinateDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
|
@ -145,7 +145,7 @@ public class HostCreateFlowTest extends ResourceFlowTestCase<HostCreateFlow, Hos
|
|||
doSuccessfulInternalTest("tld");
|
||||
HostResource host = reloadResourceByForeignKey();
|
||||
DomainResource superordinateDomain =
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc());
|
||||
loadByForeignKey(DomainResource.class, "example.tld", clock.nowUtc()).get();
|
||||
assertAboutHosts().that(host).hasSuperordinateDomain(Key.create(superordinateDomain));
|
||||
assertThat(superordinateDomain.getSubordinateHosts()).containsExactly("ns1.example.tld");
|
||||
assertDnsTasksEnqueued("ns1.example.tld");
|
||||
|
|
|
@ -92,7 +92,7 @@ public class HostInfoFlowTest extends ResourceFlowTestCase<HostInfoFlow, HostRes
|
|||
persistResource(
|
||||
newDomainResource("example.foobar")
|
||||
.asBuilder()
|
||||
.addNameservers(ImmutableSet.of(Key.create(persistHostResource())))
|
||||
.addNameserver(Key.create(persistHostResource()))
|
||||
.build());
|
||||
assertTransactionalFlow(false);
|
||||
// Check that the persisted host info was returned.
|
||||
|
|
|
@ -159,7 +159,7 @@ public class HostUpdateFlowTest extends ResourceFlowTestCase<HostUpdateFlow, Hos
|
|||
assertThat(reloadResourceByForeignKey()).isNull();
|
||||
// However, it should load correctly if we use the new name (taken from the xml).
|
||||
HostResource renamedHost =
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc());
|
||||
loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
|
||||
assertAboutHosts()
|
||||
.that(renamedHost)
|
||||
.hasOnlyOneHistoryEntryWhich()
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package google.registry.model;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveContact;
|
||||
import static google.registry.testing.DatastoreHelper.persistActiveHost;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
|
@ -40,9 +42,8 @@ public class EppResourceTest extends EntityTestCase {
|
|||
persistResource(originalContact.asBuilder().setEmailAddress("different@fake.lol").build());
|
||||
assertThat(EppResource.loadCached(ImmutableList.of(Key.create(originalContact))))
|
||||
.containsExactly(Key.create(originalContact), originalContact);
|
||||
assertThat(
|
||||
EppResourceUtils.loadByForeignKey(ContactResource.class, "contact123", clock.nowUtc()))
|
||||
.isEqualTo(modifiedContact);
|
||||
assertThat(loadByForeignKey(ContactResource.class, "contact123", clock.nowUtc()))
|
||||
.hasValue(modifiedContact);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -56,10 +57,8 @@ public class EppResourceTest extends EntityTestCase {
|
|||
originalHost.asBuilder().setLastTransferTime(clock.nowUtc().minusDays(60)).build());
|
||||
assertThat(EppResource.loadCached(ImmutableList.of(Key.create(originalHost))))
|
||||
.containsExactly(Key.create(originalHost), originalHost);
|
||||
assertThat(
|
||||
EppResourceUtils.loadByForeignKey(
|
||||
HostResource.class, "ns1.example.com", clock.nowUtc()))
|
||||
.isEqualTo(modifiedHost);
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns1.example.com", clock.nowUtc()))
|
||||
.hasValue(modifiedHost);
|
||||
}
|
||||
|
||||
private static void setNonZeroCachingInterval() {
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.contact;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.testing.ContactResourceSubject.assertAboutContacts;
|
||||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
|
@ -112,7 +113,7 @@ public class ContactResourceTest extends EntityTestCase {
|
|||
public void testPersistence() {
|
||||
assertThat(
|
||||
loadByForeignKey(ContactResource.class, contactResource.getForeignKey(), clock.nowUtc()))
|
||||
.isEqualTo(contactResource);
|
||||
.hasValue(contactResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadDomainApplication;
|
||||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -88,7 +89,7 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
@Test
|
||||
public void testPersistence() {
|
||||
assertThat(loadDomainApplication(domainApplication.getForeignKey(), clock.nowUtc()))
|
||||
.isEqualTo(domainApplication);
|
||||
.hasValue(domainApplication);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -121,7 +122,6 @@ public class DomainApplicationTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testEmptySetsAndArraysBecomeNull() {
|
||||
assertThat(emptyBuilder().setNameservers(null).build().nsHosts).isNull();
|
||||
assertThat(emptyBuilder().setNameservers(ImmutableSet.of()).build().nsHosts).isNull();
|
||||
assertThat(
|
||||
emptyBuilder()
|
||||
|
|
|
@ -17,6 +17,7 @@ package google.registry.model.domain;
|
|||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -151,7 +152,7 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
@Test
|
||||
public void testPersistence() {
|
||||
assertThat(loadByForeignKey(DomainResource.class, domain.getForeignKey(), clock.nowUtc()))
|
||||
.isEqualTo(domain);
|
||||
.hasValue(domain);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -187,7 +188,12 @@ public class DomainResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testEmptySetsAndArraysBecomeNull() {
|
||||
assertThat(newDomainResource("example.com").asBuilder().setNameservers(null).build().nsHosts)
|
||||
assertThat(
|
||||
newDomainResource("example.com")
|
||||
.asBuilder()
|
||||
.setNameservers(ImmutableSet.of())
|
||||
.build()
|
||||
.nsHosts)
|
||||
.isNull();
|
||||
assertThat(
|
||||
newDomainResource("example.com")
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
package google.registry.model.host;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.testing.DatastoreHelper.cloneAndSetAutoTimestamps;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
|
@ -86,9 +87,8 @@ public class HostResourceTest extends EntityTestCase {
|
|||
|
||||
@Test
|
||||
public void testPersistence() {
|
||||
assertThat(loadByForeignKey(
|
||||
HostResource.class, host.getForeignKey(), clock.nowUtc()))
|
||||
.isEqualTo(host);
|
||||
assertThat(loadByForeignKey(HostResource.class, host.getForeignKey(), clock.nowUtc()))
|
||||
.hasValue(host);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
package google.registry.model.index;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.testing.DatastoreHelper.createTld;
|
||||
import static google.registry.testing.DatastoreHelper.deleteResource;
|
||||
|
@ -29,7 +31,6 @@ import com.google.common.cache.CacheBuilder;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.googlecode.objectify.Key;
|
||||
import google.registry.model.EntityTestCase;
|
||||
import google.registry.model.EppResourceUtils;
|
||||
import google.registry.model.contact.ContactResource;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
|
||||
|
@ -180,10 +181,8 @@ public class ForeignKeyIndexTest extends EntityTestCase {
|
|||
clock.advanceOneMilli();
|
||||
ForeignKeyIndex<HostResource> newFki = loadHostFki("ns1.example.com");
|
||||
assertThat(newFki).isNotEqualTo(originalFki);
|
||||
assertThat(
|
||||
EppResourceUtils.loadByForeignKey(
|
||||
HostResource.class, "ns1.example.com", clock.nowUtc()))
|
||||
.isEqualTo(modifiedHost);
|
||||
assertThat(loadByForeignKey(HostResource.class, "ns1.example.com", clock.nowUtc()))
|
||||
.hasValue(modifiedHost);
|
||||
assertThat(
|
||||
ForeignKeyIndex.loadCached(
|
||||
HostResource.class, ImmutableList.of("ns1.example.com"), clock.nowUtc()))
|
||||
|
|
|
@ -141,7 +141,8 @@ public class EppLifecycleToolsTest extends EppTestCase {
|
|||
DateTime createTime = DateTime.parse("2000-06-01T00:02:00Z");
|
||||
DomainResource domain =
|
||||
loadByForeignKey(
|
||||
DomainResource.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z"));
|
||||
DomainResource.class, "example.tld", DateTime.parse("2003-06-02T00:02:00Z"))
|
||||
.get();
|
||||
BillingEvent.OneTime renewBillingEvent =
|
||||
new BillingEvent.OneTime.Builder()
|
||||
.setReason(Reason.RENEW)
|
||||
|
|
|
@ -196,7 +196,7 @@ public class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsRep
|
|||
|
||||
@Test
|
||||
public void testSuccess_skipDomainsWithoutNameservers() throws Exception {
|
||||
persistResource(domain1.asBuilder().setNameservers(null).build());
|
||||
persistResource(domain1.asBuilder().setNameservers(ImmutableSet.of()).build());
|
||||
runCommand("--output=" + output, "--tld=xn--q9jyb4c");
|
||||
assertThat(getOutputAsJson())
|
||||
.isEqualTo(ImmutableList.of(DOMAIN2_OUTPUT, NAMESERVER1_OUTPUT, NAMESERVER2_OUTPUT));
|
||||
|
|
|
@ -82,7 +82,7 @@ public class LockDomainCommandTest extends EppToolCommandTestCase<LockDomainComm
|
|||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "missing.tld"));
|
||||
assertThat(e).hasMessageThat().isEqualTo("Domain 'missing.tld' does not exist");
|
||||
assertThat(e).hasMessageThat().isEqualTo("Domain 'missing.tld' does not exist or is deleted");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -94,7 +94,7 @@ public class UnlockDomainCommandTest extends EppToolCommandTestCase<UnlockDomain
|
|||
assertThrows(
|
||||
IllegalArgumentException.class,
|
||||
() -> runCommandForced("--client=NewRegistrar", "missing.tld"));
|
||||
assertThat(e).hasMessageThat().isEqualTo("Domain 'missing.tld' does not exist");
|
||||
assertThat(e).hasMessageThat().isEqualTo("Domain 'missing.tld' does not exist or is deleted");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -79,10 +79,12 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
|||
clock.advanceOneMilli();
|
||||
assertThat(
|
||||
loadByForeignKey(DomainResource.class, "foo.tld", clock.nowUtc())
|
||||
.get()
|
||||
.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2019-12-06T13:55:01.001Z"));
|
||||
assertThat(
|
||||
loadByForeignKey(DomainResource.class, "bar.tld", clock.nowUtc())
|
||||
.get()
|
||||
.getRegistrationExpirationTime())
|
||||
.isEqualTo(DateTime.parse("2018-12-06T13:55:01.002Z"));
|
||||
assertInStdout("Successfully unrenewed all domains.");
|
||||
|
@ -99,7 +101,7 @@ public class UnrenewDomainCommandTest extends CommandTestCase<UnrenewDomainComma
|
|||
runCommandForced("-p", "2", "foo.tld");
|
||||
DateTime unrenewTime = clock.nowUtc();
|
||||
clock.advanceOneMilli();
|
||||
DomainResource domain = loadByForeignKey(DomainResource.class, "foo.tld", clock.nowUtc());
|
||||
DomainResource domain = loadByForeignKey(DomainResource.class, "foo.tld", clock.nowUtc()).get();
|
||||
|
||||
assertAboutHistoryEntries()
|
||||
.that(getOnlyHistoryEntryOfType(domain, SYNTHETIC))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue